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

Unified Diff: webrtc/common_audio/resampler/sinc_resampler.cc

Issue 2535643002: Replace some asserts with DCHECKs (Closed)
Patch Set: Don't use the enum hack Created 4 years, 1 month 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
« no previous file with comments | « webrtc/common_audio/fir_filter_sse.cc ('k') | webrtc/common_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_audio/resampler/sinc_resampler.cc
diff --git a/webrtc/common_audio/resampler/sinc_resampler.cc b/webrtc/common_audio/resampler/sinc_resampler.cc
index c8bc15a362fc75b2aa20c998e682b2b0c295a628..651bbf6954f0e8b08d5b61618faf7c79d0778907 100644
--- a/webrtc/common_audio/resampler/sinc_resampler.cc
+++ b/webrtc/common_audio/resampler/sinc_resampler.cc
@@ -87,12 +87,12 @@
#include "webrtc/common_audio/resampler/sinc_resampler.h"
-#include <assert.h>
#include <math.h>
#include <string.h>
#include <limits>
+#include "webrtc/base/checks.h"
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
#include "webrtc/typedefs.h"
@@ -118,6 +118,8 @@ double SincScaleFactor(double io_ratio) {
} // namespace
+const size_t SincResampler::kKernelSize;
+
// If we know the minimum architecture at compile time, avoid CPU detection.
#if defined(WEBRTC_ARCH_X86_FAMILY)
#if defined(__SSE2__)
@@ -165,11 +167,11 @@ SincResampler::SincResampler(double io_sample_rate_ratio,
r2_(input_buffer_.get() + kKernelSize / 2) {
#if defined(WEBRTC_CPU_DETECTION)
InitializeCPUSpecificFeatures();
- assert(convolve_proc_);
+ RTC_DCHECK(convolve_proc_);
#endif
- assert(request_frames_ > 0);
+ RTC_DCHECK_GT(request_frames_, 0);
Flush();
- assert(block_size_ > kKernelSize);
+ RTC_DCHECK_GT(block_size_, kKernelSize);
memset(kernel_storage_.get(), 0,
sizeof(*kernel_storage_.get()) * kKernelStorageSize);
@@ -192,11 +194,11 @@ void SincResampler::UpdateRegions(bool second_load) {
block_size_ = r4_ - r2_;
// r1_ at the beginning of the buffer.
- assert(r1_ == input_buffer_.get());
+ RTC_DCHECK_EQ(r1_, input_buffer_.get());
// r1_ left of r2_, r4_ left of r3_ and size correct.
- assert(r2_ - r1_ == r4_ - r3_);
+ RTC_DCHECK_EQ(r2_ - r1_, r4_ - r3_);
// r2_ left of r3.
- assert(r2_ < r3_);
+ RTC_DCHECK_LT(r2_, r3_);
}
void SincResampler::InitializeKernel() {
@@ -283,7 +285,7 @@ void SincResampler::Resample(size_t frames, float* destination) {
for (int i = static_cast<int>(
ceil((block_size_ - virtual_source_idx_) / current_io_ratio));
i > 0; --i) {
- assert(virtual_source_idx_ < block_size_);
+ RTC_DCHECK_LT(virtual_source_idx_, block_size_);
// |virtual_source_idx_| lies in between two kernel offsets so figure out
// what they are.
@@ -301,8 +303,8 @@ void SincResampler::Resample(size_t frames, float* destination) {
// Ensure |k1|, |k2| are 16-byte aligned for SIMD usage. Should always be
// true so long as kKernelSize is a multiple of 16.
- assert(0u == (reinterpret_cast<uintptr_t>(k1) & 0x0F));
- assert(0u == (reinterpret_cast<uintptr_t>(k2) & 0x0F));
+ RTC_DCHECK_EQ(0, reinterpret_cast<uintptr_t>(k1) % 16);
+ RTC_DCHECK_EQ(0, reinterpret_cast<uintptr_t>(k2) % 16);
// Initialize input pointer based on quantized |virtual_source_idx_|.
const float* const input_ptr = r1_ + source_idx;
« no previous file with comments | « webrtc/common_audio/fir_filter_sse.cc ('k') | webrtc/common_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698