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:
kwiberg
2016-09-14 05:23:22 -07:00
committed by Commit bot
parent 3a7f35b1c4
commit 9e2be5f292
27 changed files with 159 additions and 149 deletions

View File

@ -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_)));

View File

@ -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]));
}

View File

@ -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]);