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/vad/vad_circular_buffer.h" | 11 #include "webrtc/modules/audio_processing/vad/vad_circular_buffer.h" |
12 | 12 |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 | 14 |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "webrtc/test/gtest.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 static const int kWidthThreshold = 7; | 21 static const int kWidthThreshold = 7; |
22 static const double kValThreshold = 1.0; | 22 static const double kValThreshold = 1.0; |
23 static const int kLongBuffSize = 100; | 23 static const int kLongBuffSize = 100; |
24 static const int kShortBuffSize = 10; | 24 static const int kShortBuffSize = 10; |
25 | 25 |
26 static void InsertSequentially(int k, VadCircularBuffer* circular_buffer) { | 26 static void InsertSequentially(int k, VadCircularBuffer* circular_buffer) { |
27 double mean_val; | 27 double mean_val; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // it shouldn't be considered transient. | 125 // it shouldn't be considered transient. |
126 Insert(push_val, num_insertion, circular_buffer.get()); | 126 Insert(push_val, num_insertion, circular_buffer.get()); |
127 num_non_zero_elements += num_insertion; | 127 num_non_zero_elements += num_insertion; |
128 EXPECT_EQ(0, | 128 EXPECT_EQ(0, |
129 circular_buffer->RemoveTransient(kWidthThreshold, kValThreshold)); | 129 circular_buffer->RemoveTransient(kWidthThreshold, kValThreshold)); |
130 mean_val = circular_buffer->Mean(); | 130 mean_val = circular_buffer->Mean(); |
131 EXPECT_DOUBLE_EQ(num_non_zero_elements * push_val / kLongBuffSize, mean_val); | 131 EXPECT_DOUBLE_EQ(num_non_zero_elements * push_val / kLongBuffSize, mean_val); |
132 } | 132 } |
133 | 133 |
134 } // namespace webrtc | 134 } // namespace webrtc |
OLD | NEW |