VAD Refactoring: API change of return value from int16_t to int.

This CL change the return int on Process() to meet Google Style. The change affects audio_coding and neteq.

Tests have been changed accordingly and the code has been tested on trybots, vad_unittests, audioproc_unittest, audio_coding_unittests, audio_coding_module_test and neteq_unittests.

BUG=None
TEST=None

Review URL: https://webrtc-codereview.appspot.com/663005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2423 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org 2012-06-19 11:03:32 +00:00
parent f477aac844
commit b38fca1ec2
11 changed files with 34 additions and 34 deletions

View File

@ -71,8 +71,8 @@ int WebRtcVad_set_mode(VadInst* handle, int mode);
// returns : 1 - (Active Voice),
// 0 - (Non-active Voice),
// -1 - (Error)
int16_t WebRtcVad_Process(VadInst* handle, int16_t fs, int16_t* audio_frame,
int16_t frame_length);
int WebRtcVad_Process(VadInst* handle, int fs, int16_t* audio_frame,
int frame_length);
// Checks for valid combinations of |rate| and |frame_length|. We support 10,
// 20 and 30 ms frames and the rates 8000, 16000 and 32000 Hz.

View File

@ -600,10 +600,10 @@ int WebRtcVad_set_mode_core(VadInstT* self, int mode) {
// Calculate VAD decision by first extracting feature values and then calculate
// probability for both speech and background noise.
int16_t WebRtcVad_CalcVad32khz(VadInstT* inst, int16_t* speech_frame,
int frame_length)
int WebRtcVad_CalcVad32khz(VadInstT* inst, int16_t* speech_frame,
int frame_length)
{
int16_t len, vad;
int len, vad;
int16_t speechWB[480]; // Downsampled speech frame: 960 samples (30ms in SWB)
int16_t speechNB[240]; // Downsampled speech frame: 480 samples (30ms in WB)
@ -622,10 +622,10 @@ int16_t WebRtcVad_CalcVad32khz(VadInstT* inst, int16_t* speech_frame,
return vad;
}
int16_t WebRtcVad_CalcVad16khz(VadInstT* inst, int16_t* speech_frame,
int frame_length)
int WebRtcVad_CalcVad16khz(VadInstT* inst, int16_t* speech_frame,
int frame_length)
{
int16_t len, vad;
int len, vad;
int16_t speechNB[240]; // Downsampled speech frame: 480 samples (30ms in WB)
// Wideband: Downsample signal before doing VAD
@ -638,8 +638,8 @@ int16_t WebRtcVad_CalcVad16khz(VadInstT* inst, int16_t* speech_frame,
return vad;
}
int16_t WebRtcVad_CalcVad8khz(VadInstT* inst, int16_t* speech_frame,
int frame_length)
int WebRtcVad_CalcVad8khz(VadInstT* inst, int16_t* speech_frame,
int frame_length)
{
int16_t feature_vector[kNumChannels], total_power;

View File

@ -26,7 +26,7 @@ enum { kMinEnergy = 10 }; // Minimum energy required to trigger audio signal.
typedef struct VadInstT_
{
int16_t vad;
int vad;
int32_t downsampling_filter_states[4];
int16_t noise_means[kTableSize];
int16_t speech_means[kTableSize];
@ -100,11 +100,11 @@ int WebRtcVad_set_mode_core(VadInstT* self, int mode);
* 0 - No active speech
* 1-6 - Active speech
*/
int16_t WebRtcVad_CalcVad32khz(VadInstT* inst, int16_t* speech_frame,
int frame_length);
int16_t WebRtcVad_CalcVad16khz(VadInstT* inst, int16_t* speech_frame,
int frame_length);
int16_t WebRtcVad_CalcVad8khz(VadInstT* inst, int16_t* speech_frame,
int frame_length);
int WebRtcVad_CalcVad32khz(VadInstT* inst, int16_t* speech_frame,
int frame_length);
int WebRtcVad_CalcVad16khz(VadInstT* inst, int16_t* speech_frame,
int frame_length);
int WebRtcVad_CalcVad8khz(VadInstT* inst, int16_t* speech_frame,
int frame_length);
#endif // WEBRTC_COMMON_AUDIO_VAD_VAD_CORE_H_

View File

@ -25,7 +25,7 @@ void VadTest::SetUp() {}
void VadTest::TearDown() {}
// Returns true if the rate and frame length combination is valid.
bool VadTest::ValidRatesAndFrameLengths(int16_t rate, int16_t frame_length) {
bool VadTest::ValidRatesAndFrameLengths(int rate, int frame_length) {
if (rate == 8000) {
if (frame_length == 80 || frame_length == 160 || frame_length == 240) {
return true;

View File

@ -24,12 +24,12 @@ const int kModes[] = { 0, 1, 2, 3 };
const size_t kModesSize = sizeof(kModes) / sizeof(*kModes);
// Rates we support.
const int16_t kRates[] = { 8000, 12000, 16000, 24000, 32000 };
const int kRates[] = { 8000, 12000, 16000, 24000, 32000 };
const size_t kRatesSize = sizeof(kRates) / sizeof(*kRates);
// Frame lengths we support.
const int16_t kMaxFrameLength = 960;
const int16_t kFrameLengths[] = { 80, 120, 160, 240, 320, 480, 640,
const int kMaxFrameLength = 960;
const int kFrameLengths[] = { 80, 120, 160, 240, 320, 480, 640,
kMaxFrameLength };
const size_t kFrameLengthsSize = sizeof(kFrameLengths) / sizeof(*kFrameLengths);
@ -42,7 +42,7 @@ class VadTest : public ::testing::Test {
virtual void TearDown();
// Returns true if the rate and frame length combination is valid.
bool ValidRatesAndFrameLengths(int16_t rate, int16_t frame_length);
bool ValidRatesAndFrameLengths(int rate, int frame_length);
};
#endif // WEBRTC_COMMON_AUDIO_VAD_VAD_UNITTEST_H

View File

@ -71,9 +71,9 @@ int WebRtcVad_set_mode(VadInst* handle, int mode) {
return WebRtcVad_set_mode_core(self, mode);
}
int16_t WebRtcVad_Process(VadInst* handle, int16_t fs, int16_t* audio_frame,
int16_t frame_length) {
int16_t vad = -1;
int WebRtcVad_Process(VadInst* handle, int fs, int16_t* audio_frame,
int frame_length) {
int vad = -1;
VadInstT* self = (VadInstT*) handle;
if (handle == NULL) {

View File

@ -1350,7 +1350,7 @@ ACMGenericCodec::ProcessFrameVADDTX(
}
// Call VAD
status = WebRtcVad_Process(_ptrVADInst, (WebRtc_Word16)freqHz,
status = (WebRtc_Word16)WebRtcVad_Process(_ptrVADInst, (int)freqHz,
audio, noSamplesToProcess[i]);
_vadLabel[i] = status;

View File

@ -194,7 +194,7 @@ int WebRtcNetEQ_DSPInit(DSPInst_t *inst, WebRtc_UWord16 fs)
VADSetmodeFunction savedVADsetmode = inst->VADInst.setmodeFunction;
VADFunction savedVADfunc = inst->VADInst.VADFunction;
WebRtc_Word16 savedVADEnabled = inst->VADInst.VADEnabled;
WebRtc_Word16 savedVADMode = inst->VADInst.VADMode;
int savedVADMode = inst->VADInst.VADMode;
#endif /* NETEQ_VAD */
DSPStats_t saveStats;
WebRtc_Word16 saveMsPerCall = inst->millisecondsPerCall;

View File

@ -190,8 +190,8 @@ typedef struct ExpandInst_t_
*/
typedef int (*VADInitFunction)(void *VAD_inst);
typedef int (*VADSetmodeFunction)(void *VAD_inst, int mode);
typedef WebRtc_Word16 (*VADFunction)(void *VAD_inst, WebRtc_Word16 fs, WebRtc_Word16 *frame,
WebRtc_Word16 frameLen);
typedef int (*VADFunction)(void *VAD_inst, int fs, WebRtc_Word16 *frame,
int frameLen);
/* Post-decode VAD instance (sub-instance of NETEQDSP_inst) */
typedef struct PostDecodeVAD_t_
@ -201,7 +201,7 @@ typedef struct PostDecodeVAD_t_
WebRtc_Word16 VADEnabled; /* 1 if enabled, 0 if disabled */
int VADMode; /* mode parameter to pass to the VAD function */
WebRtc_Word16 VADDecision; /* 1 for active, 0 for passive */
int VADDecision; /* 1 for active, 0 for passive */
WebRtc_Word16 SIDintervalCounter; /* reset when decoding CNG/SID frame,
increment for each recout call */

View File

@ -140,8 +140,8 @@ int WebRtcNetEQ_GetRawFrameWaitingTimes(void *inst,
*/
typedef int (*WebRtcNetEQ_VADInitFunction)(void *VAD_inst);
typedef int (*WebRtcNetEQ_VADSetmodeFunction)(void *VAD_inst, int mode);
typedef WebRtc_Word16 (*WebRtcNetEQ_VADFunction)(void *VAD_inst, WebRtc_Word16 fs,
WebRtc_Word16 *frame, WebRtc_Word16 frameLen);
typedef int (*WebRtcNetEQ_VADFunction)(void *VAD_inst, int fs,
WebRtc_Word16 *frame, int frameLen);
/****************************************************************************
* WebRtcNetEQ_SetVADInstance(...)

View File

@ -622,9 +622,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData,
/* call VAD with new decoded data */
inst->VADInst.VADDecision |= inst->VADInst.VADFunction(
inst->VADInst.VADState, (WebRtc_Word16) inst->fs,
inst->VADInst.VADState, (int) inst->fs,
(WebRtc_Word16 *) &pw16_decoded_buffer[VADSamplePtr],
(WebRtc_Word16) (VADframeSize * fs_mult * 8));
(VADframeSize * fs_mult * 8));
VADSamplePtr += VADframeSize * fs_mult * 8; /* increment sample counter */
}