Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Unified Diff: webrtc/modules/audio_processing/vad/vad_circular_buffer_unittest.cc

Issue 1212543002: Pull the Voice Activity Detector out from the AGC (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/vad/vad_circular_buffer_unittest.cc
diff --git a/webrtc/modules/audio_processing/agc/circular_buffer_unittest.cc b/webrtc/modules/audio_processing/vad/vad_circular_buffer_unittest.cc
similarity index 76%
rename from webrtc/modules/audio_processing/agc/circular_buffer_unittest.cc
rename to webrtc/modules/audio_processing/vad/vad_circular_buffer_unittest.cc
index e80a5d0fa156f8a0fe38d4b169e095dad29481b8..11945e042cf719bab18ec6e837c87f6a861022e1 100644
--- a/webrtc/modules/audio_processing/agc/circular_buffer_unittest.cc
+++ b/webrtc/modules/audio_processing/vad/vad_circular_buffer_unittest.cc
@@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/modules/audio_processing/agc/circular_buffer.h"
+#include "webrtc/modules/audio_processing/vad/vad_circular_buffer.h"
#include <stdio.h>
@@ -22,7 +22,7 @@ static const double kValThreshold = 1.0;
static const int kLongBuffSize = 100;
static const int kShortBuffSize = 10;
-static void InsertSequentially(int k, AgcCircularBuffer* circular_buffer) {
+static void InsertSequentially(int k, VadCircularBuffer* circular_buffer) {
double mean_val;
for (int n = 1; n <= k; n++) {
EXPECT_TRUE(!circular_buffer->is_full());
@@ -32,19 +32,20 @@ static void InsertSequentially(int k, AgcCircularBuffer* circular_buffer) {
}
}
-static void Insert(double value, int num_insertion,
- AgcCircularBuffer* circular_buffer) {
+static void Insert(double value,
+ int num_insertion,
+ VadCircularBuffer* circular_buffer) {
for (int n = 0; n < num_insertion; n++)
circular_buffer->Insert(value);
}
-static void InsertZeros(int num_zeros, AgcCircularBuffer* circular_buffer) {
+static void InsertZeros(int num_zeros, VadCircularBuffer* circular_buffer) {
Insert(0.0, num_zeros, circular_buffer);
}
-TEST(AgcCircularBufferTest, GeneralTest) {
- rtc::scoped_ptr<AgcCircularBuffer> circular_buffer(
- AgcCircularBuffer::Create(kShortBuffSize));
+TEST(VadCircularBufferTest, GeneralTest) {
+ rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
+ VadCircularBuffer::Create(kShortBuffSize));
double mean_val;
// Mean should return zero if nothing is inserted.
@@ -70,9 +71,9 @@ TEST(AgcCircularBufferTest, GeneralTest) {
EXPECT_TRUE(circular_buffer->is_full());
}
-TEST(AgcCircularBufferTest, TransientsRemoval) {
- rtc::scoped_ptr<AgcCircularBuffer> circular_buffer(
- AgcCircularBuffer::Create(kLongBuffSize));
+TEST(VadCircularBufferTest, TransientsRemoval) {
+ rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
+ VadCircularBuffer::Create(kLongBuffSize));
// Let the first transient be in wrap-around.
InsertZeros(kLongBuffSize - kWidthThreshold / 2, circular_buffer.get());
@@ -89,9 +90,9 @@ TEST(AgcCircularBufferTest, TransientsRemoval) {
}
}
-TEST(AgcCircularBufferTest, TransientDetection) {
- rtc::scoped_ptr<AgcCircularBuffer> circular_buffer(
- AgcCircularBuffer::Create(kLongBuffSize));
+TEST(VadCircularBufferTest, TransientDetection) {
+ rtc::scoped_ptr<VadCircularBuffer> circular_buffer(
+ VadCircularBuffer::Create(kLongBuffSize));
// Let the first transient be in wrap-around.
int num_insertion = kLongBuffSize - kWidthThreshold / 2;
InsertZeros(num_insertion, circular_buffer.get());
@@ -104,8 +105,8 @@ TEST(AgcCircularBufferTest, TransientDetection) {
double mean_val = circular_buffer->Mean();
EXPECT_DOUBLE_EQ(num_non_zero_elements * push_val / kLongBuffSize, mean_val);
circular_buffer->Insert(0);
- EXPECT_EQ(0, circular_buffer->RemoveTransient(kWidthThreshold,
- kValThreshold));
+ EXPECT_EQ(0,
+ circular_buffer->RemoveTransient(kWidthThreshold, kValThreshold));
mean_val = circular_buffer->Mean();
EXPECT_DOUBLE_EQ(num_non_zero_elements * push_val / kLongBuffSize, mean_val);
@@ -114,8 +115,8 @@ TEST(AgcCircularBufferTest, TransientDetection) {
num_insertion = 3;
Insert(push_val, num_insertion, circular_buffer.get());
circular_buffer->Insert(0);
- EXPECT_EQ(0, circular_buffer->RemoveTransient(kWidthThreshold,
- kValThreshold));
+ EXPECT_EQ(0,
+ circular_buffer->RemoveTransient(kWidthThreshold, kValThreshold));
mean_val = circular_buffer->Mean();
EXPECT_DOUBLE_EQ(num_non_zero_elements * push_val / kLongBuffSize, mean_val);
@@ -123,8 +124,8 @@ TEST(AgcCircularBufferTest, TransientDetection) {
// it shouldn't be considered transient.
Insert(push_val, num_insertion, circular_buffer.get());
num_non_zero_elements += num_insertion;
- EXPECT_EQ(0, circular_buffer->RemoveTransient(kWidthThreshold,
- kValThreshold));
+ EXPECT_EQ(0,
+ circular_buffer->RemoveTransient(kWidthThreshold, kValThreshold));
mean_val = circular_buffer->Mean();
EXPECT_DOUBLE_EQ(num_non_zero_elements * push_val / kLongBuffSize, mean_val);
}

Powered by Google App Engine
This is Rietveld 408576698