Replace calls to assert() with RTC_DCHECK_*() in .c code
We have RTC_CHECK and RTC_DCHECK for C now, so we should use it. It's
one fewer difference between our C and C++ code.
NOPRESUBMIT=true
Review-Url: https://codereview.webrtc.org/2274083002
Cr-Commit-Position: refs/heads/master@{#13930}
diff --git a/webrtc/common_audio/signal_processing/auto_correlation.c b/webrtc/common_audio/signal_processing/auto_correlation.c
index fda4fff..58e6d6e 100644
--- a/webrtc/common_audio/signal_processing/auto_correlation.c
+++ b/webrtc/common_audio/signal_processing/auto_correlation.c
@@ -10,7 +10,7 @@
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
-#include <assert.h>
+#include "webrtc/base/checks.h"
size_t WebRtcSpl_AutoCorrelation(const int16_t* in_vector,
size_t in_vector_length,
@@ -22,7 +22,7 @@
int16_t smax = 0;
int scaling = 0;
- assert(order <= in_vector_length);
+ RTC_DCHECK_LE(order, in_vector_length);
// Find the maximum absolute value of the samples.
smax = WebRtcSpl_MaxAbsValueW16(in_vector, in_vector_length);
diff --git a/webrtc/common_audio/signal_processing/filter_ar_fast_q12.c b/webrtc/common_audio/signal_processing/filter_ar_fast_q12.c
index 70001a0..53e800b 100644
--- a/webrtc/common_audio/signal_processing/filter_ar_fast_q12.c
+++ b/webrtc/common_audio/signal_processing/filter_ar_fast_q12.c
@@ -7,8 +7,8 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <assert.h>
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
// TODO(bjornv): Change the return type to report errors.
@@ -21,8 +21,8 @@
size_t i = 0;
size_t j = 0;
- assert(data_length > 0);
- assert(coefficients_length > 1);
+ RTC_DCHECK_GT(data_length, 0);
+ RTC_DCHECK_GT(coefficients_length, 1);
for (i = 0; i < data_length; i++) {
int32_t output = 0;
diff --git a/webrtc/common_audio/signal_processing/filter_ar_fast_q12_mips.c b/webrtc/common_audio/signal_processing/filter_ar_fast_q12_mips.c
index 0384701..02fa80b 100644
--- a/webrtc/common_audio/signal_processing/filter_ar_fast_q12_mips.c
+++ b/webrtc/common_audio/signal_processing/filter_ar_fast_q12_mips.c
@@ -7,8 +7,8 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <assert.h>
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
void WebRtcSpl_FilterARFastQ12(const int16_t* data_in,
@@ -25,8 +25,8 @@
int min16 = 0xFFFF8000;
#endif // #if !defined(MIPS_DSP_R1_LE)
- assert(data_length > 0);
- assert(coefficients_length > 1);
+ RTC_DCHECK_GT(data_length, 0);
+ RTC_DCHECK_GT(coefficients_length, 1);
__asm __volatile (
".set push \n\t"
diff --git a/webrtc/common_audio/signal_processing/min_max_operations.c b/webrtc/common_audio/signal_processing/min_max_operations.c
index 4a962f8..bc23a9c 100644
--- a/webrtc/common_audio/signal_processing/min_max_operations.c
+++ b/webrtc/common_audio/signal_processing/min_max_operations.c
@@ -24,9 +24,9 @@
*
*/
-#include <assert.h>
#include <stdlib.h>
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
// TODO(bjorn/kma): Consolidate function pairs (e.g. combine
@@ -38,7 +38,7 @@
size_t i = 0;
int absolute = 0, maximum = 0;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
absolute = abs((int)vector[i]);
@@ -64,7 +64,7 @@
uint32_t absolute = 0, maximum = 0;
size_t i = 0;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
absolute = abs((int)vector[i]);
@@ -83,7 +83,7 @@
int16_t maximum = WEBRTC_SPL_WORD16_MIN;
size_t i = 0;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
if (vector[i] > maximum)
@@ -97,7 +97,7 @@
int32_t maximum = WEBRTC_SPL_WORD32_MIN;
size_t i = 0;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
if (vector[i] > maximum)
@@ -111,7 +111,7 @@
int16_t minimum = WEBRTC_SPL_WORD16_MAX;
size_t i = 0;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
if (vector[i] < minimum)
@@ -125,7 +125,7 @@
int32_t minimum = WEBRTC_SPL_WORD32_MAX;
size_t i = 0;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
if (vector[i] < minimum)
@@ -141,7 +141,7 @@
size_t i = 0, index = 0;
int absolute = 0, maximum = 0;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
absolute = abs((int)vector[i]);
@@ -160,7 +160,7 @@
size_t i = 0, index = 0;
int16_t maximum = WEBRTC_SPL_WORD16_MIN;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
if (vector[i] > maximum) {
@@ -177,7 +177,7 @@
size_t i = 0, index = 0;
int32_t maximum = WEBRTC_SPL_WORD32_MIN;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
if (vector[i] > maximum) {
@@ -194,7 +194,7 @@
size_t i = 0, index = 0;
int16_t minimum = WEBRTC_SPL_WORD16_MAX;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
if (vector[i] < minimum) {
@@ -211,7 +211,7 @@
size_t i = 0, index = 0;
int32_t minimum = WEBRTC_SPL_WORD32_MAX;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) {
if (vector[i] < minimum) {
diff --git a/webrtc/common_audio/signal_processing/min_max_operations_mips.c b/webrtc/common_audio/signal_processing/min_max_operations_mips.c
index 28de45b..c769e6a 100644
--- a/webrtc/common_audio/signal_processing/min_max_operations_mips.c
+++ b/webrtc/common_audio/signal_processing/min_max_operations_mips.c
@@ -16,8 +16,7 @@
*
*/
-#include <assert.h>
-
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
// Maximum absolute value of word16 vector.
@@ -26,7 +25,7 @@
int32_t tmp32_0, tmp32_1, tmp32_2, tmp32_3;
size_t i, loop_size;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
#if defined(MIPS_DSP_R1)
const int32_t* tmpvec32 = (int32_t*)vector;
@@ -230,7 +229,7 @@
uint32_t absolute = 0, maximum = 0;
int tmp1 = 0, max_value = 0x7fffffff;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
__asm__ volatile (
".set push \n\t"
@@ -264,7 +263,7 @@
int tmp1;
int16_t value;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
__asm__ volatile (
".set push \n\t"
@@ -292,7 +291,7 @@
int32_t maximum = WEBRTC_SPL_WORD32_MIN;
int tmp1, value;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
__asm__ volatile (
".set push \n\t"
@@ -322,7 +321,7 @@
int tmp1;
int16_t value;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
__asm__ volatile (
".set push \n\t"
@@ -351,7 +350,7 @@
int32_t minimum = WEBRTC_SPL_WORD32_MAX;
int tmp1, value;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
__asm__ volatile (
".set push \n\t"
diff --git a/webrtc/common_audio/signal_processing/min_max_operations_neon.c b/webrtc/common_audio/signal_processing/min_max_operations_neon.c
index 6fbbf94..d5aad76 100644
--- a/webrtc/common_audio/signal_processing/min_max_operations_neon.c
+++ b/webrtc/common_audio/signal_processing/min_max_operations_neon.c
@@ -9,16 +9,16 @@
*/
#include <arm_neon.h>
-#include <assert.h>
#include <stdlib.h>
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
// Maximum absolute value of word16 vector. C version for generic platforms.
int16_t WebRtcSpl_MaxAbsValueW16Neon(const int16_t* vector, size_t length) {
int absolute = 0, maximum = 0;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
const int16_t* p_start = vector;
size_t rest = length & 7;
@@ -76,7 +76,7 @@
size_t i = 0;
size_t residual = length & 0x7;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
const int32_t* p_start = vector;
uint32x4_t max32x4_0 = vdupq_n_u32(0);
@@ -128,7 +128,7 @@
size_t i = 0;
size_t residual = length & 0x7;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
const int16_t* p_start = vector;
int16x8_t max16x8 = vdupq_n_s16(WEBRTC_SPL_WORD16_MIN);
@@ -166,7 +166,7 @@
size_t i = 0;
size_t residual = length & 0x7;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
const int32_t* p_start = vector;
int32x4_t max32x4_0 = vdupq_n_s32(WEBRTC_SPL_WORD32_MIN);
@@ -208,7 +208,7 @@
size_t i = 0;
size_t residual = length & 0x7;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
const int16_t* p_start = vector;
int16x8_t min16x8 = vdupq_n_s16(WEBRTC_SPL_WORD16_MAX);
@@ -246,7 +246,7 @@
size_t i = 0;
size_t residual = length & 0x7;
- assert(length > 0);
+ RTC_DCHECK_GT(length, 0);
const int32_t* p_start = vector;
int32x4_t min32x4_0 = vdupq_n_s32(WEBRTC_SPL_WORD32_MAX);
diff --git a/webrtc/common_audio/signal_processing/spl_sqrt.c b/webrtc/common_audio/signal_processing/spl_sqrt.c
index 579e714..511039b 100644
--- a/webrtc/common_audio/signal_processing/spl_sqrt.c
+++ b/webrtc/common_audio/signal_processing/spl_sqrt.c
@@ -15,10 +15,9 @@
*
*/
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
-#include <assert.h>
-
int32_t WebRtcSpl_SqrtLocal(int32_t in);
int32_t WebRtcSpl_SqrtLocal(int32_t in)
@@ -166,7 +165,7 @@
x_norm = (int16_t)(A >> 16); // x_norm = AH
nshift = (sh / 2);
- assert(nshift >= 0);
+ RTC_DCHECK_GE(nshift, 0);
A = (int32_t)WEBRTC_SPL_LSHIFT_W32((int32_t)x_norm, 16);
A = WEBRTC_SPL_ABS_W32(A); // A = abs(x_norm<<16)
diff --git a/webrtc/common_audio/signal_processing/splitting_filter.c b/webrtc/common_audio/signal_processing/splitting_filter.c
index ba6e77d..1400623 100644
--- a/webrtc/common_audio/signal_processing/splitting_filter.c
+++ b/webrtc/common_audio/signal_processing/splitting_filter.c
@@ -13,10 +13,9 @@
*
*/
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
-#include <assert.h>
-
// Maximum number of samples in a low/high-band frame.
enum
{
@@ -136,8 +135,8 @@
int32_t filter1[kMaxBandFrameLength];
int32_t filter2[kMaxBandFrameLength];
const size_t band_length = in_data_length / 2;
- assert(in_data_length % 2 == 0);
- assert(band_length <= kMaxBandFrameLength);
+ RTC_DCHECK_EQ(0, in_data_length % 2);
+ RTC_DCHECK_LE(band_length, kMaxBandFrameLength);
// Split even and odd samples. Also shift them to Q10.
for (i = 0, k = 0; i < band_length; i++, k += 2)
@@ -175,7 +174,7 @@
int32_t filter2[kMaxBandFrameLength];
size_t i;
int16_t k;
- assert(band_length <= kMaxBandFrameLength);
+ RTC_DCHECK_LE(band_length, kMaxBandFrameLength);
// Obtain the sum and difference channels out of upper and lower-band channels.
// Also shift to Q10 domain.
diff --git a/webrtc/common_audio/vad/vad_filterbank.c b/webrtc/common_audio/vad/vad_filterbank.c
index 8b9df93..5e15696 100644
--- a/webrtc/common_audio/vad/vad_filterbank.c
+++ b/webrtc/common_audio/vad/vad_filterbank.c
@@ -10,8 +10,7 @@
#include "webrtc/common_audio/vad/vad_filterbank.h"
-#include <assert.h>
-
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/typedefs.h"
@@ -160,8 +159,8 @@
// we eventually will mask out the fractional part.
uint32_t energy = 0;
- assert(data_in != NULL);
- assert(data_length > 0);
+ RTC_DCHECK(data_in);
+ RTC_DCHECK_GT(data_length, 0);
energy = (uint32_t) WebRtcSpl_Energy((int16_t*) data_in, data_length,
&tot_rshifts);
@@ -261,8 +260,8 @@
int16_t* hp_out_ptr = hp_120; // [2000 - 4000] Hz.
int16_t* lp_out_ptr = lp_120; // [0 - 2000] Hz.
- assert(data_length <= 240);
- assert(4 < kNumChannels - 1); // Checking maximum |frequency_band|.
+ RTC_DCHECK_LE(data_length, 240);
+ RTC_DCHECK_LT(4, kNumChannels - 1); // Checking maximum |frequency_band|.
// Split at 2000 Hz and downsample.
SplitFilter(in_ptr, data_length, &self->upper_state[frequency_band],
diff --git a/webrtc/common_audio/vad/vad_sp.c b/webrtc/common_audio/vad/vad_sp.c
index a54be17..4a1cebb 100644
--- a/webrtc/common_audio/vad/vad_sp.c
+++ b/webrtc/common_audio/vad/vad_sp.c
@@ -10,8 +10,7 @@
#include "webrtc/common_audio/vad/vad_sp.h"
-#include <assert.h>
-
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/common_audio/vad/vad_core.h"
#include "webrtc/typedefs.h"
@@ -72,7 +71,7 @@
int16_t* age = &self->index_vector[offset];
int16_t* smallest_values = &self->low_value_vector[offset];
- assert(channel < kNumChannels);
+ RTC_DCHECK_LT(channel, kNumChannels);
// Each value in |smallest_values| is getting 1 loop older. Update |age|, and
// remove old values.
diff --git a/webrtc/modules/audio_coding/codecs/isac/empty.cc b/webrtc/modules/audio_coding/codecs/isac/empty.cc
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/webrtc/modules/audio_coding/codecs/isac/empty.cc
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c
index b074962..fa63b46 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c
@@ -20,9 +20,8 @@
#include "bandwidth_estimator.h"
-#include <assert.h>
#include "settings.h"
-
+#include "webrtc/base/checks.h"
/* array of quantization levels for bottle neck info; Matlab code: */
/* sprintf('%4.1ff, ', logspace(log10(5000), log10(40000), 12)) */
@@ -180,7 +179,7 @@
int16_t errCode;
- assert(!bweStr->external_bw_info.in_use);
+ RTC_DCHECK(!bweStr->external_bw_info.in_use);
/* UPDATE ESTIMATES FROM OTHER SIDE */
@@ -551,7 +550,7 @@
{
uint16_t RateInd;
- assert(!bweStr->external_bw_info.in_use);
+ RTC_DCHECK(!bweStr->external_bw_info.in_use);
if ( (Index < 0) || (Index > 23) ) {
return -ISAC_RANGE_ERROR_BW_ESTIMATOR;
@@ -732,7 +731,7 @@
int32_t rec_jitter_short_term_abs_inv; /* Q18 */
int32_t temp;
- assert(!bweStr->external_bw_info.in_use);
+ RTC_DCHECK(!bweStr->external_bw_info.in_use);
/* Q18 rec jitter short term abs is in Q13, multiply it by 2^13 to save precision
2^18 then needs to be shifted 13 bits to 2^31 */
@@ -790,7 +789,7 @@
{
int16_t recMaxDelay = (int16_t)(bweStr->recMaxDelay >> 15);
- assert(!bweStr->external_bw_info.in_use);
+ RTC_DCHECK(!bweStr->external_bw_info.in_use);
/* limit range of jitter estimate */
if (recMaxDelay < MIN_ISAC_MD) {
@@ -804,7 +803,7 @@
/* Clamp val to the closed interval [min,max]. */
static int16_t clamp(int16_t val, int16_t min, int16_t max) {
- assert(min <= max);
+ RTC_DCHECK_LE(min, max);
return val < min ? min : (val > max ? max : val);
}
@@ -822,7 +821,7 @@
void WebRtcIsacfixBw_GetBandwidthInfo(BwEstimatorstr* bweStr,
IsacBandwidthInfo* bwinfo) {
- assert(!bweStr->external_bw_info.in_use);
+ RTC_DCHECK(!bweStr->external_bw_info.in_use);
bwinfo->in_use = 1;
bwinfo->send_bw_avg = WebRtcIsacfix_GetUplinkBandwidth(bweStr);
bwinfo->send_max_delay_avg = WebRtcIsacfix_GetUplinkMaxDelay(bweStr);
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/encode.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/encode.c
index 757c0b8..248511f 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/encode.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/encode.c
@@ -15,9 +15,9 @@
*
*/
+#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
-#include <assert.h>
#include <stdio.h>
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routins.h"
@@ -455,7 +455,7 @@
while (stream_length < MinBytes)
{
- assert(stream_length >= 0);
+ RTC_DCHECK_GE(stream_length, 0);
if (stream_length & 0x0001){
ISACenc_obj->bitstr_seed = WEBRTC_SPL_RAND( ISACenc_obj->bitstr_seed );
ISACenc_obj->bitstr_obj.stream[stream_length / 2] |=
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding_neon.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding_neon.c
index 0f01a03..1e4812a 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding_neon.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding_neon.c
@@ -17,10 +17,10 @@
#include "entropy_coding.h"
#include <arm_neon.h>
-#include <assert.h>
#include <stddef.h>
#include "signal_processing_library.h"
+#include "webrtc/base/checks.h"
void WebRtcIsacfix_MatrixProduct1Neon(const int16_t matrix0[],
const int32_t matrix1[],
@@ -46,8 +46,8 @@
int32x4_t sum_32x4 = vdupq_n_s32(0);
int32x2_t sum_32x2 = vdup_n_s32(0);
- assert(inner_loop_count % 2 == 0);
- assert(mid_loop_count % 2 == 0);
+ RTC_DCHECK_EQ(0, inner_loop_count % 2);
+ RTC_DCHECK_EQ(0, mid_loop_count % 2);
if (matrix1_index_init_case != 0 && matrix1_index_factor1 == 1) {
for (j = 0; j < SUBFRAMES; j++) {
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c
index 2e92578..ce479e2 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c
@@ -20,11 +20,10 @@
#include "filterbank_internal.h"
-#include <assert.h>
-
#include "codec.h"
#include "filterbank_tables.h"
#include "settings.h"
+#include "webrtc/base/checks.h"
// Declare a function pointer.
AllpassFilter2FixDec16 WebRtcIsacfix_AllpassFilter2FixDec16;
@@ -44,7 +43,7 @@
int32_t a = 0, b = 0;
// Assembly file assumption.
- assert(length % 2 == 0);
+ RTC_DCHECK_EQ(0, length % 2);
for (n = 0; n < length; n++) {
// Process channel 1:
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks_neon.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks_neon.c
index 20f80ae..5dd6e8f 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks_neon.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks_neon.c
@@ -14,7 +14,8 @@
// C code is at end of this file.
#include <arm_neon.h>
-#include <assert.h>
+
+#include "webrtc/base/checks.h"
void WebRtcIsacfix_AllpassFilter2FixDec16Neon(
int16_t* data_ch1, // Input and output in channel 1, in Q0
@@ -24,7 +25,7 @@
const int length, // Length of the data buffers
int32_t* filter_state_ch1, // Filter state for channel 1, in Q16
int32_t* filter_state_ch2) { // Filter state for channel 2, in Q16
- assert(length % 2 == 0);
+ RTC_DCHECK_EQ(0, length % 2);
int n = 0;
int16x4_t factorv;
int16x4_t datav;
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/filters.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/filters.c
index 21e4983..2e666d6 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filters.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filters.c
@@ -8,8 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <assert.h>
-
+#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
// Autocorrelation function in fixed point.
@@ -27,8 +26,8 @@
int64_t prod = 0;
// The ARM assembly code assumptoins.
- assert(N % 4 == 0);
- assert(N >= 8);
+ RTC_DCHECK_EQ(0, N % 4);
+ RTC_DCHECK_GE(N, 8);
// Calculate r[0].
for (i = 0; i < N; i++) {
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/filters_neon.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/filters_neon.c
index eff8dae..df4ef6f 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filters_neon.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filters_neon.c
@@ -9,8 +9,8 @@
*/
#include <arm_neon.h>
-#include <assert.h>
+#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
// Autocorrelation function in fixed point.
@@ -26,8 +26,8 @@
int64_t prod = 0;
int64_t prod_tail = 0;
- assert(n % 4 == 0);
- assert(n >= 8);
+ RTC_DCHECK_EQ(0, n % 4);
+ RTC_DCHECK_GE(n, 8);
// Calculate r[0].
int16x4_t x0_v;
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
index e7905ae..39ae8be 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
@@ -17,9 +17,9 @@
#include "webrtc/modules/audio_coding/codecs/isac/fix/include/isacfix.h"
-#include <assert.h>
#include <stdlib.h>
+#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h"
@@ -1113,8 +1113,8 @@
void WebRtcIsacfix_SetInitialBweBottleneck(ISACFIX_MainStruct* ISAC_main_inst,
int bottleneck_bits_per_second) {
ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst;
- assert(bottleneck_bits_per_second >= 10000 &&
- bottleneck_bits_per_second <= 32000);
+ RTC_DCHECK_GE(bottleneck_bits_per_second, 10000);
+ RTC_DCHECK_LE(bottleneck_bits_per_second, 32000);
inst->bwestimator_obj.sendBwAvg = ((uint32_t)bottleneck_bits_per_second) << 7;
}
@@ -1539,13 +1539,13 @@
void WebRtcIsacfix_GetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
IsacBandwidthInfo* bwinfo) {
ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst;
- assert(inst->initflag & 1); // Decoder initialized.
+ RTC_DCHECK_NE(0, inst->initflag & 1); // Decoder initialized.
WebRtcIsacfixBw_GetBandwidthInfo(&inst->bwestimator_obj, bwinfo);
}
void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
const IsacBandwidthInfo* bwinfo) {
ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst;
- assert(inst->initflag & 2); // Encoder initialized.
+ RTC_DCHECK_NE(0, inst->initflag & 2); // Encoder initialized.
WebRtcIsacfixBw_SetBandwidthInfo(&inst->bwestimator_obj, bwinfo);
}
diff --git a/webrtc/modules/audio_coding/codecs/isac/isac_test.gypi b/webrtc/modules/audio_coding/codecs/isac/isac_test.gypi
index 744885d..e313a7e 100644
--- a/webrtc/modules/audio_coding/codecs/isac/isac_test.gypi
+++ b/webrtc/modules/audio_coding/codecs/isac/isac_test.gypi
@@ -23,6 +23,7 @@
'<(webrtc_root)',
],
'sources': [
+ 'empty.cc', # force build system to use C++ linker
'./main/test/simpleKenny.c',
'./main/util/utility.c',
],
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c b/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c
index 51da3f7..f3d9e1b 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c
+++ b/webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.c
@@ -19,8 +19,8 @@
#include "bandwidth_estimator.h"
#include "settings.h"
#include "isac.h"
+#include "webrtc/base/checks.h"
-#include <assert.h>
#include <math.h>
#include <string.h>
@@ -159,7 +159,7 @@
int immediate_set = 0;
int num_pkts_expected;
- assert(!bwest_str->external_bw_info.in_use);
+ RTC_DCHECK(!bwest_str->external_bw_info.in_use);
// We have to adjust the header-rate if the first packet has a
// frame-size different than the initialized value.
@@ -514,7 +514,7 @@
int16_t index,
enum IsacSamplingRate encoderSamplingFreq)
{
- assert(!bwest_str->external_bw_info.in_use);
+ RTC_DCHECK(!bwest_str->external_bw_info.in_use);
if((index < 0) || (index > 23))
{
@@ -572,7 +572,7 @@
BwEstimatorstr* bwest_str,
int32_t index)
{
- assert(!bwest_str->external_bw_info.in_use);
+ RTC_DCHECK(!bwest_str->external_bw_info.in_use);
if((index < 0) || (index > 23))
{
@@ -711,7 +711,7 @@
float jitter_sign;
float bw_adjust;
- assert(!bwest_str->external_bw_info.in_use);
+ RTC_DCHECK(!bwest_str->external_bw_info.in_use);
/* create a value between -1.0 and 1.0 indicating "average sign" of jitter */
jitter_sign = bwest_str->rec_jitter_short_term /
@@ -741,7 +741,7 @@
{
int32_t rec_max_delay;
- assert(!bwest_str->external_bw_info.in_use);
+ RTC_DCHECK(!bwest_str->external_bw_info.in_use);
rec_max_delay = (int32_t)(bwest_str->rec_max_delay);
@@ -759,7 +759,7 @@
/* Clamp val to the closed interval [min,max]. */
static int32_t clamp(int32_t val, int32_t min, int32_t max) {
- assert(min <= max);
+ RTC_DCHECK_LE(min, max);
return val < min ? min : (val > max ? max : val);
}
@@ -778,7 +778,7 @@
void WebRtcIsacBw_GetBandwidthInfo(BwEstimatorstr* bwest_str,
enum IsacSamplingRate decoder_sample_rate_hz,
IsacBandwidthInfo* bwinfo) {
- assert(!bwest_str->external_bw_info.in_use);
+ RTC_DCHECK(!bwest_str->external_bw_info.in_use);
bwinfo->in_use = 1;
bwinfo->send_bw_avg = WebRtcIsac_GetUplinkBandwidth(bwest_str);
bwinfo->send_max_delay_avg = WebRtcIsac_GetUplinkMaxDelay(bwest_str);
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/isac.c b/webrtc/modules/audio_coding/codecs/isac/main/source/isac.c
index 875e7ac..e59f16f 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/source/isac.c
+++ b/webrtc/modules/audio_coding/codecs/isac/main/source/isac.c
@@ -17,12 +17,12 @@
#include "webrtc/modules/audio_coding/codecs/isac/main/include/isac.h"
-#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/modules/audio_coding/codecs/isac/main/source/bandwidth_estimator.h"
#include "webrtc/modules/audio_coding/codecs/isac/main/source/codec.h"
@@ -1539,8 +1539,8 @@
void WebRtcIsac_SetInitialBweBottleneck(ISACStruct* ISAC_main_inst,
int bottleneck_bits_per_second) {
ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst;
- assert(bottleneck_bits_per_second >= 10000 &&
- bottleneck_bits_per_second <= 32000);
+ RTC_DCHECK_GE(bottleneck_bits_per_second, 10000);
+ RTC_DCHECK_LE(bottleneck_bits_per_second, 32000);
instISAC->bwestimator_obj.send_bw_avg = (float)bottleneck_bits_per_second;
}
@@ -2341,7 +2341,7 @@
void WebRtcIsac_GetBandwidthInfo(ISACStruct* inst,
IsacBandwidthInfo* bwinfo) {
ISACMainStruct* instISAC = (ISACMainStruct*)inst;
- assert(instISAC->initFlag & BIT_MASK_DEC_INIT);
+ RTC_DCHECK_NE(0, instISAC->initFlag & BIT_MASK_DEC_INIT);
WebRtcIsacBw_GetBandwidthInfo(&instISAC->bwestimator_obj,
instISAC->decoderSamplingRateKHz, bwinfo);
}
@@ -2349,15 +2349,15 @@
void WebRtcIsac_SetBandwidthInfo(ISACStruct* inst,
const IsacBandwidthInfo* bwinfo) {
ISACMainStruct* instISAC = (ISACMainStruct*)inst;
- assert(instISAC->initFlag & BIT_MASK_ENC_INIT);
+ RTC_DCHECK_NE(0, instISAC->initFlag & BIT_MASK_ENC_INIT);
WebRtcIsacBw_SetBandwidthInfo(&instISAC->bwestimator_obj, bwinfo);
}
void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst,
int sample_rate_hz) {
ISACMainStruct* instISAC = (ISACMainStruct*)inst;
- assert(instISAC->initFlag & BIT_MASK_DEC_INIT);
- assert(!(instISAC->initFlag & BIT_MASK_ENC_INIT));
- assert(sample_rate_hz == 16000 || sample_rate_hz == 32000);
+ RTC_DCHECK_NE(0, instISAC->initFlag & BIT_MASK_DEC_INIT);
+ RTC_DCHECK(!(instISAC->initFlag & BIT_MASK_ENC_INIT));
+ RTC_DCHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000);
instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000;
}
diff --git a/webrtc/modules/audio_processing/agc/legacy/analog_agc.c b/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
index 2450e05..d215564 100644
--- a/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
+++ b/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
@@ -19,12 +19,13 @@
#include "webrtc/modules/audio_processing/agc/legacy/analog_agc.h"
-#include <assert.h>
#include <stdlib.h>
#ifdef WEBRTC_AGC_DEBUG_DUMP
#include <stdio.h>
#endif
+#include "webrtc/base/checks.h"
+
/* The slope of in Q13*/
static const int16_t kSlope1[8] = {21793, 12517, 7189, 4129,
2372, 1362, 472, 78};
@@ -155,14 +156,14 @@
if (stt->micVol > stt->maxAnalog) {
/* |maxLevel| is strictly >= |micVol|, so this condition should be
* satisfied here, ensuring there is no divide-by-zero. */
- assert(stt->maxLevel > stt->maxAnalog);
+ RTC_DCHECK_GT(stt->maxLevel, stt->maxAnalog);
/* Q1 */
tmp16 = (int16_t)(stt->micVol - stt->maxAnalog);
tmp32 = (GAIN_TBL_LEN - 1) * tmp16;
tmp16 = (int16_t)(stt->maxLevel - stt->maxAnalog);
targetGainIdx = tmp32 / tmp16;
- assert(targetGainIdx < GAIN_TBL_LEN);
+ RTC_DCHECK_LT(targetGainIdx, GAIN_TBL_LEN);
/* Increment through the table towards the target gain.
* If micVol drops below maxAnalog, we allow the gain
diff --git a/webrtc/modules/audio_processing/agc/legacy/digital_agc.c b/webrtc/modules/audio_processing/agc/legacy/digital_agc.c
index 231a204..dd24845c 100644
--- a/webrtc/modules/audio_processing/agc/legacy/digital_agc.c
+++ b/webrtc/modules/audio_processing/agc/legacy/digital_agc.c
@@ -14,12 +14,12 @@
#include "webrtc/modules/audio_processing/agc/legacy/digital_agc.h"
-#include <assert.h>
#include <string.h>
#ifdef WEBRTC_AGC_DEBUG_DUMP
#include <stdio.h>
#endif
+#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_processing/agc/legacy/gain_control.h"
// To generate the gaintable, copy&paste the following lines to a Matlab window:
@@ -109,7 +109,7 @@
diffGain =
WebRtcSpl_DivW32W16ResW16(tmp32no1 + (kCompRatio >> 1), kCompRatio);
if (diffGain < 0 || diffGain >= kGenFuncTableSize) {
- assert(0);
+ RTC_DCHECK(0);
return -1;
}
@@ -268,7 +268,7 @@
int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* stt,
const int16_t* in_far,
size_t nrSamples) {
- assert(stt != NULL);
+ RTC_DCHECK(stt);
// VAD for far end
WebRtcAgc_ProcessVad(&stt->vadFarend, in_far, nrSamples);
diff --git a/webrtc/modules/audio_processing/ns/ns_core.c b/webrtc/modules/audio_processing/ns/ns_core.c
index 5ce64ce..76589c5 100644
--- a/webrtc/modules/audio_processing/ns/ns_core.c
+++ b/webrtc/modules/audio_processing/ns/ns_core.c
@@ -8,11 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <assert.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/fft4g.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/modules/audio_processing/ns/noise_suppression.h"
@@ -857,7 +857,7 @@
size_t frame_length,
size_t buffer_length,
float* buffer) {
- assert(buffer_length < 2 * frame_length);
+ RTC_DCHECK_LT(buffer_length, 2 * frame_length);
memcpy(buffer,
buffer + frame_length,
@@ -893,7 +893,7 @@
float* magn) {
size_t i;
- assert(magnitude_length == time_data_length / 2 + 1);
+ RTC_DCHECK_EQ(magnitude_length, time_data_length / 2 + 1);
WebRtc_rdft(time_data_length, 1, time_data, self->ip, self->wfft);
@@ -929,7 +929,7 @@
float* time_data) {
size_t i;
- assert(time_data_length == 2 * (magnitude_length - 1));
+ RTC_DCHECK_EQ(time_data_length, 2 * (magnitude_length - 1));
time_data[0] = real[0];
time_data[1] = real[magnitude_length - 1];
@@ -1062,7 +1062,7 @@
float parametric_num = 0.0;
// Check that initiation has been done.
- assert(self->initFlag == 1);
+ RTC_DCHECK_EQ(1, self->initFlag);
updateParsFlag = self->modelUpdatePars[0];
// Update analysis buffer for L band.
@@ -1206,8 +1206,8 @@
float sumMagnAnalyze, sumMagnProcess;
// Check that initiation has been done.
- assert(self->initFlag == 1);
- assert((num_bands - 1) <= NUM_HIGH_BANDS_MAX);
+ RTC_DCHECK_EQ(1, self->initFlag);
+ RTC_DCHECK_LE(num_bands - 1, NUM_HIGH_BANDS_MAX);
const float* const* speechFrameHB = NULL;
float* const* outFrameHB = NULL;
diff --git a/webrtc/modules/audio_processing/ns/nsx_core.c b/webrtc/modules/audio_processing/ns/nsx_core.c
index 94b6449..c58fc39 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core.c
@@ -10,11 +10,11 @@
#include "webrtc/modules/audio_processing/ns/noise_suppression_x.h"
-#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/real_fft.h"
#include "webrtc/modules/audio_processing/ns/nsx_core.h"
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
@@ -344,8 +344,8 @@
size_t i, s, offset;
tabind = inst->stages - inst->normData;
- assert(tabind < 9);
- assert(tabind > -9);
+ RTC_DCHECK_LT(tabind, 9);
+ RTC_DCHECK_GT(tabind, -9);
if (tabind < 0) {
logval = -WebRtcNsx_kLogTable[-tabind];
} else {
@@ -362,7 +362,7 @@
frac = (int16_t)((((uint32_t)magn[i] << zeros)
& 0x7FFFFFFF) >> 23);
// log2(magn(i))
- assert(frac < 256);
+ RTC_DCHECK_LT(frac, 256);
log2 = (int16_t)(((31 - zeros) << 8)
+ WebRtcNsx_kLogTableFrac[frac]);
// log2(magn(i))*log(2)
@@ -380,7 +380,7 @@
// Get counter values from state
counter = inst->noiseEstCounter[s];
- assert(counter < 201);
+ RTC_DCHECK_LT(counter, 201);
countDiv = WebRtcNsx_kCounterDiv[counter];
countProd = (int16_t)(counter * countDiv);
@@ -543,7 +543,7 @@
const int16_t* in,
int16_t* out) {
size_t i = 0;
- assert(inst->normData >= 0);
+ RTC_DCHECK_GE(inst->normData, 0);
for (i = 0; i < inst->anaLen; ++i) {
out[i] = in[i] << inst->normData; // Q(normData)
}
@@ -594,8 +594,8 @@
// Use pink noise estimate
// noise_estimate = 2^(pinkNoiseNumerator + pinkNoiseExp * log2(j))
- assert(freq_index >= 0);
- assert(freq_index < 129);
+ RTC_DCHECK_GE(freq_index, 0);
+ RTC_DCHECK_LT(freq_index, 129);
tmp32no2 = (pink_noise_exp_avg * kLogIndex[freq_index]) >> 15; // Q11
tmp32no1 = pink_noise_num_avg - tmp32no2; // Q11
@@ -1038,7 +1038,7 @@
frac = (int16_t)(((uint32_t)((uint32_t)(magn[i]) << zeros)
& 0x7FFFFFFF) >> 23);
// log2(magn(i))
- assert(frac < 256);
+ RTC_DCHECK_LT(frac, 256);
tmpU32 = (uint32_t)(((31 - zeros) << 8)
+ WebRtcNsx_kLogTableFrac[frac]); // Q8
avgSpectralFlatnessNum += tmpU32; // Q8
@@ -1053,7 +1053,7 @@
zeros = WebRtcSpl_NormU32(avgSpectralFlatnessDen);
frac = (int16_t)(((avgSpectralFlatnessDen << zeros) & 0x7FFFFFFF) >> 23);
// log2(avgSpectralFlatnessDen)
- assert(frac < 256);
+ RTC_DCHECK_LT(frac, 256);
tmp32 = (int32_t)(((31 - zeros) << 8) + WebRtcNsx_kLogTableFrac[frac]); // Q8
logCurSpectralFlatness = (int32_t)avgSpectralFlatnessNum;
logCurSpectralFlatness += ((int32_t)(inst->stages - 1) << (inst->stages + 7)); // Q(8+stages-1)
@@ -1286,7 +1286,7 @@
frac = (int16_t)((((uint32_t)magnU16[inst->anaLen2] << zeros) &
0x7FFFFFFF) >> 23); // Q8
// log2(magnU16(i)) in Q8
- assert(frac < 256);
+ RTC_DCHECK_LT(frac, 256);
log2 = (int16_t)(((31 - zeros) << 8) + WebRtcNsx_kLogTableFrac[frac]);
}
@@ -1320,7 +1320,7 @@
frac = (int16_t)((((uint32_t)magnU16[i] << zeros) &
0x7FFFFFFF) >> 23);
// log2(magnU16(i)) in Q8
- assert(frac < 256);
+ RTC_DCHECK_LT(frac, 256);
log2 = (int16_t)(((31 - zeros) << 8)
+ WebRtcNsx_kLogTableFrac[frac]);
}
@@ -1347,14 +1347,14 @@
// Shift to same Q-domain as whiteNoiseLevel
tmpU32no1 >>= right_shifts_in_magnU16;
// This operation is safe from wrap around as long as END_STARTUP_SHORT < 128
- assert(END_STARTUP_SHORT < 128);
+ RTC_DCHECK_LT(END_STARTUP_SHORT, 128);
inst->whiteNoiseLevel += tmpU32no1; // Q(minNorm-stages)
// Estimate Pink noise parameters
// Denominator used in both parameter estimates.
// The value is only dependent on the size of the frequency band (kStartBand)
// and to reduce computational complexity stored in a table (kDeterminantEstMatrix[])
- assert(kStartBand < 66);
+ RTC_DCHECK_LT(kStartBand, 66);
matrix_determinant = kDeterminantEstMatrix[kStartBand]; // Q0
sum_log_i = kSumLogIndex[kStartBand]; // Q5
sum_log_i_square = kSumSquareLogIndex[kStartBand]; // Q2
@@ -1469,13 +1469,13 @@
inst->energyIn >>= 8 + scaleEnergyOut - inst->scaleEnergyIn;
}
- assert(inst->energyIn > 0);
+ RTC_DCHECK_GT(inst->energyIn, 0);
energyRatio = (energyOut + inst->energyIn / 2) / inst->energyIn; // Q8
// Limit the ratio to [0, 1] in Q8, i.e., [0, 256]
energyRatio = WEBRTC_SPL_SAT(256, energyRatio, 0);
// all done in lookup tables now
- assert(energyRatio < 257);
+ RTC_DCHECK_LT(energyRatio, 257);
gainFactor1 = kFactor1Table[energyRatio]; // Q8
gainFactor2 = inst->factor2Table[energyRatio]; // Q8
@@ -1534,24 +1534,24 @@
int q_domain_to_use = 0;
// Code for ARMv7-Neon platform assumes the following:
- assert(inst->anaLen > 0);
- assert(inst->anaLen2 > 0);
- assert(inst->anaLen % 16 == 0);
- assert(inst->anaLen2 % 8 == 0);
- assert(inst->blockLen10ms > 0);
- assert(inst->blockLen10ms % 16 == 0);
- assert(inst->magnLen == inst->anaLen2 + 1);
+ RTC_DCHECK_GT(inst->anaLen, 0);
+ RTC_DCHECK_GT(inst->anaLen2, 0);
+ RTC_DCHECK_EQ(0, inst->anaLen % 16);
+ RTC_DCHECK_EQ(0, inst->anaLen2 % 8);
+ RTC_DCHECK_GT(inst->blockLen10ms, 0);
+ RTC_DCHECK_EQ(0, inst->blockLen10ms % 16);
+ RTC_DCHECK_EQ(inst->magnLen, inst->anaLen2 + 1);
#ifdef NS_FILEDEBUG
if (fwrite(spframe, sizeof(short),
inst->blockLen10ms, inst->infile) != inst->blockLen10ms) {
- assert(false);
+ RTC_DCHECK(false);
}
#endif
// Check that initialization has been done
- assert(inst->initFlag == 1);
- assert((num_bands - 1) <= NUM_HIGH_BANDS_MAX);
+ RTC_DCHECK_EQ(1, inst->initFlag);
+ RTC_DCHECK_LE(num_bands - 1, NUM_HIGH_BANDS_MAX);
const short* const* speechFrameHB = NULL;
short* const* outFrameHB = NULL;
@@ -1989,7 +1989,7 @@
//gain filter
tmpU32no1 = inst->overdrive + ((priorSnr + 8192) >> 14); // Q8
- assert(inst->overdrive > 0);
+ RTC_DCHECK_GT(inst->overdrive, 0);
tmpU16no1 = (priorSnr + tmpU32no1 / 2) / tmpU32no1; // Q14
inst->noiseSupFilter[i] = WEBRTC_SPL_SAT(16384, tmpU16no1, inst->denoiseBound); // 16384 = Q14(1.0) // Q14
@@ -2025,7 +2025,7 @@
#ifdef NS_FILEDEBUG
if (fwrite(outframe, sizeof(short),
inst->blockLen10ms, inst->outfile) != inst->blockLen10ms) {
- assert(false);
+ RTC_DCHECK(false);
}
#endif
@@ -2052,7 +2052,7 @@
tmpU16no1 += nonSpeechProbFinal[i]; // Q8
tmpU32no1 += (uint32_t)(inst->noiseSupFilter[i]); // Q14
}
- assert(inst->stages >= 7);
+ RTC_DCHECK_GE(inst->stages, 7);
avgProbSpeechHB = (4096 - (tmpU16no1 >> (inst->stages - 7))); // Q12
avgFilterGainHB = (int16_t)(tmpU32no1 >> (inst->stages - 3)); // Q14
diff --git a/webrtc/modules/audio_processing/ns/nsx_core_c.c b/webrtc/modules/audio_processing/ns/nsx_core_c.c
index 213320d..abfb2c9 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core_c.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core_c.c
@@ -8,8 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <assert.h>
-
+#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_processing/ns/noise_suppression_x.h"
#include "webrtc/modules/audio_processing/ns/nsx_core.h"
#include "webrtc/modules/audio_processing/ns/nsx_defines.h"
@@ -149,7 +148,7 @@
if (inst->featureSpecDiff) {
normTmp = WEBRTC_SPL_MIN(20 - inst->stages,
WebRtcSpl_NormU32(inst->featureSpecDiff));
- assert(normTmp >= 0);
+ RTC_DCHECK_GE(normTmp, 0);
tmpU32no1 = inst->featureSpecDiff << normTmp; // Q(normTmp-2*stages)
tmpU32no2 = inst->timeAvgMagnEnergy >> (20 - inst->stages - normTmp);
if (tmpU32no2 > 0) {
diff --git a/webrtc/modules/audio_processing/ns/nsx_core_mips.c b/webrtc/modules/audio_processing/ns/nsx_core_mips.c
index 3922308..2baf7df 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core_mips.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core_mips.c
@@ -8,9 +8,9 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <assert.h>
#include <string.h>
+#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_processing/ns/noise_suppression_x.h"
#include "webrtc/modules/audio_processing/ns/nsx_core.h"
@@ -184,7 +184,7 @@
if (inst->featureSpecDiff) {
normTmp = WEBRTC_SPL_MIN(20 - inst->stages,
WebRtcSpl_NormU32(inst->featureSpecDiff));
- assert(normTmp >= 0);
+ RTC_DCHECK_GE(normTmp, 0);
tmpU32no1 = inst->featureSpecDiff << normTmp; // Q(normTmp-2*stages)
tmpU32no2 = inst->timeAvgMagnEnergy >> (20 - inst->stages - normTmp);
if (tmpU32no2 > 0) {
diff --git a/webrtc/modules/audio_processing/ns/nsx_core_neon.c b/webrtc/modules/audio_processing/ns/nsx_core_neon.c
index 516dd09..fb1b323 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core_neon.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core_neon.c
@@ -11,7 +11,8 @@
#include "webrtc/modules/audio_processing/ns/nsx_core.h"
#include <arm_neon.h>
-#include <assert.h>
+
+#include "webrtc/base/checks.h"
// Constants to compensate for shifting signal log(2^shifts).
const int16_t WebRtcNsx_kLogTable[9] = {
@@ -144,8 +145,8 @@
size_t i, s, offset;
tabind = inst->stages - inst->normData;
- assert(tabind < 9);
- assert(tabind > -9);
+ RTC_DCHECK_LT(tabind, 9);
+ RTC_DCHECK_GT(tabind, -9);
if (tabind < 0) {
logval = -WebRtcNsx_kLogTable[-tabind];
} else {
@@ -163,7 +164,7 @@
zeros = WebRtcSpl_NormU32((uint32_t)magn[i]);
frac = (int16_t)((((uint32_t)magn[i] << zeros)
& 0x7FFFFFFF) >> 23);
- assert(frac < 256);
+ RTC_DCHECK_LT(frac, 256);
// log2(magn(i))
log2 = (int16_t)(((31 - zeros) << 8)
+ WebRtcNsx_kLogTableFrac[frac]);
@@ -190,7 +191,7 @@
// Get counter values from state
counter = inst->noiseEstCounter[s];
- assert(counter < 201);
+ RTC_DCHECK_LT(counter, 201);
countDiv = WebRtcNsx_kCounterDiv[counter];
countProd = (int16_t)(counter * countDiv);
@@ -354,8 +355,8 @@
// Filter the data in the frequency domain, and create spectrum.
void WebRtcNsx_PrepareSpectrumNeon(NoiseSuppressionFixedC* inst,
int16_t* freq_buf) {
- assert(inst->magnLen % 8 == 1);
- assert(inst->anaLen2 % 16 == 0);
+ RTC_DCHECK_EQ(1, inst->magnLen % 8);
+ RTC_DCHECK_EQ(0, inst->anaLen2 % 16);
// (1) Filtering.
@@ -445,8 +446,8 @@
void WebRtcNsx_SynthesisUpdateNeon(NoiseSuppressionFixedC* inst,
int16_t* out_frame,
int16_t gain_factor) {
- assert(inst->anaLen % 16 == 0);
- assert(inst->blockLen10ms % 16 == 0);
+ RTC_DCHECK_EQ(0, inst->anaLen % 16);
+ RTC_DCHECK_EQ(0, inst->blockLen10ms % 16);
int16_t* preal_start = inst->real;
const int16_t* pwindow = inst->window;
@@ -537,8 +538,8 @@
void WebRtcNsx_AnalysisUpdateNeon(NoiseSuppressionFixedC* inst,
int16_t* out,
int16_t* new_speech) {
- assert(inst->blockLen10ms % 16 == 0);
- assert(inst->anaLen % 16 == 0);
+ RTC_DCHECK_EQ(0, inst->blockLen10ms % 16);
+ RTC_DCHECK_EQ(0, inst->anaLen % 16);
// For lower band update analysis buffer.
// memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,
diff --git a/webrtc/system_wrappers/source/data_log_c_helpers_unittest.c b/webrtc/system_wrappers/source/data_log_c_helpers_unittest.c
index 0b05e22..cd1ff72 100644
--- a/webrtc/system_wrappers/source/data_log_c_helpers_unittest.c
+++ b/webrtc/system_wrappers/source/data_log_c_helpers_unittest.c
@@ -10,7 +10,6 @@
#include "webrtc/system_wrappers/source/data_log_c_helpers_unittest.h"
-#include <assert.h>
#include <stdlib.h>
#include <string.h>