Changed the delay estimator to be built using C++
BUG=webrtc:5724 NOPRESUBMIT=true Review URL: https://codereview.webrtc.org/1878613002 Cr-Commit-Position: refs/heads/master@{#12336}
This commit is contained in:
@ -110,10 +110,10 @@ source_set("audio_processing") {
|
||||
"typing_detection.h",
|
||||
"utility/block_mean_calculator.cc",
|
||||
"utility/block_mean_calculator.h",
|
||||
"utility/delay_estimator.c",
|
||||
"utility/delay_estimator.cc",
|
||||
"utility/delay_estimator.h",
|
||||
"utility/delay_estimator_internal.h",
|
||||
"utility/delay_estimator_wrapper.c",
|
||||
"utility/delay_estimator_wrapper.cc",
|
||||
"utility/delay_estimator_wrapper.h",
|
||||
"vad/common.h",
|
||||
"vad/gmm.cc",
|
||||
|
||||
@ -35,9 +35,7 @@ extern "C" {
|
||||
#include "webrtc/modules/audio_processing/aec/aec_rdft.h"
|
||||
}
|
||||
#include "webrtc/modules/audio_processing/logging/aec_logging.h"
|
||||
extern "C" {
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h"
|
||||
}
|
||||
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
|
||||
@ -19,10 +19,11 @@ extern "C" {
|
||||
#include "webrtc/common_audio/signal_processing/include/real_fft.h"
|
||||
}
|
||||
#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h"
|
||||
extern "C" {
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h"
|
||||
extern "C" {
|
||||
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
|
||||
}
|
||||
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#ifdef AEC_DEBUG
|
||||
|
||||
@ -19,8 +19,8 @@ extern "C" {
|
||||
#include "webrtc/common_audio/signal_processing/include/real_fft.h"
|
||||
}
|
||||
#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h"
|
||||
extern "C" {
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h"
|
||||
extern "C" {
|
||||
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
|
||||
}
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -13,9 +13,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h"
|
||||
extern "C" {
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h"
|
||||
}
|
||||
|
||||
static const ALIGN8_BEG int16_t WebRtcAecm_kSqrtHanning[] ALIGN8_END = {
|
||||
0, 399, 798, 1196, 1594, 1990, 2386, 2780, 3172,
|
||||
|
||||
@ -120,10 +120,10 @@
|
||||
'typing_detection.h',
|
||||
'utility/block_mean_calculator.cc',
|
||||
'utility/block_mean_calculator.h',
|
||||
'utility/delay_estimator.c',
|
||||
'utility/delay_estimator.cc',
|
||||
'utility/delay_estimator.h',
|
||||
'utility/delay_estimator_internal.h',
|
||||
'utility/delay_estimator_wrapper.c',
|
||||
'utility/delay_estimator_wrapper.cc',
|
||||
'utility/delay_estimator_wrapper.h',
|
||||
'vad/common.h',
|
||||
'vad/gmm.cc',
|
||||
|
||||
@ -276,7 +276,8 @@ BinaryDelayEstimatorFarend* WebRtc_CreateBinaryDelayEstimatorFarend(
|
||||
|
||||
if (history_size > 1) {
|
||||
// Sanity conditions fulfilled.
|
||||
self = malloc(sizeof(BinaryDelayEstimatorFarend));
|
||||
self = static_cast<BinaryDelayEstimatorFarend*>(
|
||||
malloc(sizeof(BinaryDelayEstimatorFarend)));
|
||||
}
|
||||
if (self == NULL) {
|
||||
return NULL;
|
||||
@ -296,11 +297,12 @@ int WebRtc_AllocateFarendBufferMemory(BinaryDelayEstimatorFarend* self,
|
||||
int history_size) {
|
||||
assert(self != NULL);
|
||||
// (Re-)Allocate memory for history buffers.
|
||||
self->binary_far_history =
|
||||
self->binary_far_history = static_cast<uint32_t*>(
|
||||
realloc(self->binary_far_history,
|
||||
history_size * sizeof(*self->binary_far_history));
|
||||
self->far_bit_counts = realloc(self->far_bit_counts,
|
||||
history_size * sizeof(*self->far_bit_counts));
|
||||
history_size * sizeof(*self->binary_far_history)));
|
||||
self->far_bit_counts = static_cast<int*>(
|
||||
realloc(self->far_bit_counts,
|
||||
history_size * sizeof(*self->far_bit_counts)));
|
||||
if ((self->binary_far_history == NULL) || (self->far_bit_counts == NULL)) {
|
||||
history_size = 0;
|
||||
}
|
||||
@ -404,7 +406,8 @@ BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator(
|
||||
|
||||
if ((farend != NULL) && (max_lookahead >= 0)) {
|
||||
// Sanity conditions fulfilled.
|
||||
self = malloc(sizeof(BinaryDelayEstimator));
|
||||
self = static_cast<BinaryDelayEstimator*>(
|
||||
malloc(sizeof(BinaryDelayEstimator)));
|
||||
}
|
||||
if (self == NULL) {
|
||||
return NULL;
|
||||
@ -422,8 +425,8 @@ BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator(
|
||||
self->mean_bit_counts = NULL;
|
||||
self->bit_counts = NULL;
|
||||
self->histogram = NULL;
|
||||
self->binary_near_history =
|
||||
malloc((max_lookahead + 1) * sizeof(*self->binary_near_history));
|
||||
self->binary_near_history = static_cast<uint32_t*>(
|
||||
malloc((max_lookahead + 1) * sizeof(*self->binary_near_history)));
|
||||
if (self->binary_near_history == NULL ||
|
||||
WebRtc_AllocateHistoryBufferMemory(self, farend->history_size) == 0) {
|
||||
WebRtc_FreeBinaryDelayEstimator(self);
|
||||
@ -444,13 +447,13 @@ int WebRtc_AllocateHistoryBufferMemory(BinaryDelayEstimator* self,
|
||||
// The extra array element in |mean_bit_counts| and |histogram| is a dummy
|
||||
// element only used while |last_delay| == -2, i.e., before we have a valid
|
||||
// estimate.
|
||||
self->mean_bit_counts =
|
||||
self->mean_bit_counts = static_cast<int32_t*>(
|
||||
realloc(self->mean_bit_counts,
|
||||
(history_size + 1) * sizeof(*self->mean_bit_counts));
|
||||
self->bit_counts =
|
||||
realloc(self->bit_counts, history_size * sizeof(*self->bit_counts));
|
||||
self->histogram =
|
||||
realloc(self->histogram, (history_size + 1) * sizeof(*self->histogram));
|
||||
(history_size + 1) * sizeof(*self->mean_bit_counts)));
|
||||
self->bit_counts = static_cast<int32_t*>(
|
||||
realloc(self->bit_counts, history_size * sizeof(*self->bit_counts)));
|
||||
self->histogram = static_cast<float*>(
|
||||
realloc(self->histogram, (history_size + 1) * sizeof(*self->histogram)));
|
||||
|
||||
if ((self->mean_bit_counts == NULL) ||
|
||||
(self->bit_counts == NULL) ||
|
||||
@ -10,11 +10,9 @@
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
extern "C" {
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator.h"
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_internal.h"
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h"
|
||||
}
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator.h"
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_internal.h"
|
||||
#include "webrtc/system_wrappers/include/compile_assert_c.h"
|
||||
|
||||
// Only bit |kBandFirst| through bit |kBandLast| are processed and
|
||||
// |kBandFirst| - |kBandLast| must be < 32.
|
||||
@ -144,10 +143,11 @@ void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size) {
|
||||
|
||||
// Check if the sub band used in the delay estimation is small enough to fit
|
||||
// the binary spectra in a uint32_t.
|
||||
COMPILE_ASSERT(kBandLast - kBandFirst < 32);
|
||||
static_assert(kBandLast - kBandFirst < 32, "");
|
||||
|
||||
if (spectrum_size >= kBandLast) {
|
||||
self = malloc(sizeof(DelayEstimatorFarend));
|
||||
self = static_cast<DelayEstimatorFarend*>(
|
||||
malloc(sizeof(DelayEstimatorFarend)));
|
||||
}
|
||||
|
||||
if (self != NULL) {
|
||||
@ -158,7 +158,8 @@ void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size) {
|
||||
memory_fail |= (self->binary_farend == NULL);
|
||||
|
||||
// Allocate memory for spectrum buffers.
|
||||
self->mean_far_spectrum = malloc(spectrum_size * sizeof(SpectrumType));
|
||||
self->mean_far_spectrum =
|
||||
static_cast<SpectrumType*>(malloc(spectrum_size * sizeof(SpectrumType)));
|
||||
memory_fail |= (self->mean_far_spectrum == NULL);
|
||||
|
||||
self->spectrum_size = spectrum_size;
|
||||
@ -275,7 +276,7 @@ void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead) {
|
||||
DelayEstimatorFarend* farend = (DelayEstimatorFarend*) farend_handle;
|
||||
|
||||
if (farend_handle != NULL) {
|
||||
self = malloc(sizeof(DelayEstimator));
|
||||
self = static_cast<DelayEstimator*>(malloc(sizeof(DelayEstimator)));
|
||||
}
|
||||
|
||||
if (self != NULL) {
|
||||
@ -287,8 +288,8 @@ void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead) {
|
||||
memory_fail |= (self->binary_handle == NULL);
|
||||
|
||||
// Allocate memory for spectrum buffers.
|
||||
self->mean_near_spectrum = malloc(farend->spectrum_size *
|
||||
sizeof(SpectrumType));
|
||||
self->mean_near_spectrum = static_cast<SpectrumType*>(
|
||||
malloc(farend->spectrum_size * sizeof(SpectrumType)));
|
||||
memory_fail |= (self->mean_near_spectrum == NULL);
|
||||
|
||||
self->spectrum_size = farend->spectrum_size;
|
||||
@ -328,7 +329,7 @@ int WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift) {
|
||||
}
|
||||
|
||||
int WebRtc_set_history_size(void* handle, int history_size) {
|
||||
DelayEstimator* self = handle;
|
||||
DelayEstimator* self = static_cast<DelayEstimator*>(handle);
|
||||
|
||||
if ((self == NULL) || (history_size <= 1)) {
|
||||
return -1;
|
||||
@ -337,7 +338,7 @@ int WebRtc_set_history_size(void* handle, int history_size) {
|
||||
}
|
||||
|
||||
int WebRtc_history_size(const void* handle) {
|
||||
const DelayEstimator* self = handle;
|
||||
const DelayEstimator* self = static_cast<const DelayEstimator*>(handle);
|
||||
|
||||
if (self == NULL) {
|
||||
return -1;
|
||||
Reference in New Issue
Block a user