webrtc/modules/audio_processing: Use RTC_DCHECK() instead of assert()
Review-Url: https://codereview.webrtc.org/2320053003 Cr-Commit-Position: refs/heads/master@{#14211}
This commit is contained in:
@ -15,7 +15,6 @@
|
||||
#include "webrtc/modules/audio_processing/aec/aec_core.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stddef.h> // size_t
|
||||
#include <stdlib.h>
|
||||
@ -870,7 +869,7 @@ static void Fft(float time_data[PART_LEN2], float freq_data[2][PART_LEN1]) {
|
||||
static int SignalBasedDelayCorrection(AecCore* self) {
|
||||
int delay_correction = 0;
|
||||
int last_delay = -2;
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
#if !defined(WEBRTC_ANDROID)
|
||||
// On desktops, turn on correction after |kDelayCorrectionStart| frames. This
|
||||
// is to let the delay estimation get a chance to converge. Also, if the
|
||||
@ -1846,7 +1845,7 @@ void WebRtcAec_ProcessFrames(AecCore* aec,
|
||||
// Note that the two algorithms operate independently. Currently, we only
|
||||
// allow one algorithm to be turned on.
|
||||
|
||||
assert(aec->num_bands == num_bands);
|
||||
RTC_DCHECK_EQ(aec->num_bands, num_bands);
|
||||
|
||||
for (size_t j = 0; j < num_samples; j += FRAME_LEN) {
|
||||
// 1) At most we process |aec->mult|+1 partitions in 10 ms. Make sure we
|
||||
@ -1949,9 +1948,9 @@ int WebRtcAec_GetDelayMetricsCore(AecCore* self,
|
||||
int* median,
|
||||
int* std,
|
||||
float* fraction_poor_delays) {
|
||||
assert(self != NULL);
|
||||
assert(median != NULL);
|
||||
assert(std != NULL);
|
||||
RTC_DCHECK(self);
|
||||
RTC_DCHECK(median);
|
||||
RTC_DCHECK(std);
|
||||
|
||||
if (self->delay_logging_enabled == 0) {
|
||||
// Logging disabled.
|
||||
@ -1978,9 +1977,9 @@ void WebRtcAec_GetEchoStats(AecCore* self,
|
||||
Stats* erle,
|
||||
Stats* a_nlp,
|
||||
float* divergent_filter_fraction) {
|
||||
assert(erl != NULL);
|
||||
assert(erle != NULL);
|
||||
assert(a_nlp != NULL);
|
||||
RTC_DCHECK(erl);
|
||||
RTC_DCHECK(erle);
|
||||
RTC_DCHECK(a_nlp);
|
||||
*erl = self->erl;
|
||||
*erle = self->erle;
|
||||
*a_nlp = self->aNlp;
|
||||
@ -1992,7 +1991,8 @@ void WebRtcAec_SetConfigCore(AecCore* self,
|
||||
int nlp_mode,
|
||||
int metrics_mode,
|
||||
int delay_logging) {
|
||||
assert(nlp_mode >= 0 && nlp_mode < 3);
|
||||
RTC_DCHECK_GE(nlp_mode, 0);
|
||||
RTC_DCHECK_LT(nlp_mode, 3);
|
||||
self->nlp_mode = nlp_mode;
|
||||
self->metricsMode = metrics_mode;
|
||||
if (self->metricsMode) {
|
||||
@ -2019,7 +2019,7 @@ void WebRtcAec_enable_aec3(AecCore* self, int enable) {
|
||||
}
|
||||
|
||||
int WebRtcAec_aec3_enabled(AecCore* self) {
|
||||
assert(self->aec3_enabled == 0 || self->aec3_enabled == 1);
|
||||
RTC_DCHECK(self->aec3_enabled == 0 || self->aec3_enabled == 1);
|
||||
return self->aec3_enabled;
|
||||
}
|
||||
|
||||
@ -2051,7 +2051,7 @@ int WebRtcAec_system_delay(AecCore* self) {
|
||||
}
|
||||
|
||||
void WebRtcAec_SetSystemDelay(AecCore* self, int delay) {
|
||||
assert(delay >= 0);
|
||||
RTC_DCHECK_GE(delay, 0);
|
||||
self->system_delay = delay;
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
@ -14,11 +14,11 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/aec/aec_resampler.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/aec/aec_core.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -74,11 +74,11 @@ void WebRtcAec_ResampleLinear(void* resampInst,
|
||||
float be, tnew;
|
||||
size_t tn, mm;
|
||||
|
||||
assert(size <= 2 * FRAME_LEN);
|
||||
assert(resampInst != NULL);
|
||||
assert(inspeech != NULL);
|
||||
assert(outspeech != NULL);
|
||||
assert(size_out != NULL);
|
||||
RTC_DCHECK_LE(size, 2u * FRAME_LEN);
|
||||
RTC_DCHECK(resampInst);
|
||||
RTC_DCHECK(inspeech);
|
||||
RTC_DCHECK(outspeech);
|
||||
RTC_DCHECK(size_out);
|
||||
|
||||
// Add new frame data in lookahead
|
||||
memcpy(&obj->buffer[FRAME_LEN + kResamplingDelay], inspeech,
|
||||
@ -163,7 +163,7 @@ int EstimateSkew(const int* rawSkew,
|
||||
if (n == 0) {
|
||||
return -1;
|
||||
}
|
||||
assert(n > 0);
|
||||
RTC_DCHECK_GT(n, 0);
|
||||
rawAvg /= n;
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
@ -172,7 +172,7 @@ int EstimateSkew(const int* rawSkew,
|
||||
rawAbsDev += err >= 0 ? err : -err;
|
||||
}
|
||||
}
|
||||
assert(n > 0);
|
||||
RTC_DCHECK_GT(n, 0);
|
||||
rawAbsDev /= n;
|
||||
upperLimit = static_cast<int>(rawAvg + 5 * rawAbsDev + 1); // +1 for ceiling.
|
||||
lowerLimit = static_cast<int>(rawAvg - 5 * rawAbsDev - 1); // -1 for floor.
|
||||
@ -193,7 +193,7 @@ int EstimateSkew(const int* rawSkew,
|
||||
if (n == 0) {
|
||||
return -1;
|
||||
}
|
||||
assert(n > 0);
|
||||
RTC_DCHECK_GT(n, 0);
|
||||
xAvg = x / n;
|
||||
denom = x2 - xAvg * x;
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/aecm/aecm_core.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -24,6 +23,7 @@ extern "C" {
|
||||
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
|
||||
}
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
#ifdef AEC_DEBUG
|
||||
@ -193,7 +193,7 @@ const uint16_t* WebRtcAecm_AlignedFarend(AecmCore* self,
|
||||
int* far_q,
|
||||
int delay) {
|
||||
int buffer_position = 0;
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
buffer_position = self->far_history_pos - delay;
|
||||
|
||||
// Check buffer position
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/aecm/aecm_core.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -23,6 +22,8 @@ extern "C" {
|
||||
extern "C" {
|
||||
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
|
||||
}
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
// Square root of Hanning window in Q14.
|
||||
@ -483,7 +484,7 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm,
|
||||
}
|
||||
|
||||
zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]);
|
||||
assert(zeros16 >= 0); // |zeros16| is a norm, hence non-negative.
|
||||
RTC_DCHECK_GE(zeros16, 0); // |zeros16| is a norm, hence non-negative.
|
||||
dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld;
|
||||
if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) {
|
||||
tmp16no1 = aecm->nearFilt[i] << zeros16;
|
||||
@ -562,7 +563,7 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm,
|
||||
{
|
||||
avgHnl32 += (int32_t)hnl[i];
|
||||
}
|
||||
assert(kMaxPrefBand - kMinPrefBand + 1 > 0);
|
||||
RTC_DCHECK_GT(kMaxPrefBand - kMinPrefBand + 1, 0);
|
||||
avgHnl32 /= (kMaxPrefBand - kMinPrefBand + 1);
|
||||
|
||||
for (i = kMaxPrefBand; i < PART_LEN1; i++)
|
||||
@ -652,8 +653,8 @@ static void ComfortNoise(AecmCore* aecm,
|
||||
int16_t shiftFromNearToNoise = kNoiseEstQDomain - aecm->dfaCleanQDomain;
|
||||
int16_t minTrackShift;
|
||||
|
||||
assert(shiftFromNearToNoise >= 0);
|
||||
assert(shiftFromNearToNoise < 16);
|
||||
RTC_DCHECK_GE(shiftFromNearToNoise, 0);
|
||||
RTC_DCHECK_LT(shiftFromNearToNoise, 16);
|
||||
|
||||
if (aecm->noiseEstCtr < 100)
|
||||
{
|
||||
|
@ -10,8 +10,7 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/aecm/aecm_core.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h"
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h"
|
||||
|
||||
@ -995,7 +994,7 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm,
|
||||
}
|
||||
|
||||
zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]);
|
||||
assert(zeros16 >= 0); // |zeros16| is a norm, hence non-negative.
|
||||
RTC_DCHECK_GE(zeros16, 0); // |zeros16| is a norm, hence non-negative.
|
||||
dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld;
|
||||
if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) {
|
||||
tmp16no1 = aecm->nearFilt[i] << zeros16;
|
||||
@ -1119,7 +1118,7 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm,
|
||||
avgHnl32 += (int32_t)hnl[i];
|
||||
}
|
||||
|
||||
assert(kMaxPrefBand - kMinPrefBand + 1 > 0);
|
||||
RTC_DCHECK_GT(kMaxPrefBand - kMinPrefBand + 1, 0);
|
||||
avgHnl32 /= (kMaxPrefBand - kMinPrefBand + 1);
|
||||
|
||||
for (i = kMaxPrefBand; i < PART_LEN1; i++) {
|
||||
@ -1271,8 +1270,8 @@ static void ComfortNoise(AecmCore* aecm,
|
||||
int16_t shiftFromNearToNoise = kNoiseEstQDomain - aecm->dfaCleanQDomain;
|
||||
int16_t minTrackShift = 9;
|
||||
|
||||
assert(shiftFromNearToNoise >= 0);
|
||||
assert(shiftFromNearToNoise < 16);
|
||||
RTC_DCHECK_GE(shiftFromNearToNoise, 0);
|
||||
RTC_DCHECK_LT(shiftFromNearToNoise, 16);
|
||||
|
||||
if (aecm->noiseEstCtr < 100) {
|
||||
// Track the minimum more quickly initially.
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "webrtc/modules/audio_processing/aecm/aecm_core.h"
|
||||
|
||||
#include <arm_neon.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/real_fft.h"
|
||||
|
||||
// TODO(kma): Re-write the corresponding assembly file, the offset
|
||||
@ -104,9 +104,9 @@ void WebRtcAecm_CalcLinearEnergiesNeon(AecmCore* aecm,
|
||||
void WebRtcAecm_StoreAdaptiveChannelNeon(AecmCore* aecm,
|
||||
const uint16_t* far_spectrum,
|
||||
int32_t* echo_est) {
|
||||
assert((uintptr_t)echo_est % 32 == 0);
|
||||
assert((uintptr_t)(aecm->channelStored) % 16 == 0);
|
||||
assert((uintptr_t)(aecm->channelAdapt16) % 16 == 0);
|
||||
RTC_DCHECK_EQ(0u, (uintptr_t)echo_est % 32);
|
||||
RTC_DCHECK_EQ(0u, (uintptr_t)aecm->channelStored % 16);
|
||||
RTC_DCHECK_EQ(0u, (uintptr_t)aecm->channelAdapt16 % 16);
|
||||
|
||||
// This is C code of following optimized code.
|
||||
// During startup we store the channel every block.
|
||||
@ -161,9 +161,9 @@ void WebRtcAecm_StoreAdaptiveChannelNeon(AecmCore* aecm,
|
||||
}
|
||||
|
||||
void WebRtcAecm_ResetAdaptiveChannelNeon(AecmCore* aecm) {
|
||||
assert((uintptr_t)(aecm->channelStored) % 16 == 0);
|
||||
assert((uintptr_t)(aecm->channelAdapt16) % 16 == 0);
|
||||
assert((uintptr_t)(aecm->channelAdapt32) % 32 == 0);
|
||||
RTC_DCHECK_EQ(0u, (uintptr_t)aecm->channelStored % 16);
|
||||
RTC_DCHECK_EQ(0u, (uintptr_t)aecm->channelAdapt16 % 16);
|
||||
RTC_DCHECK_EQ(0u, (uintptr_t)aecm->channelAdapt32 % 32);
|
||||
|
||||
// The C code of following optimized code.
|
||||
// for (i = 0; i < PART_LEN1; i++) {
|
||||
|
@ -39,7 +39,7 @@ Agc::Agc()
|
||||
Agc::~Agc() {}
|
||||
|
||||
float Agc::AnalyzePreproc(const int16_t* audio, size_t length) {
|
||||
assert(length > 0);
|
||||
RTC_DCHECK_GT(length, 0u);
|
||||
size_t num_clipped = 0;
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
if (audio[i] == 32767 || audio[i] == -32768)
|
||||
@ -62,7 +62,7 @@ int Agc::Process(const int16_t* audio, size_t length, int sample_rate_hz) {
|
||||
|
||||
bool Agc::GetRmsErrorDb(int* error) {
|
||||
if (!error) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -10,13 +10,13 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/agc/agc_manager_direct.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef WEBRTC_AGC_DEBUG_DUMP
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/agc/gain_map_internal.h"
|
||||
#include "webrtc/modules/audio_processing/gain_control_impl.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
@ -61,7 +61,8 @@ int ClampLevel(int mic_level) {
|
||||
}
|
||||
|
||||
int LevelFromGainError(int gain_error, int level) {
|
||||
assert(level >= 0 && level <= kMaxMicLevel);
|
||||
RTC_DCHECK_GE(level, 0);
|
||||
RTC_DCHECK_LE(level, kMaxMicLevel);
|
||||
if (gain_error == 0) {
|
||||
return level;
|
||||
}
|
||||
@ -90,7 +91,7 @@ class DebugFile {
|
||||
public:
|
||||
explicit DebugFile(const char* filename)
|
||||
: file_(fopen(filename, "wb")) {
|
||||
assert(file_);
|
||||
RTC_DCHECK(file_);
|
||||
}
|
||||
~DebugFile() {
|
||||
fclose(file_);
|
||||
@ -245,7 +246,7 @@ void AgcManagerDirect::Process(const int16_t* audio,
|
||||
|
||||
if (agc_->Process(audio, length, sample_rate_hz) != 0) {
|
||||
LOG(LS_ERROR) << "Agc::Process failed";
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
|
||||
UpdateGain();
|
||||
@ -297,7 +298,7 @@ void AgcManagerDirect::SetLevel(int new_level) {
|
||||
}
|
||||
|
||||
void AgcManagerDirect::SetMaxLevel(int level) {
|
||||
assert(level >= kClippedLevelMin);
|
||||
RTC_DCHECK_GE(level, kClippedLevelMin);
|
||||
max_level_ = level;
|
||||
// Scale the |kSurplusCompressionGain| linearly across the restricted
|
||||
// level range.
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -101,7 +102,7 @@ void LoudnessHistogram::Update(double rms, double activity_probaility) {
|
||||
|
||||
// Doing nothing if buffer is not full, yet.
|
||||
void LoudnessHistogram::RemoveOldestEntryAndUpdate() {
|
||||
assert(len_circular_buffer_ > 0);
|
||||
RTC_DCHECK_GT(len_circular_buffer_, 0);
|
||||
// Do nothing if circular buffer is not full.
|
||||
if (!buffer_is_full_)
|
||||
return;
|
||||
@ -114,7 +115,7 @@ void LoudnessHistogram::RemoveOldestEntryAndUpdate() {
|
||||
void LoudnessHistogram::RemoveTransient() {
|
||||
// Don't expect to be here if high-activity region is longer than
|
||||
// |kTransientWidthThreshold| or there has not been any transient.
|
||||
assert(len_high_activity_ <= kTransientWidthThreshold);
|
||||
RTC_DCHECK_LE(len_high_activity_, kTransientWidthThreshold);
|
||||
int index =
|
||||
(buffer_index_ > 0) ? (buffer_index_ - 1) : len_circular_buffer_ - 1;
|
||||
while (len_high_activity_ > 0) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/audio_buffer.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
|
||||
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
|
||||
@ -25,7 +26,7 @@ const size_t kSamplesPer48kHzChannel = 480;
|
||||
|
||||
int KeyboardChannelIndex(const StreamConfig& stream_config) {
|
||||
if (!stream_config.has_keyboard()) {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -61,11 +62,12 @@ AudioBuffer::AudioBuffer(size_t input_num_frames,
|
||||
activity_(AudioFrame::kVadUnknown),
|
||||
keyboard_data_(NULL),
|
||||
data_(new IFChannelBuffer(proc_num_frames_, num_proc_channels_)) {
|
||||
assert(input_num_frames_ > 0);
|
||||
assert(proc_num_frames_ > 0);
|
||||
assert(output_num_frames_ > 0);
|
||||
assert(num_input_channels_ > 0);
|
||||
assert(num_proc_channels_ > 0 && num_proc_channels_ <= num_input_channels_);
|
||||
RTC_DCHECK_GT(input_num_frames_, 0u);
|
||||
RTC_DCHECK_GT(proc_num_frames_, 0u);
|
||||
RTC_DCHECK_GT(output_num_frames_, 0u);
|
||||
RTC_DCHECK_GT(num_input_channels_, 0u);
|
||||
RTC_DCHECK_GT(num_proc_channels_, 0u);
|
||||
RTC_DCHECK_LE(num_proc_channels_, num_input_channels_);
|
||||
|
||||
if (input_num_frames_ != proc_num_frames_ ||
|
||||
output_num_frames_ != proc_num_frames_) {
|
||||
@ -102,8 +104,8 @@ AudioBuffer::~AudioBuffer() {}
|
||||
|
||||
void AudioBuffer::CopyFrom(const float* const* data,
|
||||
const StreamConfig& stream_config) {
|
||||
assert(stream_config.num_frames() == input_num_frames_);
|
||||
assert(stream_config.num_channels() == num_input_channels_);
|
||||
RTC_DCHECK_EQ(stream_config.num_frames(), input_num_frames_);
|
||||
RTC_DCHECK_EQ(stream_config.num_channels(), num_input_channels_);
|
||||
InitForNewData();
|
||||
// Initialized lazily because there's a different condition in
|
||||
// DeinterleaveFrom.
|
||||
@ -147,8 +149,9 @@ void AudioBuffer::CopyFrom(const float* const* data,
|
||||
|
||||
void AudioBuffer::CopyTo(const StreamConfig& stream_config,
|
||||
float* const* data) {
|
||||
assert(stream_config.num_frames() == output_num_frames_);
|
||||
assert(stream_config.num_channels() == num_channels_ || num_channels_ == 1);
|
||||
RTC_DCHECK_EQ(stream_config.num_frames(), output_num_frames_);
|
||||
RTC_DCHECK(stream_config.num_channels() == num_channels_ ||
|
||||
num_channels_ == 1);
|
||||
|
||||
// Convert to the float range.
|
||||
float* const* data_ptr = data;
|
||||
@ -374,8 +377,8 @@ size_t AudioBuffer::num_bands() const {
|
||||
|
||||
// The resampler is only for supporting 48kHz to 16kHz in the reverse stream.
|
||||
void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) {
|
||||
assert(frame->num_channels_ == num_input_channels_);
|
||||
assert(frame->samples_per_channel_ == input_num_frames_);
|
||||
RTC_DCHECK_EQ(frame->num_channels_, num_input_channels_);
|
||||
RTC_DCHECK_EQ(frame->samples_per_channel_, input_num_frames_);
|
||||
InitForNewData();
|
||||
// Initialized lazily because there's a different condition in CopyFrom.
|
||||
if ((input_num_frames_ != proc_num_frames_) && !input_buffer_) {
|
||||
@ -395,7 +398,7 @@ void AudioBuffer::DeinterleaveFrom(AudioFrame* frame) {
|
||||
DownmixInterleavedToMono(frame->data_, input_num_frames_,
|
||||
num_input_channels_, deinterleaved[0]);
|
||||
} else {
|
||||
assert(num_proc_channels_ == num_input_channels_);
|
||||
RTC_DCHECK_EQ(num_proc_channels_, num_input_channels_);
|
||||
Deinterleave(frame->data_,
|
||||
input_num_frames_,
|
||||
num_proc_channels_,
|
||||
@ -419,8 +422,8 @@ void AudioBuffer::InterleaveTo(AudioFrame* frame, bool data_changed) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(frame->num_channels_ == num_channels_ || num_channels_ == 1);
|
||||
assert(frame->samples_per_channel_ == output_num_frames_);
|
||||
RTC_DCHECK(frame->num_channels_ == num_channels_ || num_channels_ == 1);
|
||||
RTC_DCHECK_EQ(frame->samples_per_channel_, output_num_frames_);
|
||||
|
||||
// Resample if necessary.
|
||||
IFChannelBuffer* data_ptr = data_.get();
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/audio_processing_impl.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
@ -84,7 +83,7 @@ static bool LayoutHasKeyboard(AudioProcessing::ChannelLayout layout) {
|
||||
return true;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -693,8 +692,8 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
|
||||
MaybeInitializeCapture(processing_config, reinitialization_required));
|
||||
}
|
||||
rtc::CritScope cs_capture(&crit_capture_);
|
||||
assert(processing_config.input_stream().num_frames() ==
|
||||
formats_.api_format.input_stream().num_frames());
|
||||
RTC_DCHECK_EQ(processing_config.input_stream().num_frames(),
|
||||
formats_.api_format.input_stream().num_frames());
|
||||
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
if (debug_dump_.debug_file->is_open()) {
|
||||
@ -1010,8 +1009,8 @@ int AudioProcessingImpl::AnalyzeReverseStreamLocked(
|
||||
processing_config.reverse_output_stream() = reverse_output_config;
|
||||
|
||||
RETURN_ON_ERR(MaybeInitializeRender(processing_config));
|
||||
assert(reverse_input_config.num_frames() ==
|
||||
formats_.api_format.reverse_input_stream().num_frames());
|
||||
RTC_DCHECK_EQ(reverse_input_config.num_frames(),
|
||||
formats_.api_format.reverse_input_stream().num_frames());
|
||||
|
||||
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
|
||||
if (debug_dump_.debug_file->is_open()) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <queue>
|
||||
|
||||
#include "webrtc/base/arraysize.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_audio/include/audio_util.h"
|
||||
#include "webrtc/common_audio/resampler/include/push_resampler.h"
|
||||
#include "webrtc/common_audio/resampler/push_sinc_resampler.h"
|
||||
@ -92,7 +93,7 @@ size_t TotalChannelsFromLayout(AudioProcessing::ChannelLayout layout) {
|
||||
case AudioProcessing::kStereoAndKeyboard:
|
||||
return 3;
|
||||
}
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -265,7 +266,7 @@ std::string OutputFilePath(std::string name,
|
||||
} else if (num_output_channels == 2) {
|
||||
ss << "stereo";
|
||||
} else {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
ss << output_rate / 1000;
|
||||
if (num_reverse_output_channels == 1) {
|
||||
@ -273,7 +274,7 @@ std::string OutputFilePath(std::string name,
|
||||
} else if (num_reverse_output_channels == 2) {
|
||||
ss << "_rstereo";
|
||||
} else {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
}
|
||||
ss << reverse_output_rate / 1000;
|
||||
ss << "_d" << file_direction << "_pcm";
|
||||
@ -311,7 +312,7 @@ bool ReadChunk(FILE* file, int16_t* int_data, float* float_data,
|
||||
size_t read_count = fread(int_data, sizeof(int16_t), frame_size, file);
|
||||
if (read_count != frame_size) {
|
||||
// Check that the file really ended.
|
||||
assert(feof(file));
|
||||
RTC_DCHECK(feof(file));
|
||||
return false; // This is expected.
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_COMMON_H_
|
||||
#define WEBRTC_MODULES_AUDIO_PROCESSING_COMMON_H_
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -26,7 +25,7 @@ static inline size_t ChannelsFromLayout(AudioProcessing::ChannelLayout layout) {
|
||||
case AudioProcessing::kStereoAndKeyboard:
|
||||
return 2;
|
||||
}
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/echo_cancellation_impl.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/aec/aec_core.h"
|
||||
#include "webrtc/modules/audio_processing/aec/echo_cancellation.h"
|
||||
#include "webrtc/modules/audio_processing/audio_buffer.h"
|
||||
@ -29,7 +29,7 @@ int16_t MapSetting(EchoCancellation::SuppressionLevel level) {
|
||||
case EchoCancellation::kHighSuppression:
|
||||
return kAecNlpAggressive;
|
||||
}
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ int GainControlImpl::set_stream_analog_level(int level) {
|
||||
int GainControlImpl::stream_analog_level() {
|
||||
rtc::CritScope cs(crit_capture_);
|
||||
// TODO(ajm): enable this assertion?
|
||||
//assert(mode_ == kAdaptiveAnalog);
|
||||
//RTC_DCHECK_EQ(kAdaptiveAnalog, mode_);
|
||||
|
||||
return analog_capture_level_;
|
||||
}
|
||||
@ -482,7 +482,7 @@ int GainControlImpl::Configure() {
|
||||
WebRtcAgcConfig config;
|
||||
// TODO(ajm): Flip the sign here (since AGC expects a positive value) if we
|
||||
// change the interface.
|
||||
//assert(target_level_dbfs_ <= 0);
|
||||
//RTC_DCHECK_LE(target_level_dbfs_, 0);
|
||||
//config.targetLevelDbfs = static_cast<int16_t>(-target_level_dbfs_);
|
||||
config.targetLevelDbfs = static_cast<int16_t>(target_level_dbfs_);
|
||||
config.compressionGaindB =
|
||||
|
@ -10,9 +10,10 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/rms_level.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
static const float kMaxSquaredLevel = 32768 * 32768;
|
||||
@ -49,7 +50,7 @@ int RMSLevel::RMS() {
|
||||
float rms = sum_square_ / (sample_count_ * kMaxSquaredLevel);
|
||||
// 20log_10(x^0.5) = 10log_10(x)
|
||||
rms = 10 * log10(rms);
|
||||
assert(rms <= 0);
|
||||
RTC_DCHECK_LE(rms, 0);
|
||||
if (rms < -kMinLevel)
|
||||
rms = -kMinLevel;
|
||||
|
||||
|
@ -10,13 +10,13 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/transient_detector.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/transient/common.h"
|
||||
#include "webrtc/modules/audio_processing/transient/daubechies_8_wavelet_coeffs.h"
|
||||
#include "webrtc/modules/audio_processing/transient/moving_moments.h"
|
||||
@ -36,10 +36,10 @@ TransientDetector::TransientDetector(int sample_rate_hz)
|
||||
chunks_at_startup_left_to_delete_(kChunksAtStartupLeftToDelete),
|
||||
reference_energy_(1.f),
|
||||
using_reference_(false) {
|
||||
assert(sample_rate_hz == ts::kSampleRate8kHz ||
|
||||
sample_rate_hz == ts::kSampleRate16kHz ||
|
||||
sample_rate_hz == ts::kSampleRate32kHz ||
|
||||
sample_rate_hz == ts::kSampleRate48kHz);
|
||||
RTC_DCHECK(sample_rate_hz == ts::kSampleRate8kHz ||
|
||||
sample_rate_hz == ts::kSampleRate16kHz ||
|
||||
sample_rate_hz == ts::kSampleRate32kHz ||
|
||||
sample_rate_hz == ts::kSampleRate48kHz);
|
||||
int samples_per_transient = sample_rate_hz * kTransientLengthMs / 1000;
|
||||
// Adjustment to avoid data loss while downsampling, making
|
||||
// |samples_per_chunk_| and |samples_per_transient| always divisible by
|
||||
@ -72,7 +72,8 @@ float TransientDetector::Detect(const float* data,
|
||||
size_t data_length,
|
||||
const float* reference_data,
|
||||
size_t reference_length) {
|
||||
assert(data && data_length == samples_per_chunk_);
|
||||
RTC_DCHECK(data);
|
||||
RTC_DCHECK_EQ(samples_per_chunk_, data_length);
|
||||
|
||||
// TODO(aluebs): Check if these errors can logically happen and if not assert
|
||||
// on them.
|
||||
@ -160,7 +161,7 @@ float TransientDetector::ReferenceDetectionValue(const float* data,
|
||||
using_reference_ = false;
|
||||
return 1.f;
|
||||
}
|
||||
assert(reference_energy_ != 0);
|
||||
RTC_DCHECK_NE(0, reference_energy_);
|
||||
float result = 1.f / (1.f + exp(kReferenceNonLinearity *
|
||||
(kEnergyRatioThreshold -
|
||||
reference_energy / reference_energy_)));
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_node.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_audio/fir_filter.h"
|
||||
#include "webrtc/modules/audio_processing/transient/dyadic_decimator.h"
|
||||
|
||||
@ -29,7 +29,9 @@ WPDNode::WPDNode(size_t length,
|
||||
filter_(FIRFilter::Create(coefficients,
|
||||
coefficients_length,
|
||||
2 * length + 1)) {
|
||||
assert(length > 0 && coefficients && coefficients_length > 0);
|
||||
RTC_DCHECK_GT(length, 0u);
|
||||
RTC_DCHECK(coefficients);
|
||||
RTC_DCHECK_GT(coefficients_length, 0u);
|
||||
memset(data_.get(), 0.f, (2 * length + 1) * sizeof(data_[0]));
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_tree.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/transient/dyadic_decimator.h"
|
||||
#include "webrtc/modules/audio_processing/transient/wpd_node.h"
|
||||
|
||||
@ -25,10 +25,10 @@ WPDTree::WPDTree(size_t data_length, const float* high_pass_coefficients,
|
||||
: data_length_(data_length),
|
||||
levels_(levels),
|
||||
num_nodes_((1 << (levels + 1)) - 1) {
|
||||
assert(data_length > (static_cast<size_t>(1) << levels) &&
|
||||
high_pass_coefficients &&
|
||||
low_pass_coefficients &&
|
||||
levels > 0);
|
||||
RTC_DCHECK_GT(data_length, (static_cast<size_t>(1) << levels));
|
||||
RTC_DCHECK(high_pass_coefficients);
|
||||
RTC_DCHECK(low_pass_coefficients);
|
||||
RTC_DCHECK_GT(levels, 0);
|
||||
// Size is 1 more, so we can use the array as 1-based. nodes_[0] is never
|
||||
// allocated.
|
||||
nodes_.reset(new std::unique_ptr<WPDNode>[num_nodes_ + 1]);
|
||||
|
@ -10,11 +10,12 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
|
||||
// Number of right shifts for scaling is linearly depending on number of bits in
|
||||
// the far-end binary spectrum.
|
||||
static const int kShiftsAtZero = 13; // Right shifts at zero binary spectrum.
|
||||
@ -99,7 +100,7 @@ static void UpdateRobustValidationStatistics(BinaryDelayEstimator* self,
|
||||
kMaxHitsWhenPossiblyNonCausal : kMaxHitsWhenPossiblyCausal;
|
||||
int i = 0;
|
||||
|
||||
assert(self->history_size == self->farend->history_size);
|
||||
RTC_DCHECK_EQ(self->history_size, self->farend->history_size);
|
||||
// Reset |candidate_hits| if we have a new candidate.
|
||||
if (candidate_delay != self->last_candidate_delay) {
|
||||
self->candidate_hits = 0;
|
||||
@ -296,7 +297,7 @@ BinaryDelayEstimatorFarend* WebRtc_CreateBinaryDelayEstimatorFarend(
|
||||
|
||||
int WebRtc_AllocateFarendBufferMemory(BinaryDelayEstimatorFarend* self,
|
||||
int history_size) {
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
// (Re-)Allocate memory for history buffers.
|
||||
self->binary_far_history = static_cast<uint32_t*>(
|
||||
realloc(self->binary_far_history,
|
||||
@ -323,7 +324,7 @@ int WebRtc_AllocateFarendBufferMemory(BinaryDelayEstimatorFarend* self,
|
||||
}
|
||||
|
||||
void WebRtc_InitBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self) {
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
memset(self->binary_far_history, 0, sizeof(uint32_t) * self->history_size);
|
||||
memset(self->far_bit_counts, 0, sizeof(int) * self->history_size);
|
||||
}
|
||||
@ -336,9 +337,9 @@ void WebRtc_SoftResetBinaryDelayEstimatorFarend(
|
||||
int src_index = 0;
|
||||
int padding_index = 0;
|
||||
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
shift_size = self->history_size - abs_shift;
|
||||
assert(shift_size > 0);
|
||||
RTC_DCHECK_GT(shift_size, 0);
|
||||
if (delay_shift == 0) {
|
||||
return;
|
||||
} else if (delay_shift > 0) {
|
||||
@ -363,7 +364,7 @@ void WebRtc_SoftResetBinaryDelayEstimatorFarend(
|
||||
|
||||
void WebRtc_AddBinaryFarSpectrum(BinaryDelayEstimatorFarend* handle,
|
||||
uint32_t binary_far_spectrum) {
|
||||
assert(handle != NULL);
|
||||
RTC_DCHECK(handle);
|
||||
// Shift binary spectrum history and insert current |binary_far_spectrum|.
|
||||
memmove(&(handle->binary_far_history[1]), &(handle->binary_far_history[0]),
|
||||
(handle->history_size - 1) * sizeof(uint32_t));
|
||||
@ -481,7 +482,7 @@ int WebRtc_AllocateHistoryBufferMemory(BinaryDelayEstimator* self,
|
||||
|
||||
void WebRtc_InitBinaryDelayEstimator(BinaryDelayEstimator* self) {
|
||||
int i = 0;
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
|
||||
memset(self->bit_counts, 0, sizeof(int32_t) * self->history_size);
|
||||
memset(self->binary_near_history,
|
||||
@ -506,7 +507,7 @@ void WebRtc_InitBinaryDelayEstimator(BinaryDelayEstimator* self) {
|
||||
int WebRtc_SoftResetBinaryDelayEstimator(BinaryDelayEstimator* self,
|
||||
int delay_shift) {
|
||||
int lookahead = 0;
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
lookahead = self->lookahead;
|
||||
self->lookahead -= delay_shift;
|
||||
if (self->lookahead < 0) {
|
||||
@ -528,7 +529,7 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
|
||||
int32_t value_worst_candidate = 0;
|
||||
int32_t valley_depth = 0;
|
||||
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
if (self->farend->history_size != self->history_size) {
|
||||
// Non matching history sizes.
|
||||
return -1;
|
||||
@ -664,13 +665,13 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
|
||||
}
|
||||
|
||||
int WebRtc_binary_last_delay(BinaryDelayEstimator* self) {
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
return self->last_delay;
|
||||
}
|
||||
|
||||
float WebRtc_binary_last_delay_quality(BinaryDelayEstimator* self) {
|
||||
float quality = 0;
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
|
||||
if (self->robust_validation_enabled) {
|
||||
// Simply a linear function of the histogram height at delay estimate.
|
||||
|
@ -10,10 +10,10 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_wrapper.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator.h"
|
||||
#include "webrtc/modules/audio_processing/utility/delay_estimator_internal.h"
|
||||
|
||||
@ -42,7 +42,7 @@ static __inline uint32_t SetBit(uint32_t in, int pos) {
|
||||
static void MeanEstimatorFloat(float new_value,
|
||||
float scale,
|
||||
float* mean_value) {
|
||||
assert(scale < 1.0f);
|
||||
RTC_DCHECK_LT(scale, 1.0f);
|
||||
*mean_value += (new_value - *mean_value) * scale;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ static uint32_t BinarySpectrumFix(const uint16_t* spectrum,
|
||||
int i = kBandFirst;
|
||||
uint32_t out = 0;
|
||||
|
||||
assert(q_domain < 16);
|
||||
RTC_DCHECK_LT(q_domain, 16);
|
||||
|
||||
if (!(*threshold_initialized)) {
|
||||
// Set the |threshold_spectrum| to half the input |spectrum| as starting
|
||||
@ -194,7 +194,7 @@ int WebRtc_InitDelayEstimatorFarend(void* handle) {
|
||||
|
||||
void WebRtc_SoftResetDelayEstimatorFarend(void* handle, int delay_shift) {
|
||||
DelayEstimatorFarend* self = (DelayEstimatorFarend*) handle;
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
WebRtc_SoftResetBinaryDelayEstimatorFarend(self->binary_farend, delay_shift);
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ int WebRtc_InitDelayEstimator(void* handle) {
|
||||
|
||||
int WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift) {
|
||||
DelayEstimator* self = (DelayEstimator*) handle;
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
return WebRtc_SoftResetBinaryDelayEstimator(self->binary_handle, delay_shift);
|
||||
}
|
||||
|
||||
@ -353,8 +353,8 @@ int WebRtc_history_size(const void* handle) {
|
||||
|
||||
int WebRtc_set_lookahead(void* handle, int lookahead) {
|
||||
DelayEstimator* self = (DelayEstimator*) handle;
|
||||
assert(self != NULL);
|
||||
assert(self->binary_handle != NULL);
|
||||
RTC_DCHECK(self);
|
||||
RTC_DCHECK(self->binary_handle);
|
||||
if ((lookahead > self->binary_handle->near_history_size - 1) ||
|
||||
(lookahead < 0)) {
|
||||
return -1;
|
||||
@ -365,8 +365,8 @@ int WebRtc_set_lookahead(void* handle, int lookahead) {
|
||||
|
||||
int WebRtc_lookahead(void* handle) {
|
||||
DelayEstimator* self = (DelayEstimator*) handle;
|
||||
assert(self != NULL);
|
||||
assert(self->binary_handle != NULL);
|
||||
RTC_DCHECK(self);
|
||||
RTC_DCHECK(self->binary_handle);
|
||||
return self->binary_handle->lookahead;
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ int WebRtc_enable_robust_validation(void* handle, int enable) {
|
||||
if ((enable < 0) || (enable > 1)) {
|
||||
return -1;
|
||||
}
|
||||
assert(self->binary_handle != NULL);
|
||||
RTC_DCHECK(self->binary_handle);
|
||||
self->binary_handle->robust_validation_enabled = enable;
|
||||
return 0;
|
||||
}
|
||||
@ -481,6 +481,6 @@ int WebRtc_last_delay(void* handle) {
|
||||
|
||||
float WebRtc_last_delay_quality(void* handle) {
|
||||
DelayEstimator* self = (DelayEstimator*) handle;
|
||||
assert(self != NULL);
|
||||
RTC_DCHECK(self);
|
||||
return WebRtc_binary_last_delay_quality(self->binary_handle);
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/vad/pitch_based_vad.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -10,8 +10,7 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/vad/standalone_vad.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/modules/utility/include/audio_frame_operations.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
@ -64,7 +63,7 @@ int StandaloneVad::GetActivity(double* p, size_t length_p) {
|
||||
const size_t num_frames = index_ / kLength10Ms;
|
||||
if (num_frames > length_p)
|
||||
return -1;
|
||||
assert(WebRtcVad_ValidRateAndFrameLength(kSampleRateHz, index_) == 0);
|
||||
RTC_DCHECK_EQ(0, WebRtcVad_ValidRateAndFrameLength(kSampleRateHz, index_));
|
||||
|
||||
int activity = WebRtcVad_Process(vad_, kSampleRateHz, buffer_, index_);
|
||||
if (activity < 0)
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_audio/fft4g.h"
|
||||
#include "webrtc/modules/audio_processing/vad/vad_audio_proc_internal.h"
|
||||
#include "webrtc/modules/audio_processing/vad/pitch_internal.h"
|
||||
@ -95,7 +96,7 @@ int VadAudioProc::ExtractFeatures(const int16_t* frame,
|
||||
if (num_buffer_samples_ < kBufferLength) {
|
||||
return 0;
|
||||
}
|
||||
assert(num_buffer_samples_ == kBufferLength);
|
||||
RTC_DCHECK_EQ(num_buffer_samples_, kBufferLength);
|
||||
features->num_frames = kNum10msSubframes;
|
||||
features->silence = false;
|
||||
|
||||
@ -121,7 +122,7 @@ int VadAudioProc::ExtractFeatures(const int16_t* frame,
|
||||
void VadAudioProc::SubframeCorrelation(double* corr,
|
||||
size_t length_corr,
|
||||
size_t subframe_index) {
|
||||
assert(length_corr >= kLpcOrder + 1);
|
||||
RTC_DCHECK_GE(length_corr, kLpcOrder + 1);
|
||||
double windowed_audio[kNumSubframeSamples + kNumPastSignalSamples];
|
||||
size_t buffer_index = subframe_index * kNumSubframeSamples;
|
||||
|
||||
@ -137,7 +138,7 @@ void VadAudioProc::SubframeCorrelation(double* corr,
|
||||
// each 10ms sub-frame. This is equivalent to computing LPC coefficients for the
|
||||
// first half of each 10 ms subframe.
|
||||
void VadAudioProc::GetLpcPolynomials(double* lpc, size_t length_lpc) {
|
||||
assert(length_lpc >= kNum10msSubframes * (kLpcOrder + 1));
|
||||
RTC_DCHECK_GE(length_lpc, kNum10msSubframes * (kLpcOrder + 1));
|
||||
double corr[kLpcOrder + 1];
|
||||
double reflec_coeff[kLpcOrder];
|
||||
for (size_t i = 0, offset_lpc = 0; i < kNum10msSubframes;
|
||||
@ -165,7 +166,7 @@ static float QuadraticInterpolation(float prev_val,
|
||||
|
||||
fractional_index =
|
||||
-(next_val - prev_val) * 0.5f / (next_val + prev_val - 2.f * curr_val);
|
||||
assert(fabs(fractional_index) < 1);
|
||||
RTC_DCHECK_LT(fabs(fractional_index), 1);
|
||||
return fractional_index;
|
||||
}
|
||||
|
||||
@ -176,7 +177,7 @@ static float QuadraticInterpolation(float prev_val,
|
||||
// to save on one square root.
|
||||
void VadAudioProc::FindFirstSpectralPeaks(double* f_peak,
|
||||
size_t length_f_peak) {
|
||||
assert(length_f_peak >= kNum10msSubframes);
|
||||
RTC_DCHECK_GE(length_f_peak, kNum10msSubframes);
|
||||
double lpc[kNum10msSubframes * (kLpcOrder + 1)];
|
||||
// For all sub-frames.
|
||||
GetLpcPolynomials(lpc, kNum10msSubframes * (kLpcOrder + 1));
|
||||
@ -232,7 +233,7 @@ void VadAudioProc::PitchAnalysis(double* log_pitch_gains,
|
||||
size_t length) {
|
||||
// TODO(turajs): This can be "imported" from iSAC & and the next two
|
||||
// constants.
|
||||
assert(length >= kNum10msSubframes);
|
||||
RTC_DCHECK_GE(length, kNum10msSubframes);
|
||||
const int kNumPitchSubframes = 4;
|
||||
double gains[kNumPitchSubframes];
|
||||
double lags[kNumPitchSubframes];
|
||||
@ -262,7 +263,7 @@ void VadAudioProc::PitchAnalysis(double* log_pitch_gains,
|
||||
}
|
||||
|
||||
void VadAudioProc::Rms(double* rms, size_t length_rms) {
|
||||
assert(length_rms >= kNum10msSubframes);
|
||||
RTC_DCHECK_GE(length_rms, kNum10msSubframes);
|
||||
size_t offset = kNumPastSignalSamples;
|
||||
for (size_t i = 0; i < kNum10msSubframes; i++) {
|
||||
rms[i] = 0;
|
||||
|
@ -50,25 +50,28 @@ class VadAudioProc {
|
||||
// For every 30 ms we compute 3 spectral peak there for 3 LPC analysis.
|
||||
// LPC is computed over 15 ms of windowed audio. For every 10 ms sub-frame
|
||||
// we need 5 ms of past signal to create the input of LPC analysis.
|
||||
static const size_t kNumPastSignalSamples =
|
||||
static_cast<size_t>(kSampleRateHz / 200);
|
||||
enum : size_t {
|
||||
kNumPastSignalSamples = static_cast<size_t>(kSampleRateHz / 200)
|
||||
};
|
||||
|
||||
// TODO(turajs): maybe defining this at a higher level (maybe enum) so that
|
||||
// all the code recognize it as "no-error."
|
||||
static const int kNoError = 0;
|
||||
enum : int { kNoError = 0 };
|
||||
|
||||
static const size_t kNum10msSubframes = 3;
|
||||
static const size_t kNumSubframeSamples =
|
||||
static_cast<size_t>(kSampleRateHz / 100);
|
||||
static const size_t kNumSamplesToProcess =
|
||||
kNum10msSubframes *
|
||||
kNumSubframeSamples; // Samples in 30 ms @ given sampling rate.
|
||||
static const size_t kBufferLength =
|
||||
kNumPastSignalSamples + kNumSamplesToProcess;
|
||||
static const size_t kIpLength = kDftSize >> 1;
|
||||
static const size_t kWLength = kDftSize >> 1;
|
||||
|
||||
static const size_t kLpcOrder = 16;
|
||||
enum : size_t { kNum10msSubframes = 3 };
|
||||
enum : size_t {
|
||||
kNumSubframeSamples = static_cast<size_t>(kSampleRateHz / 100)
|
||||
};
|
||||
enum : size_t {
|
||||
// Samples in 30 ms @ given sampling rate.
|
||||
kNumSamplesToProcess = kNum10msSubframes * kNumSubframeSamples
|
||||
};
|
||||
enum : size_t {
|
||||
kBufferLength = kNumPastSignalSamples + kNumSamplesToProcess
|
||||
};
|
||||
enum : size_t { kIpLength = kDftSize >> 1 };
|
||||
enum : size_t { kWLength = kDftSize >> 1 };
|
||||
enum : size_t { kLpcOrder = 16 };
|
||||
|
||||
size_t ip_[kIpLength];
|
||||
float w_fft_[kWLength];
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "webrtc/modules/audio_processing/vad/vad_circular_buffer.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace webrtc {
|
||||
|
@ -103,7 +103,7 @@ int VoiceDetectionImpl::set_stream_has_voice(bool has_voice) {
|
||||
bool VoiceDetectionImpl::stream_has_voice() const {
|
||||
rtc::CritScope cs(crit_);
|
||||
// TODO(ajm): enable this assertion?
|
||||
//assert(using_external_vad_ || is_component_enabled());
|
||||
//RTC_DCHECK(using_external_vad_ || is_component_enabled());
|
||||
return stream_has_voice_;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user