Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: webrtc/modules/audio_processing/utility/delay_estimator.cc

Issue 2320053003: webrtc/modules/audio_processing: Use RTC_DCHECK() instead of assert() (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/utility/delay_estimator.cc
diff --git a/webrtc/modules/audio_processing/utility/delay_estimator.cc b/webrtc/modules/audio_processing/utility/delay_estimator.cc
index 56bdde890c9348a0e2874950b15177a00ed72d0f..bc67ba1fe23af3f91e341d7280c59545f7f1f03e 100644
--- a/webrtc/modules/audio_processing/utility/delay_estimator.cc
+++ b/webrtc/modules/audio_processing/utility/delay_estimator.cc
@@ -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.

Powered by Google App Engine
This is Rietveld 408576698