aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/audio_processing/utility
diff options
context:
space:
mode:
authorbjornv@webrtc.org <bjornv@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2013-11-28 14:58:35 +0000
committerbjornv@webrtc.org <bjornv@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2013-11-28 14:58:35 +0000
commitbd41a846940fca1fb40c7ae4c9114a2976a68fbc (patch)
tree09d7bf1f54d2353531f07b0cf7fdaa4e07ea0a1b /webrtc/modules/audio_processing/utility
parentb627f676b3be77e8d9da55104d6553d6972cd2a1 (diff)
downloadwebrtc-bd41a846940fca1fb40c7ae4c9114a2976a68fbc.tar.gz
This CL adds an API to enable robust validation of delay estimates.
Added is - a member variable for turning robust validation on and off. - API to enable/disable feature. - API to check if enabled. - unit tests for these APIs. Not added is - the actual functionality (separate CL), hence turning feature on/off has no impact currently. - calls in AEC and AEC, where the delay estimator is used. This is also done in a separate CL when we know if it should be turned on in both components. TESTED=trybots, module_unittest BUG= R=aluebs@webrtc.org Review URL: https://webrtc-codereview.appspot.com/4609005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5191 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/modules/audio_processing/utility')
-rw-r--r--webrtc/modules/audio_processing/utility/delay_estimator.c2
-rw-r--r--webrtc/modules/audio_processing/utility/delay_estimator.h3
-rw-r--r--webrtc/modules/audio_processing/utility/delay_estimator_unittest.cc21
-rw-r--r--webrtc/modules/audio_processing/utility/delay_estimator_wrapper.c24
-rw-r--r--webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h12
5 files changed, 62 insertions, 0 deletions
diff --git a/webrtc/modules/audio_processing/utility/delay_estimator.c b/webrtc/modules/audio_processing/utility/delay_estimator.c
index f6cdaa2a2f..062874dc2b 100644
--- a/webrtc/modules/audio_processing/utility/delay_estimator.c
+++ b/webrtc/modules/audio_processing/utility/delay_estimator.c
@@ -196,6 +196,8 @@ void WebRtc_InitBinaryDelayEstimator(BinaryDelayEstimator* self) {
// Default return value if we're unable to estimate. -1 is used for errors.
self->last_delay = -2;
+
+ self->robust_validation_enabled = 0; // Disabled by default.
}
int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
diff --git a/webrtc/modules/audio_processing/utility/delay_estimator.h b/webrtc/modules/audio_processing/utility/delay_estimator.h
index bf2b08a217..561514b485 100644
--- a/webrtc/modules/audio_processing/utility/delay_estimator.h
+++ b/webrtc/modules/audio_processing/utility/delay_estimator.h
@@ -42,6 +42,9 @@ typedef struct {
// Delay memory.
int last_delay;
+ // Robust validation
+ int robust_validation_enabled;
+
// Far-end binary spectrum history buffer etc.
BinaryDelayEstimatorFarend* farend;
} BinaryDelayEstimator;
diff --git a/webrtc/modules/audio_processing/utility/delay_estimator_unittest.cc b/webrtc/modules/audio_processing/utility/delay_estimator_unittest.cc
index f4b47114e7..bdc199cafb 100644
--- a/webrtc/modules/audio_processing/utility/delay_estimator_unittest.cc
+++ b/webrtc/modules/audio_processing/utility/delay_estimator_unittest.cc
@@ -246,6 +246,17 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) {
EXPECT_EQ(-1, WebRtc_AddFarSpectrumFix(farend_handle_, far_u16_,
spectrum_size_, 16));
+ // WebRtc_enable_robust_validation() should return -1 if we have:
+ // 1) NULL pointer as |handle|.
+ // 2) Incorrect |enable| value (not 0 or 1).
+ EXPECT_EQ(-1, WebRtc_enable_robust_validation(NULL, 0));
+ EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, -1));
+ EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, 2));
+
+ // WebRtc_is_robust_validation_enabled() should return -1 if we have NULL
+ // pointer as |handle|.
+ EXPECT_EQ(-1, WebRtc_is_robust_validation_enabled(NULL));
+
// WebRtc_DelayEstimatorProcessFloat() should return -1 if we have:
// 1) NULL pointer as |handle|.
// 2) NULL pointer as near-end spectrum.
@@ -283,6 +294,16 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) {
WebRtc_FreeDelayEstimator(handle);
}
+TEST_F(DelayEstimatorTest, VerifyEnableRobustValidation) {
+ Init();
+ // Disabled by default.
+ EXPECT_EQ(0, WebRtc_is_robust_validation_enabled(handle_));
+ for (int i = 1; i >= 0; i--) {
+ EXPECT_EQ(0, WebRtc_enable_robust_validation(handle_, i));
+ EXPECT_EQ(i, WebRtc_is_robust_validation_enabled(handle_));
+ }
+}
+
TEST_F(DelayEstimatorTest, InitializedSpectrumAfterProcess) {
// In this test we verify that the mean spectra are initialized after first
// time we call WebRtc_AddFarSpectrum() and Process() respectively.
diff --git a/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.c b/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.c
index b72b8ffa07..ce4431844e 100644
--- a/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.c
+++ b/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.c
@@ -312,6 +312,30 @@ int WebRtc_InitDelayEstimator(void* handle) {
return 0;
}
+int WebRtc_enable_robust_validation(void* handle, int enable) {
+ DelayEstimator* self = (DelayEstimator*) handle;
+
+ if (self == NULL) {
+ return -1;
+ }
+ if ((enable < 0) || (enable > 1)) {
+ return -1;
+ }
+ assert(self->binary_handle != NULL);
+ self->binary_handle->robust_validation_enabled = enable;
+ return 0;
+}
+
+int WebRtc_is_robust_validation_enabled(void* handle) {
+ DelayEstimator* self = (DelayEstimator*) handle;
+
+ if (self == NULL) {
+ return -1;
+ }
+ assert(self->binary_handle != NULL);
+ return self->binary_handle->robust_validation_enabled;
+}
+
int WebRtc_DelayEstimatorProcessFix(void* handle,
uint16_t* near_spectrum,
int spectrum_size,
diff --git a/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h b/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h
index 51b9a0a1d5..50bcddeddc 100644
--- a/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h
+++ b/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h
@@ -123,6 +123,18 @@ void* WebRtc_CreateDelayEstimator(void* farend_handle, int lookahead);
//
int WebRtc_InitDelayEstimator(void* handle);
+// TODO(bjornv): Implement this functionality. Currently, enabling it has no
+// impact, hence this is an empty API.
+// Enables/Disables a robust validation functionality in the delay estimation.
+// This is by default disabled upon initialization.
+// Inputs:
+// - handle : Pointer to the delay estimation instance.
+// - enable : Enable (1) or disable (0) this feature.
+int WebRtc_enable_robust_validation(void* handle, int enable);
+
+// Returns 1 if robust validation is enabled and 0 if disabled.
+int WebRtc_is_robust_validation_enabled(void* handle);
+
// Estimates and returns the delay between the far-end and near-end blocks. The
// value will be offset by the lookahead (i.e. the lookahead should be
// subtracted from the returned value).