| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 1479, 1385, 1291, 1200, 1103, 1099, | 31 1479, 1385, 1291, 1200, 1103, 1099, |
| 32 1732, 1692, 1681, 1629, 1436, 1436 | 32 1732, 1692, 1681, 1629, 1436, 1436 |
| 33 }; | 33 }; |
| 34 static const int16_t kOffsetVector[kNumChannels] = { | 34 static const int16_t kOffsetVector[kNumChannels] = { |
| 35 368, 368, 272, 176, 176, 176 }; | 35 368, 368, 272, 176, 176, 176 }; |
| 36 int16_t features[kNumChannels]; | 36 int16_t features[kNumChannels]; |
| 37 | 37 |
| 38 // Construct a speech signal that will trigger the VAD in all modes. It is | 38 // Construct a speech signal that will trigger the VAD in all modes. It is |
| 39 // known that (i * i) will wrap around, but that doesn't matter in this case. | 39 // known that (i * i) will wrap around, but that doesn't matter in this case. |
| 40 int16_t speech[kMaxFrameLength]; | 40 int16_t speech[kMaxFrameLength]; |
| 41 for (int16_t i = 0; i < kMaxFrameLength; ++i) { | 41 for (size_t i = 0; i < kMaxFrameLength; ++i) { |
| 42 speech[i] = static_cast<int16_t>(i * i); | 42 speech[i] = static_cast<int16_t>(i * i); |
| 43 } | 43 } |
| 44 | 44 |
| 45 int frame_length_index = 0; | 45 int frame_length_index = 0; |
| 46 ASSERT_EQ(0, WebRtcVad_InitCore(self)); | 46 ASSERT_EQ(0, WebRtcVad_InitCore(self)); |
| 47 for (size_t j = 0; j < kFrameLengthsSize; ++j) { | 47 for (size_t j = 0; j < kFrameLengthsSize; ++j) { |
| 48 if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { | 48 if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { |
| 49 EXPECT_EQ(kReference[frame_length_index], | 49 EXPECT_EQ(kReference[frame_length_index], |
| 50 WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], | 50 WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], |
| 51 features)); | 51 features)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 66 EXPECT_EQ(0, WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], | 66 EXPECT_EQ(0, WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], |
| 67 features)); | 67 features)); |
| 68 for (int k = 0; k < kNumChannels; ++k) { | 68 for (int k = 0; k < kNumChannels; ++k) { |
| 69 EXPECT_EQ(kOffsetVector[k], features[k]); | 69 EXPECT_EQ(kOffsetVector[k], features[k]); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Verify that all ones in gives kOffsetVector out. Any other constant input | 74 // Verify that all ones in gives kOffsetVector out. Any other constant input |
| 75 // will have a small impact in the sub bands. | 75 // will have a small impact in the sub bands. |
| 76 for (int16_t i = 0; i < kMaxFrameLength; ++i) { | 76 for (size_t i = 0; i < kMaxFrameLength; ++i) { |
| 77 speech[i] = 1; | 77 speech[i] = 1; |
| 78 } | 78 } |
| 79 for (size_t j = 0; j < kFrameLengthsSize; ++j) { | 79 for (size_t j = 0; j < kFrameLengthsSize; ++j) { |
| 80 if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { | 80 if (ValidRatesAndFrameLengths(8000, kFrameLengths[j])) { |
| 81 ASSERT_EQ(0, WebRtcVad_InitCore(self)); | 81 ASSERT_EQ(0, WebRtcVad_InitCore(self)); |
| 82 EXPECT_EQ(0, WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], | 82 EXPECT_EQ(0, WebRtcVad_CalculateFeatures(self, speech, kFrameLengths[j], |
| 83 features)); | 83 features)); |
| 84 for (int k = 0; k < kNumChannels; ++k) { | 84 for (int k = 0; k < kNumChannels; ++k) { |
| 85 EXPECT_EQ(kOffsetVector[k], features[k]); | 85 EXPECT_EQ(kOffsetVector[k], features[k]); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 free(self); | 90 free(self); |
| 91 } | 91 } |
| 92 } // namespace | 92 } // namespace |
| OLD | NEW |