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 |
11 #include "webrtc/modules/audio_processing/agc/pole_zero_filter.h" | 11 #include "webrtc/modules/audio_processing/vad/pole_zero_filter.h" |
12 | 12 |
13 #include <math.h> | 13 #include <math.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 | 15 |
16 #include "gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
18 #include "webrtc/modules/audio_processing/agc/agc_audio_proc_internal.h" | 18 #include "webrtc/modules/audio_processing/vad/vad_audio_proc_internal.h" |
19 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 static const int kInputSamples = 50; | 23 static const int kInputSamples = 50; |
24 | 24 |
25 static const int16_t kInput[kInputSamples] = {-2136, -7116, 10715, 2464, 3164, | 25 static const int16_t kInput[kInputSamples] = { |
26 8139, 11393, 24013, -32117, -5544, -27740, 10181, 14190, -24055, -15912, | 26 -2136, -7116, 10715, 2464, 3164, 8139, 11393, 24013, -32117, -5544, |
27 17393, 6359, -9950, -13894, 32432, -23944, 3437, -8381, 19768, 3087, -19795, | 27 -27740, 10181, 14190, -24055, -15912, 17393, 6359, -9950, -13894, 32432, |
28 -5920, 13310, 1407, 3876, 4059, 3524, -23130, 19121, -27900, -24840, 4089, | 28 -23944, 3437, -8381, 19768, 3087, -19795, -5920, 13310, 1407, 3876, |
29 21422, -3625, 3015, -11236, 28856, 13424, 6571, -19761, -6361, 15821, -9469, | 29 4059, 3524, -23130, 19121, -27900, -24840, 4089, 21422, -3625, 3015, |
30 29727, 32229}; | 30 -11236, 28856, 13424, 6571, -19761, -6361, 15821, -9469, 29727, 32229}; |
31 | 31 |
32 static const float kReferenceOutput[kInputSamples] = {-2082.230472f, | 32 static const float kReferenceOutput[kInputSamples] = { |
33 -6878.572941f, 10697.090871f, 2358.373952f, 2973.936512f, 7738.580650f, | 33 -2082.230472f, -6878.572941f, 10697.090871f, 2358.373952f, |
34 10690.803213f, 22687.091576f, -32676.684717f, -5879.621684f, -27359.297432f, | 34 2973.936512f, 7738.580650f, 10690.803213f, 22687.091576f, |
35 10368.735888f, 13994.584604f, -23676.126249f, -15078.250390f, 17818.253338f, | 35 -32676.684717f, -5879.621684f, -27359.297432f, 10368.735888f, |
36 6577.743123f, -9498.369315f, -13073.651079f, 32460.026588f, -23391.849347f, | 36 13994.584604f, -23676.126249f, -15078.250390f, 17818.253338f, |
37 3953.805667f, -7667.761363f, 19995.153447f, 3185.575477f, -19207.365160f, | 37 6577.743123f, -9498.369315f, -13073.651079f, 32460.026588f, |
38 -5143.103201f, 13756.317237f, 1779.654794f, 4142.269755f, 4209.475034f, | 38 -23391.849347f, 3953.805667f, -7667.761363f, 19995.153447f, |
39 3572.991789f, -22509.089546f, 19307.878964f, -27060.439759f, -23319.042810f, | 39 3185.575477f, -19207.365160f, -5143.103201f, 13756.317237f, |
40 5547.685267f, 22312.718676f, -2707.309027f, 3852.358490f, -10135.510093f, | 40 1779.654794f, 4142.269755f, 4209.475034f, 3572.991789f, |
41 29241.509970f, 13394.397233f, 6340.721417f, -19510.207905f, -5908.442086f, | 41 -22509.089546f, 19307.878964f, -27060.439759f, -23319.042810f, |
42 15882.301634f, -9211.335255f, 29253.056735f, 30874.443046f}; | 42 5547.685267f, 22312.718676f, -2707.309027f, 3852.358490f, |
| 43 -10135.510093f, 29241.509970f, 13394.397233f, 6340.721417f, |
| 44 -19510.207905f, -5908.442086f, 15882.301634f, -9211.335255f, |
| 45 29253.056735f, 30874.443046f}; |
43 | 46 |
44 class PoleZeroFilterTest : public ::testing::Test { | 47 class PoleZeroFilterTest : public ::testing::Test { |
45 protected: | 48 protected: |
46 PoleZeroFilterTest() | 49 PoleZeroFilterTest() |
47 : my_filter_(PoleZeroFilter::Create( | 50 : my_filter_(PoleZeroFilter::Create(kCoeffNumerator, |
48 kCoeffNumerator, kFilterOrder, kCoeffDenominator, kFilterOrder)) {} | 51 kFilterOrder, |
| 52 kCoeffDenominator, |
| 53 kFilterOrder)) {} |
49 | 54 |
50 ~PoleZeroFilterTest() {} | 55 ~PoleZeroFilterTest() {} |
51 | 56 |
52 void FilterSubframes(int num_subframes); | 57 void FilterSubframes(int num_subframes); |
53 | 58 |
54 private: | 59 private: |
55 void TestClean(); | 60 void TestClean(); |
56 rtc::scoped_ptr<PoleZeroFilter> my_filter_; | 61 rtc::scoped_ptr<PoleZeroFilter> my_filter_; |
57 }; | 62 }; |
58 | 63 |
(...skipping 29 matching lines...) Expand all Loading... |
88 | 93 |
89 TEST_F(PoleZeroFilterTest, TwentyFiveSubframes) { | 94 TEST_F(PoleZeroFilterTest, TwentyFiveSubframes) { |
90 FilterSubframes(25); | 95 FilterSubframes(25); |
91 } | 96 } |
92 | 97 |
93 TEST_F(PoleZeroFilterTest, FiftySubframes) { | 98 TEST_F(PoleZeroFilterTest, FiftySubframes) { |
94 FilterSubframes(50); | 99 FilterSubframes(50); |
95 } | 100 } |
96 | 101 |
97 } // namespace webrtc | 102 } // namespace webrtc |
OLD | NEW |