Update audio_processing module

Corresponds to upstream commit 524e9b043e7e86fd72353b987c9d5f6a1ebf83e1

Update notes:

 * Pull in third party license file

 * Replace .gypi files with BUILD.gn to keep track of what changes
   upstream

 * Bunch of new filse pulled in as dependencies

 * Won't build yet due to changes needed on top of these
This commit is contained in:
Arun Raghavan
2015-10-13 17:25:22 +05:30
parent 5ae7a5d6cd
commit 753eada3aa
324 changed files with 52533 additions and 16117 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
@ -8,45 +8,40 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "voice_detection_impl.h"
#include "webrtc/modules/audio_processing/voice_detection_impl.h"
#include <cassert>
#include <assert.h>
#include "critical_section_wrapper.h"
#include "webrtc_vad.h"
#include "audio_processing_impl.h"
#include "audio_buffer.h"
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
namespace webrtc {
typedef VadInst Handle;
namespace {
WebRtc_Word16 MapSetting(VoiceDetection::Likelihood likelihood) {
int MapSetting(VoiceDetection::Likelihood likelihood) {
switch (likelihood) {
case VoiceDetection::kVeryLowLikelihood:
return 3;
break;
case VoiceDetection::kLowLikelihood:
return 2;
break;
case VoiceDetection::kModerateLikelihood:
return 1;
break;
case VoiceDetection::kHighLikelihood:
return 0;
break;
default:
return -1;
}
assert(false);
return -1;
}
} // namespace
VoiceDetectionImpl::VoiceDetectionImpl(const AudioProcessingImpl* apm)
: ProcessingComponent(apm),
VoiceDetectionImpl::VoiceDetectionImpl(const AudioProcessing* apm,
CriticalSectionWrapper* crit)
: ProcessingComponent(),
apm_(apm),
crit_(crit),
stream_has_voice_(false),
using_external_vad_(false),
likelihood_(kLowLikelihood),
@ -64,19 +59,13 @@ int VoiceDetectionImpl::ProcessCaptureAudio(AudioBuffer* audio) {
using_external_vad_ = false;
return apm_->kNoError;
}
assert(audio->samples_per_split_channel() <= 160);
WebRtc_Word16* mixed_data = audio->low_pass_split_data(0);
if (audio->num_channels() > 1) {
audio->CopyAndMixLowPass(1);
mixed_data = audio->mixed_low_pass_data(0);
}
assert(audio->num_frames_per_band() <= 160);
// TODO(ajm): concatenate data in frame buffer here.
int vad_ret = WebRtcVad_Process(static_cast<Handle*>(handle(0)),
apm_->split_sample_rate_hz(),
mixed_data,
apm_->proc_split_sample_rate_hz(),
audio->mixed_low_pass_data(),
frame_size_samples_);
if (vad_ret == 0) {
stream_has_voice_ = false;
@ -92,7 +81,7 @@ int VoiceDetectionImpl::ProcessCaptureAudio(AudioBuffer* audio) {
}
int VoiceDetectionImpl::Enable(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit());
CriticalSectionScoped crit_scoped(crit_);
return EnableComponent(enable);
}
@ -113,7 +102,7 @@ bool VoiceDetectionImpl::stream_has_voice() const {
}
int VoiceDetectionImpl::set_likelihood(VoiceDetection::Likelihood likelihood) {
CriticalSectionScoped crit_scoped(*apm_->crit());
CriticalSectionScoped crit_scoped(crit_);
if (MapSetting(likelihood) == -1) {
return apm_->kBadParameterError;
}
@ -127,7 +116,7 @@ VoiceDetection::Likelihood VoiceDetectionImpl::likelihood() const {
}
int VoiceDetectionImpl::set_frame_size_ms(int size) {
CriticalSectionScoped crit_scoped(*apm_->crit());
CriticalSectionScoped crit_scoped(crit_);
assert(size == 10); // TODO(ajm): remove when supported.
if (size != 10 &&
size != 20 &&
@ -151,34 +140,19 @@ int VoiceDetectionImpl::Initialize() {
}
using_external_vad_ = false;
frame_size_samples_ = frame_size_ms_ * (apm_->split_sample_rate_hz() / 1000);
frame_size_samples_ = static_cast<size_t>(
frame_size_ms_ * apm_->proc_split_sample_rate_hz() / 1000);
// TODO(ajm): intialize frame buffer here.
return apm_->kNoError;
}
int VoiceDetectionImpl::get_version(char* version,
int version_len_bytes) const {
if (WebRtcVad_get_version(version, version_len_bytes) != 0) {
return apm_->kBadParameterError;
}
return apm_->kNoError;
}
void* VoiceDetectionImpl::CreateHandle() const {
Handle* handle = NULL;
if (WebRtcVad_Create(&handle) != apm_->kNoError) {
handle = NULL;
} else {
assert(handle != NULL);
}
return handle;
return WebRtcVad_Create();
}
int VoiceDetectionImpl::DestroyHandle(void* handle) const {
return WebRtcVad_Free(static_cast<Handle*>(handle));
void VoiceDetectionImpl::DestroyHandle(void* handle) const {
WebRtcVad_Free(static_cast<Handle*>(handle));
}
int VoiceDetectionImpl::InitializeHandle(void* handle) const {