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
This commit is contained in:
bjornv@webrtc.org 2013-11-28 14:58:35 +00:00
parent b627f676b3
commit bd41a84694
5 changed files with 62 additions and 0 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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.

View File

@ -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,

View File

@ -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).