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:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user