VAD refactoring
* Added TODO comment * Updated unit test * Code style changes and added comments to set_mode() BUG= TEST=vad_unittests, audioproc_unittest, voe_auto_test Review URL: https://webrtc-codereview.appspot.com/460006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1943 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
534a435751
commit
78f0cdc191
@ -62,25 +62,21 @@ int WebRtcVad_Free(VadInst* handle);
|
||||
// - handle [i/o] : Instance that should be initialized.
|
||||
//
|
||||
// returns : 0 - (OK),
|
||||
// -1 - (NULL pointer or Default mode could not be set)
|
||||
// -1 - (NULL pointer or Default mode could not be set).
|
||||
int WebRtcVad_Init(VadInst* handle);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcVad_set_mode(...)
|
||||
*
|
||||
* This function initializes a VAD instance
|
||||
*
|
||||
* Input:
|
||||
* - vad_inst : VAD instance
|
||||
* - mode : Aggressiveness setting (0, 1, 2, or 3)
|
||||
*
|
||||
* Output:
|
||||
* - vad_inst : Initialized instance
|
||||
*
|
||||
* Return value : 0 - Ok
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcVad_set_mode(VadInst *vad_inst, int mode);
|
||||
// Sets the VAD operating mode. A more aggressive (higher mode) VAD is more
|
||||
// restrictive in reporting speech. Put in other words the probability of being
|
||||
// speech when the VAD returns 1 is increased with increasing mode. As a
|
||||
// consequence also the missed detection rate goes up.
|
||||
//
|
||||
// - handle [i/o] : VAD instance.
|
||||
// - mode [i] : Aggressiveness mode (0, 1, 2, or 3).
|
||||
//
|
||||
// returns : 0 - (OK),
|
||||
// -1 - (NULL pointer, mode could not be set or the VAD instance
|
||||
// has not been initialized).
|
||||
int WebRtcVad_set_mode(VadInst* handle, int mode);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcVad_Process(...)
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common_audio/signal_processing/include/signal_processing_library.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "typedefs.h"
|
||||
#include "webrtc_vad.h"
|
||||
@ -61,7 +62,7 @@ TEST_F(VadTest, ApiTest) {
|
||||
speech[i] = (i * i);
|
||||
}
|
||||
|
||||
// Null instance tests
|
||||
// NULL instance tests
|
||||
EXPECT_EQ(-1, WebRtcVad_Create(NULL));
|
||||
EXPECT_EQ(-1, WebRtcVad_Init(NULL));
|
||||
EXPECT_EQ(-1, WebRtcVad_Assign(NULL, NULL));
|
||||
@ -91,9 +92,14 @@ TEST_F(VadTest, ApiTest) {
|
||||
// WebRtcVad_Init() test
|
||||
ASSERT_EQ(0, WebRtcVad_Init(handle));
|
||||
|
||||
// WebRtcVad_set_mode() invalid modes tests
|
||||
EXPECT_EQ(-1, WebRtcVad_set_mode(handle, kModes[0] - 1));
|
||||
EXPECT_EQ(-1, WebRtcVad_set_mode(handle, kModes[kModesSize - 1] + 1));
|
||||
// WebRtcVad_set_mode() invalid modes tests. Tries smallest supported value
|
||||
// minus one and largest supported value plus one.
|
||||
EXPECT_EQ(-1, WebRtcVad_set_mode(handle,
|
||||
WebRtcSpl_MinValueW32(kModes,
|
||||
kModesSize) - 1));
|
||||
EXPECT_EQ(-1, WebRtcVad_set_mode(handle,
|
||||
WebRtcSpl_MaxValueW32(kModes,
|
||||
kModesSize) + 1));
|
||||
|
||||
// WebRtcVad_Process() tests
|
||||
// NULL speech pointer
|
||||
|
@ -65,22 +65,18 @@ int WebRtcVad_Init(VadInst* handle) {
|
||||
return WebRtcVad_InitCore((VadInstT*) handle);
|
||||
}
|
||||
|
||||
int WebRtcVad_set_mode(VadInst *vad_inst, int mode)
|
||||
{
|
||||
VadInstT* vad_ptr;
|
||||
// TODO(bjornv): Move WebRtcVad_set_mode_core() code here.
|
||||
int WebRtcVad_set_mode(VadInst* handle, int mode) {
|
||||
VadInstT* self = (VadInstT*) handle;
|
||||
|
||||
if (vad_inst == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (handle == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (self->init_flag != kInitCheck) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
vad_ptr = (VadInstT*)vad_inst;
|
||||
if (vad_ptr->init_flag != kInitCheck)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return WebRtcVad_set_mode_core((VadInstT*)vad_inst, mode);
|
||||
return WebRtcVad_set_mode_core(self, mode);
|
||||
}
|
||||
|
||||
WebRtc_Word16 WebRtcVad_Process(VadInst *vad_inst,
|
||||
|
Loading…
x
Reference in New Issue
Block a user