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}
This commit is contained in:
kwiberg 2016-08-26 04:33:34 -07:00 committed by Commit bot
parent 073ece45b6
commit 1e8ed4a801
30 changed files with 151 additions and 157 deletions

View file

@ -10,7 +10,7 @@
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" #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 WebRtcSpl_AutoCorrelation(const int16_t* in_vector,
size_t in_vector_length, size_t in_vector_length,
@ -22,7 +22,7 @@ size_t WebRtcSpl_AutoCorrelation(const int16_t* in_vector,
int16_t smax = 0; int16_t smax = 0;
int scaling = 0; int scaling = 0;
assert(order <= in_vector_length); RTC_DCHECK_LE(order, in_vector_length);
// Find the maximum absolute value of the samples. // Find the maximum absolute value of the samples.
smax = WebRtcSpl_MaxAbsValueW16(in_vector, in_vector_length); smax = WebRtcSpl_MaxAbsValueW16(in_vector, in_vector_length);

View file

@ -7,8 +7,8 @@
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * 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" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
// TODO(bjornv): Change the return type to report errors. // TODO(bjornv): Change the return type to report errors.
@ -21,8 +21,8 @@ void WebRtcSpl_FilterARFastQ12(const int16_t* data_in,
size_t i = 0; size_t i = 0;
size_t j = 0; size_t j = 0;
assert(data_length > 0); RTC_DCHECK_GT(data_length, 0);
assert(coefficients_length > 1); RTC_DCHECK_GT(coefficients_length, 1);
for (i = 0; i < data_length; i++) { for (i = 0; i < data_length; i++) {
int32_t output = 0; int32_t output = 0;

View file

@ -7,8 +7,8 @@
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * 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" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
void WebRtcSpl_FilterARFastQ12(const int16_t* data_in, void WebRtcSpl_FilterARFastQ12(const int16_t* data_in,
@ -25,8 +25,8 @@ void WebRtcSpl_FilterARFastQ12(const int16_t* data_in,
int min16 = 0xFFFF8000; int min16 = 0xFFFF8000;
#endif // #if !defined(MIPS_DSP_R1_LE) #endif // #if !defined(MIPS_DSP_R1_LE)
assert(data_length > 0); RTC_DCHECK_GT(data_length, 0);
assert(coefficients_length > 1); RTC_DCHECK_GT(coefficients_length, 1);
__asm __volatile ( __asm __volatile (
".set push \n\t" ".set push \n\t"

View file

@ -24,9 +24,9 @@
* *
*/ */
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
// TODO(bjorn/kma): Consolidate function pairs (e.g. combine // TODO(bjorn/kma): Consolidate function pairs (e.g. combine
@ -38,7 +38,7 @@ int16_t WebRtcSpl_MaxAbsValueW16C(const int16_t* vector, size_t length) {
size_t i = 0; size_t i = 0;
int absolute = 0, maximum = 0; int absolute = 0, maximum = 0;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
absolute = abs((int)vector[i]); absolute = abs((int)vector[i]);
@ -64,7 +64,7 @@ int32_t WebRtcSpl_MaxAbsValueW32C(const int32_t* vector, size_t length) {
uint32_t absolute = 0, maximum = 0; uint32_t absolute = 0, maximum = 0;
size_t i = 0; size_t i = 0;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
absolute = abs((int)vector[i]); absolute = abs((int)vector[i]);
@ -83,7 +83,7 @@ int16_t WebRtcSpl_MaxValueW16C(const int16_t* vector, size_t length) {
int16_t maximum = WEBRTC_SPL_WORD16_MIN; int16_t maximum = WEBRTC_SPL_WORD16_MIN;
size_t i = 0; size_t i = 0;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (vector[i] > maximum) if (vector[i] > maximum)
@ -97,7 +97,7 @@ int32_t WebRtcSpl_MaxValueW32C(const int32_t* vector, size_t length) {
int32_t maximum = WEBRTC_SPL_WORD32_MIN; int32_t maximum = WEBRTC_SPL_WORD32_MIN;
size_t i = 0; size_t i = 0;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (vector[i] > maximum) if (vector[i] > maximum)
@ -111,7 +111,7 @@ int16_t WebRtcSpl_MinValueW16C(const int16_t* vector, size_t length) {
int16_t minimum = WEBRTC_SPL_WORD16_MAX; int16_t minimum = WEBRTC_SPL_WORD16_MAX;
size_t i = 0; size_t i = 0;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (vector[i] < minimum) if (vector[i] < minimum)
@ -125,7 +125,7 @@ int32_t WebRtcSpl_MinValueW32C(const int32_t* vector, size_t length) {
int32_t minimum = WEBRTC_SPL_WORD32_MAX; int32_t minimum = WEBRTC_SPL_WORD32_MAX;
size_t i = 0; size_t i = 0;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (vector[i] < minimum) if (vector[i] < minimum)
@ -141,7 +141,7 @@ size_t WebRtcSpl_MaxAbsIndexW16(const int16_t* vector, size_t length) {
size_t i = 0, index = 0; size_t i = 0, index = 0;
int absolute = 0, maximum = 0; int absolute = 0, maximum = 0;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
absolute = abs((int)vector[i]); absolute = abs((int)vector[i]);
@ -160,7 +160,7 @@ size_t WebRtcSpl_MaxIndexW16(const int16_t* vector, size_t length) {
size_t i = 0, index = 0; size_t i = 0, index = 0;
int16_t maximum = WEBRTC_SPL_WORD16_MIN; int16_t maximum = WEBRTC_SPL_WORD16_MIN;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (vector[i] > maximum) { if (vector[i] > maximum) {
@ -177,7 +177,7 @@ size_t WebRtcSpl_MaxIndexW32(const int32_t* vector, size_t length) {
size_t i = 0, index = 0; size_t i = 0, index = 0;
int32_t maximum = WEBRTC_SPL_WORD32_MIN; int32_t maximum = WEBRTC_SPL_WORD32_MIN;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (vector[i] > maximum) { if (vector[i] > maximum) {
@ -194,7 +194,7 @@ size_t WebRtcSpl_MinIndexW16(const int16_t* vector, size_t length) {
size_t i = 0, index = 0; size_t i = 0, index = 0;
int16_t minimum = WEBRTC_SPL_WORD16_MAX; int16_t minimum = WEBRTC_SPL_WORD16_MAX;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (vector[i] < minimum) { if (vector[i] < minimum) {
@ -211,7 +211,7 @@ size_t WebRtcSpl_MinIndexW32(const int32_t* vector, size_t length) {
size_t i = 0, index = 0; size_t i = 0, index = 0;
int32_t minimum = WEBRTC_SPL_WORD32_MAX; int32_t minimum = WEBRTC_SPL_WORD32_MAX;
assert(length > 0); RTC_DCHECK_GT(length, 0);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
if (vector[i] < minimum) { if (vector[i] < minimum) {

View file

@ -16,8 +16,7 @@
* *
*/ */
#include <assert.h> #include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
// Maximum absolute value of word16 vector. // Maximum absolute value of word16 vector.
@ -26,7 +25,7 @@ int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, size_t length) {
int32_t tmp32_0, tmp32_1, tmp32_2, tmp32_3; int32_t tmp32_0, tmp32_1, tmp32_2, tmp32_3;
size_t i, loop_size; size_t i, loop_size;
assert(length > 0); RTC_DCHECK_GT(length, 0);
#if defined(MIPS_DSP_R1) #if defined(MIPS_DSP_R1)
const int32_t* tmpvec32 = (int32_t*)vector; const int32_t* tmpvec32 = (int32_t*)vector;
@ -230,7 +229,7 @@ int32_t WebRtcSpl_MaxAbsValueW32_mips(const int32_t* vector, size_t length) {
uint32_t absolute = 0, maximum = 0; uint32_t absolute = 0, maximum = 0;
int tmp1 = 0, max_value = 0x7fffffff; int tmp1 = 0, max_value = 0x7fffffff;
assert(length > 0); RTC_DCHECK_GT(length, 0);
__asm__ volatile ( __asm__ volatile (
".set push \n\t" ".set push \n\t"
@ -264,7 +263,7 @@ int16_t WebRtcSpl_MaxValueW16_mips(const int16_t* vector, size_t length) {
int tmp1; int tmp1;
int16_t value; int16_t value;
assert(length > 0); RTC_DCHECK_GT(length, 0);
__asm__ volatile ( __asm__ volatile (
".set push \n\t" ".set push \n\t"
@ -292,7 +291,7 @@ int32_t WebRtcSpl_MaxValueW32_mips(const int32_t* vector, size_t length) {
int32_t maximum = WEBRTC_SPL_WORD32_MIN; int32_t maximum = WEBRTC_SPL_WORD32_MIN;
int tmp1, value; int tmp1, value;
assert(length > 0); RTC_DCHECK_GT(length, 0);
__asm__ volatile ( __asm__ volatile (
".set push \n\t" ".set push \n\t"
@ -322,7 +321,7 @@ int16_t WebRtcSpl_MinValueW16_mips(const int16_t* vector, size_t length) {
int tmp1; int tmp1;
int16_t value; int16_t value;
assert(length > 0); RTC_DCHECK_GT(length, 0);
__asm__ volatile ( __asm__ volatile (
".set push \n\t" ".set push \n\t"
@ -351,7 +350,7 @@ int32_t WebRtcSpl_MinValueW32_mips(const int32_t* vector, size_t length) {
int32_t minimum = WEBRTC_SPL_WORD32_MAX; int32_t minimum = WEBRTC_SPL_WORD32_MAX;
int tmp1, value; int tmp1, value;
assert(length > 0); RTC_DCHECK_GT(length, 0);
__asm__ volatile ( __asm__ volatile (
".set push \n\t" ".set push \n\t"

View file

@ -9,16 +9,16 @@
*/ */
#include <arm_neon.h> #include <arm_neon.h>
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
// Maximum absolute value of word16 vector. C version for generic platforms. // Maximum absolute value of word16 vector. C version for generic platforms.
int16_t WebRtcSpl_MaxAbsValueW16Neon(const int16_t* vector, size_t length) { int16_t WebRtcSpl_MaxAbsValueW16Neon(const int16_t* vector, size_t length) {
int absolute = 0, maximum = 0; int absolute = 0, maximum = 0;
assert(length > 0); RTC_DCHECK_GT(length, 0);
const int16_t* p_start = vector; const int16_t* p_start = vector;
size_t rest = length & 7; size_t rest = length & 7;
@ -76,7 +76,7 @@ int32_t WebRtcSpl_MaxAbsValueW32Neon(const int32_t* vector, size_t length) {
size_t i = 0; size_t i = 0;
size_t residual = length & 0x7; size_t residual = length & 0x7;
assert(length > 0); RTC_DCHECK_GT(length, 0);
const int32_t* p_start = vector; const int32_t* p_start = vector;
uint32x4_t max32x4_0 = vdupq_n_u32(0); uint32x4_t max32x4_0 = vdupq_n_u32(0);
@ -128,7 +128,7 @@ int16_t WebRtcSpl_MaxValueW16Neon(const int16_t* vector, size_t length) {
size_t i = 0; size_t i = 0;
size_t residual = length & 0x7; size_t residual = length & 0x7;
assert(length > 0); RTC_DCHECK_GT(length, 0);
const int16_t* p_start = vector; const int16_t* p_start = vector;
int16x8_t max16x8 = vdupq_n_s16(WEBRTC_SPL_WORD16_MIN); int16x8_t max16x8 = vdupq_n_s16(WEBRTC_SPL_WORD16_MIN);
@ -166,7 +166,7 @@ int32_t WebRtcSpl_MaxValueW32Neon(const int32_t* vector, size_t length) {
size_t i = 0; size_t i = 0;
size_t residual = length & 0x7; size_t residual = length & 0x7;
assert(length > 0); RTC_DCHECK_GT(length, 0);
const int32_t* p_start = vector; const int32_t* p_start = vector;
int32x4_t max32x4_0 = vdupq_n_s32(WEBRTC_SPL_WORD32_MIN); int32x4_t max32x4_0 = vdupq_n_s32(WEBRTC_SPL_WORD32_MIN);
@ -208,7 +208,7 @@ int16_t WebRtcSpl_MinValueW16Neon(const int16_t* vector, size_t length) {
size_t i = 0; size_t i = 0;
size_t residual = length & 0x7; size_t residual = length & 0x7;
assert(length > 0); RTC_DCHECK_GT(length, 0);
const int16_t* p_start = vector; const int16_t* p_start = vector;
int16x8_t min16x8 = vdupq_n_s16(WEBRTC_SPL_WORD16_MAX); int16x8_t min16x8 = vdupq_n_s16(WEBRTC_SPL_WORD16_MAX);
@ -246,7 +246,7 @@ int32_t WebRtcSpl_MinValueW32Neon(const int32_t* vector, size_t length) {
size_t i = 0; size_t i = 0;
size_t residual = length & 0x7; size_t residual = length & 0x7;
assert(length > 0); RTC_DCHECK_GT(length, 0);
const int32_t* p_start = vector; const int32_t* p_start = vector;
int32x4_t min32x4_0 = vdupq_n_s32(WEBRTC_SPL_WORD32_MAX); int32x4_t min32x4_0 = vdupq_n_s32(WEBRTC_SPL_WORD32_MAX);

View file

@ -15,10 +15,9 @@
* *
*/ */
#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.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);
int32_t WebRtcSpl_SqrtLocal(int32_t in) int32_t WebRtcSpl_SqrtLocal(int32_t in)
@ -166,7 +165,7 @@ int32_t WebRtcSpl_Sqrt(int32_t value)
x_norm = (int16_t)(A >> 16); // x_norm = AH x_norm = (int16_t)(A >> 16); // x_norm = AH
nshift = (sh / 2); nshift = (sh / 2);
assert(nshift >= 0); RTC_DCHECK_GE(nshift, 0);
A = (int32_t)WEBRTC_SPL_LSHIFT_W32((int32_t)x_norm, 16); A = (int32_t)WEBRTC_SPL_LSHIFT_W32((int32_t)x_norm, 16);
A = WEBRTC_SPL_ABS_W32(A); // A = abs(x_norm<<16) A = WEBRTC_SPL_ABS_W32(A); // A = abs(x_norm<<16)

View file

@ -13,10 +13,9 @@
* *
*/ */
#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.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. // Maximum number of samples in a low/high-band frame.
enum enum
{ {
@ -136,8 +135,8 @@ void WebRtcSpl_AnalysisQMF(const int16_t* in_data, size_t in_data_length,
int32_t filter1[kMaxBandFrameLength]; int32_t filter1[kMaxBandFrameLength];
int32_t filter2[kMaxBandFrameLength]; int32_t filter2[kMaxBandFrameLength];
const size_t band_length = in_data_length / 2; const size_t band_length = in_data_length / 2;
assert(in_data_length % 2 == 0); RTC_DCHECK_EQ(0, in_data_length % 2);
assert(band_length <= kMaxBandFrameLength); RTC_DCHECK_LE(band_length, kMaxBandFrameLength);
// Split even and odd samples. Also shift them to Q10. // Split even and odd samples. Also shift them to Q10.
for (i = 0, k = 0; i < band_length; i++, k += 2) for (i = 0, k = 0; i < band_length; i++, k += 2)
@ -175,7 +174,7 @@ void WebRtcSpl_SynthesisQMF(const int16_t* low_band, const int16_t* high_band,
int32_t filter2[kMaxBandFrameLength]; int32_t filter2[kMaxBandFrameLength];
size_t i; size_t i;
int16_t k; 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. // Obtain the sum and difference channels out of upper and lower-band channels.
// Also shift to Q10 domain. // Also shift to Q10 domain.

View file

@ -10,8 +10,7 @@
#include "webrtc/common_audio/vad/vad_filterbank.h" #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/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/typedefs.h" #include "webrtc/typedefs.h"
@ -160,8 +159,8 @@ static void LogOfEnergy(const int16_t* data_in, size_t data_length,
// we eventually will mask out the fractional part. // we eventually will mask out the fractional part.
uint32_t energy = 0; uint32_t energy = 0;
assert(data_in != NULL); RTC_DCHECK(data_in);
assert(data_length > 0); RTC_DCHECK_GT(data_length, 0);
energy = (uint32_t) WebRtcSpl_Energy((int16_t*) data_in, data_length, energy = (uint32_t) WebRtcSpl_Energy((int16_t*) data_in, data_length,
&tot_rshifts); &tot_rshifts);
@ -261,8 +260,8 @@ int16_t WebRtcVad_CalculateFeatures(VadInstT* self, const int16_t* data_in,
int16_t* hp_out_ptr = hp_120; // [2000 - 4000] Hz. int16_t* hp_out_ptr = hp_120; // [2000 - 4000] Hz.
int16_t* lp_out_ptr = lp_120; // [0 - 2000] Hz. int16_t* lp_out_ptr = lp_120; // [0 - 2000] Hz.
assert(data_length <= 240); RTC_DCHECK_LE(data_length, 240);
assert(4 < kNumChannels - 1); // Checking maximum |frequency_band|. RTC_DCHECK_LT(4, kNumChannels - 1); // Checking maximum |frequency_band|.
// Split at 2000 Hz and downsample. // Split at 2000 Hz and downsample.
SplitFilter(in_ptr, data_length, &self->upper_state[frequency_band], SplitFilter(in_ptr, data_length, &self->upper_state[frequency_band],

View file

@ -10,8 +10,7 @@
#include "webrtc/common_audio/vad/vad_sp.h" #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/signal_processing/include/signal_processing_library.h"
#include "webrtc/common_audio/vad/vad_core.h" #include "webrtc/common_audio/vad/vad_core.h"
#include "webrtc/typedefs.h" #include "webrtc/typedefs.h"
@ -72,7 +71,7 @@ int16_t WebRtcVad_FindMinimum(VadInstT* self,
int16_t* age = &self->index_vector[offset]; int16_t* age = &self->index_vector[offset];
int16_t* smallest_values = &self->low_value_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 // Each value in |smallest_values| is getting 1 loop older. Update |age|, and
// remove old values. // remove old values.

View file

@ -20,9 +20,8 @@
#include "bandwidth_estimator.h" #include "bandwidth_estimator.h"
#include <assert.h>
#include "settings.h" #include "settings.h"
#include "webrtc/base/checks.h"
/* array of quantization levels for bottle neck info; Matlab code: */ /* array of quantization levels for bottle neck info; Matlab code: */
/* sprintf('%4.1ff, ', logspace(log10(5000), log10(40000), 12)) */ /* sprintf('%4.1ff, ', logspace(log10(5000), log10(40000), 12)) */
@ -180,7 +179,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
int16_t errCode; int16_t errCode;
assert(!bweStr->external_bw_info.in_use); RTC_DCHECK(!bweStr->external_bw_info.in_use);
/* UPDATE ESTIMATES FROM OTHER SIDE */ /* UPDATE ESTIMATES FROM OTHER SIDE */
@ -551,7 +550,7 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bweStr,
{ {
uint16_t RateInd; uint16_t RateInd;
assert(!bweStr->external_bw_info.in_use); RTC_DCHECK(!bweStr->external_bw_info.in_use);
if ( (Index < 0) || (Index > 23) ) { if ( (Index < 0) || (Index > 23) ) {
return -ISAC_RANGE_ERROR_BW_ESTIMATOR; return -ISAC_RANGE_ERROR_BW_ESTIMATOR;
@ -732,7 +731,7 @@ uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bweStr)
int32_t rec_jitter_short_term_abs_inv; /* Q18 */ int32_t rec_jitter_short_term_abs_inv; /* Q18 */
int32_t temp; 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 /* 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 */ 2^18 then needs to be shifted 13 bits to 2^31 */
@ -790,7 +789,7 @@ int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bweStr)
{ {
int16_t recMaxDelay = (int16_t)(bweStr->recMaxDelay >> 15); 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 */ /* limit range of jitter estimate */
if (recMaxDelay < MIN_ISAC_MD) { if (recMaxDelay < MIN_ISAC_MD) {
@ -804,7 +803,7 @@ int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bweStr)
/* Clamp val to the closed interval [min,max]. */ /* Clamp val to the closed interval [min,max]. */
static int16_t clamp(int16_t val, int16_t min, int16_t 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); return val < min ? min : (val > max ? max : val);
} }
@ -822,7 +821,7 @@ int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr* bweStr) {
void WebRtcIsacfixBw_GetBandwidthInfo(BwEstimatorstr* bweStr, void WebRtcIsacfixBw_GetBandwidthInfo(BwEstimatorstr* bweStr,
IsacBandwidthInfo* bwinfo) { IsacBandwidthInfo* bwinfo) {
assert(!bweStr->external_bw_info.in_use); RTC_DCHECK(!bweStr->external_bw_info.in_use);
bwinfo->in_use = 1; bwinfo->in_use = 1;
bwinfo->send_bw_avg = WebRtcIsacfix_GetUplinkBandwidth(bweStr); bwinfo->send_bw_avg = WebRtcIsacfix_GetUplinkBandwidth(bweStr);
bwinfo->send_max_delay_avg = WebRtcIsacfix_GetUplinkMaxDelay(bweStr); bwinfo->send_max_delay_avg = WebRtcIsacfix_GetUplinkMaxDelay(bweStr);

View file

@ -15,9 +15,9 @@
* *
*/ */
#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h" #include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routins.h" #include "webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routins.h"
@ -455,7 +455,7 @@ int WebRtcIsacfix_EncodeImpl(int16_t *in,
while (stream_length < MinBytes) while (stream_length < MinBytes)
{ {
assert(stream_length >= 0); RTC_DCHECK_GE(stream_length, 0);
if (stream_length & 0x0001){ if (stream_length & 0x0001){
ISACenc_obj->bitstr_seed = WEBRTC_SPL_RAND( ISACenc_obj->bitstr_seed ); ISACenc_obj->bitstr_seed = WEBRTC_SPL_RAND( ISACenc_obj->bitstr_seed );
ISACenc_obj->bitstr_obj.stream[stream_length / 2] |= ISACenc_obj->bitstr_obj.stream[stream_length / 2] |=

View file

@ -17,10 +17,10 @@
#include "entropy_coding.h" #include "entropy_coding.h"
#include <arm_neon.h> #include <arm_neon.h>
#include <assert.h>
#include <stddef.h> #include <stddef.h>
#include "signal_processing_library.h" #include "signal_processing_library.h"
#include "webrtc/base/checks.h"
void WebRtcIsacfix_MatrixProduct1Neon(const int16_t matrix0[], void WebRtcIsacfix_MatrixProduct1Neon(const int16_t matrix0[],
const int32_t matrix1[], const int32_t matrix1[],
@ -46,8 +46,8 @@ void WebRtcIsacfix_MatrixProduct1Neon(const int16_t matrix0[],
int32x4_t sum_32x4 = vdupq_n_s32(0); int32x4_t sum_32x4 = vdupq_n_s32(0);
int32x2_t sum_32x2 = vdup_n_s32(0); int32x2_t sum_32x2 = vdup_n_s32(0);
assert(inner_loop_count % 2 == 0); RTC_DCHECK_EQ(0, inner_loop_count % 2);
assert(mid_loop_count % 2 == 0); RTC_DCHECK_EQ(0, mid_loop_count % 2);
if (matrix1_index_init_case != 0 && matrix1_index_factor1 == 1) { if (matrix1_index_init_case != 0 && matrix1_index_factor1 == 1) {
for (j = 0; j < SUBFRAMES; j++) { for (j = 0; j < SUBFRAMES; j++) {

View file

@ -20,11 +20,10 @@
#include "filterbank_internal.h" #include "filterbank_internal.h"
#include <assert.h>
#include "codec.h" #include "codec.h"
#include "filterbank_tables.h" #include "filterbank_tables.h"
#include "settings.h" #include "settings.h"
#include "webrtc/base/checks.h"
// Declare a function pointer. // Declare a function pointer.
AllpassFilter2FixDec16 WebRtcIsacfix_AllpassFilter2FixDec16; AllpassFilter2FixDec16 WebRtcIsacfix_AllpassFilter2FixDec16;
@ -44,7 +43,7 @@ void WebRtcIsacfix_AllpassFilter2FixDec16C(
int32_t a = 0, b = 0; int32_t a = 0, b = 0;
// Assembly file assumption. // Assembly file assumption.
assert(length % 2 == 0); RTC_DCHECK_EQ(0, length % 2);
for (n = 0; n < length; n++) { for (n = 0; n < length; n++) {
// Process channel 1: // Process channel 1:

View file

@ -14,7 +14,8 @@
// C code is at end of this file. // C code is at end of this file.
#include <arm_neon.h> #include <arm_neon.h>
#include <assert.h>
#include "webrtc/base/checks.h"
void WebRtcIsacfix_AllpassFilter2FixDec16Neon( void WebRtcIsacfix_AllpassFilter2FixDec16Neon(
int16_t* data_ch1, // Input and output in channel 1, in Q0 int16_t* data_ch1, // Input and output in channel 1, in Q0
@ -24,7 +25,7 @@ void WebRtcIsacfix_AllpassFilter2FixDec16Neon(
const int length, // Length of the data buffers const int length, // Length of the data buffers
int32_t* filter_state_ch1, // Filter state for channel 1, in Q16 int32_t* filter_state_ch1, // Filter state for channel 1, in Q16
int32_t* filter_state_ch2) { // Filter state for channel 2, 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; int n = 0;
int16x4_t factorv; int16x4_t factorv;
int16x4_t datav; int16x4_t datav;

View file

@ -8,8 +8,7 @@
* be found in the AUTHORS file in the root of the source tree. * 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" #include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
// Autocorrelation function in fixed point. // Autocorrelation function in fixed point.
@ -27,8 +26,8 @@ int WebRtcIsacfix_AutocorrC(int32_t* __restrict r,
int64_t prod = 0; int64_t prod = 0;
// The ARM assembly code assumptoins. // The ARM assembly code assumptoins.
assert(N % 4 == 0); RTC_DCHECK_EQ(0, N % 4);
assert(N >= 8); RTC_DCHECK_GE(N, 8);
// Calculate r[0]. // Calculate r[0].
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {

View file

@ -9,8 +9,8 @@
*/ */
#include <arm_neon.h> #include <arm_neon.h>
#include <assert.h>
#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h" #include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
// Autocorrelation function in fixed point. // Autocorrelation function in fixed point.
@ -26,8 +26,8 @@ int WebRtcIsacfix_AutocorrNeon(int32_t* __restrict r,
int64_t prod = 0; int64_t prod = 0;
int64_t prod_tail = 0; int64_t prod_tail = 0;
assert(n % 4 == 0); RTC_DCHECK_EQ(0, n % 4);
assert(n >= 8); RTC_DCHECK_GE(n, 8);
// Calculate r[0]. // Calculate r[0].
int16x4_t x0_v; int16x4_t x0_v;

View file

@ -17,9 +17,9 @@
#include "webrtc/modules/audio_coding/codecs/isac/fix/include/isacfix.h" #include "webrtc/modules/audio_coding/codecs/isac/fix/include/isacfix.h"
#include <assert.h>
#include <stdlib.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/bandwidth_estimator.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h" #include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h" #include "webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h"
@ -1113,8 +1113,8 @@ int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst,
void WebRtcIsacfix_SetInitialBweBottleneck(ISACFIX_MainStruct* ISAC_main_inst, void WebRtcIsacfix_SetInitialBweBottleneck(ISACFIX_MainStruct* ISAC_main_inst,
int bottleneck_bits_per_second) { int bottleneck_bits_per_second) {
ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst; ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst;
assert(bottleneck_bits_per_second >= 10000 && RTC_DCHECK_GE(bottleneck_bits_per_second, 10000);
bottleneck_bits_per_second <= 32000); RTC_DCHECK_LE(bottleneck_bits_per_second, 32000);
inst->bwestimator_obj.sendBwAvg = ((uint32_t)bottleneck_bits_per_second) << 7; inst->bwestimator_obj.sendBwAvg = ((uint32_t)bottleneck_bits_per_second) << 7;
} }
@ -1539,13 +1539,13 @@ void WebRtcIsacfix_version(char *version)
void WebRtcIsacfix_GetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, void WebRtcIsacfix_GetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
IsacBandwidthInfo* bwinfo) { IsacBandwidthInfo* bwinfo) {
ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst; 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); WebRtcIsacfixBw_GetBandwidthInfo(&inst->bwestimator_obj, bwinfo);
} }
void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst, void WebRtcIsacfix_SetBandwidthInfo(ISACFIX_MainStruct* ISAC_main_inst,
const IsacBandwidthInfo* bwinfo) { const IsacBandwidthInfo* bwinfo) {
ISACFIX_SubStruct* inst = (ISACFIX_SubStruct*)ISAC_main_inst; 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); WebRtcIsacfixBw_SetBandwidthInfo(&inst->bwestimator_obj, bwinfo);
} }

View file

@ -23,6 +23,7 @@
'<(webrtc_root)', '<(webrtc_root)',
], ],
'sources': [ 'sources': [
'empty.cc', # force build system to use C++ linker
'./main/test/simpleKenny.c', './main/test/simpleKenny.c',
'./main/util/utility.c', './main/util/utility.c',
], ],

View file

@ -19,8 +19,8 @@
#include "bandwidth_estimator.h" #include "bandwidth_estimator.h"
#include "settings.h" #include "settings.h"
#include "isac.h" #include "isac.h"
#include "webrtc/base/checks.h"
#include <assert.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
@ -159,7 +159,7 @@ int16_t WebRtcIsac_UpdateBandwidthEstimator(
int immediate_set = 0; int immediate_set = 0;
int num_pkts_expected; 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 // We have to adjust the header-rate if the first packet has a
// frame-size different than the initialized value. // frame-size different than the initialized value.
@ -514,7 +514,7 @@ int16_t WebRtcIsac_UpdateUplinkBwImpl(
int16_t index, int16_t index,
enum IsacSamplingRate encoderSamplingFreq) 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)) if((index < 0) || (index > 23))
{ {
@ -572,7 +572,7 @@ int16_t WebRtcIsac_UpdateUplinkJitter(
BwEstimatorstr* bwest_str, BwEstimatorstr* bwest_str,
int32_t index) 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)) if((index < 0) || (index > 23))
{ {
@ -711,7 +711,7 @@ int32_t WebRtcIsac_GetDownlinkBandwidth( const BwEstimatorstr *bwest_str)
float jitter_sign; float jitter_sign;
float bw_adjust; 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 */ /* create a value between -1.0 and 1.0 indicating "average sign" of jitter */
jitter_sign = bwest_str->rec_jitter_short_term / jitter_sign = bwest_str->rec_jitter_short_term /
@ -741,7 +741,7 @@ WebRtcIsac_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str)
{ {
int32_t rec_max_delay; 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); rec_max_delay = (int32_t)(bwest_str->rec_max_delay);
@ -759,7 +759,7 @@ WebRtcIsac_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str)
/* Clamp val to the closed interval [min,max]. */ /* Clamp val to the closed interval [min,max]. */
static int32_t clamp(int32_t val, int32_t min, int32_t 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); return val < min ? min : (val > max ? max : val);
} }
@ -778,7 +778,7 @@ int32_t WebRtcIsac_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str) {
void WebRtcIsacBw_GetBandwidthInfo(BwEstimatorstr* bwest_str, void WebRtcIsacBw_GetBandwidthInfo(BwEstimatorstr* bwest_str,
enum IsacSamplingRate decoder_sample_rate_hz, enum IsacSamplingRate decoder_sample_rate_hz,
IsacBandwidthInfo* bwinfo) { IsacBandwidthInfo* bwinfo) {
assert(!bwest_str->external_bw_info.in_use); RTC_DCHECK(!bwest_str->external_bw_info.in_use);
bwinfo->in_use = 1; bwinfo->in_use = 1;
bwinfo->send_bw_avg = WebRtcIsac_GetUplinkBandwidth(bwest_str); bwinfo->send_bw_avg = WebRtcIsac_GetUplinkBandwidth(bwest_str);
bwinfo->send_max_delay_avg = WebRtcIsac_GetUplinkMaxDelay(bwest_str); bwinfo->send_max_delay_avg = WebRtcIsac_GetUplinkMaxDelay(bwest_str);

View file

@ -17,12 +17,12 @@
#include "webrtc/modules/audio_coding/codecs/isac/main/include/isac.h" #include "webrtc/modules/audio_coding/codecs/isac/main/include/isac.h"
#include <assert.h>
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.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/bandwidth_estimator.h"
#include "webrtc/modules/audio_coding/codecs/isac/main/source/codec.h" #include "webrtc/modules/audio_coding/codecs/isac/main/source/codec.h"
@ -1539,8 +1539,8 @@ int16_t WebRtcIsac_Control(ISACStruct* ISAC_main_inst,
void WebRtcIsac_SetInitialBweBottleneck(ISACStruct* ISAC_main_inst, void WebRtcIsac_SetInitialBweBottleneck(ISACStruct* ISAC_main_inst,
int bottleneck_bits_per_second) { int bottleneck_bits_per_second) {
ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst;
assert(bottleneck_bits_per_second >= 10000 && RTC_DCHECK_GE(bottleneck_bits_per_second, 10000);
bottleneck_bits_per_second <= 32000); RTC_DCHECK_LE(bottleneck_bits_per_second, 32000);
instISAC->bwestimator_obj.send_bw_avg = (float)bottleneck_bits_per_second; instISAC->bwestimator_obj.send_bw_avg = (float)bottleneck_bits_per_second;
} }
@ -2341,7 +2341,7 @@ uint16_t WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst) {
void WebRtcIsac_GetBandwidthInfo(ISACStruct* inst, void WebRtcIsac_GetBandwidthInfo(ISACStruct* inst,
IsacBandwidthInfo* bwinfo) { IsacBandwidthInfo* bwinfo) {
ISACMainStruct* instISAC = (ISACMainStruct*)inst; 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, WebRtcIsacBw_GetBandwidthInfo(&instISAC->bwestimator_obj,
instISAC->decoderSamplingRateKHz, bwinfo); instISAC->decoderSamplingRateKHz, bwinfo);
} }
@ -2349,15 +2349,15 @@ void WebRtcIsac_GetBandwidthInfo(ISACStruct* inst,
void WebRtcIsac_SetBandwidthInfo(ISACStruct* inst, void WebRtcIsac_SetBandwidthInfo(ISACStruct* inst,
const IsacBandwidthInfo* bwinfo) { const IsacBandwidthInfo* bwinfo) {
ISACMainStruct* instISAC = (ISACMainStruct*)inst; 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); WebRtcIsacBw_SetBandwidthInfo(&instISAC->bwestimator_obj, bwinfo);
} }
void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst, void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst,
int sample_rate_hz) { int sample_rate_hz) {
ISACMainStruct* instISAC = (ISACMainStruct*)inst; ISACMainStruct* instISAC = (ISACMainStruct*)inst;
assert(instISAC->initFlag & BIT_MASK_DEC_INIT); RTC_DCHECK_NE(0, instISAC->initFlag & BIT_MASK_DEC_INIT);
assert(!(instISAC->initFlag & BIT_MASK_ENC_INIT)); RTC_DCHECK(!(instISAC->initFlag & BIT_MASK_ENC_INIT));
assert(sample_rate_hz == 16000 || sample_rate_hz == 32000); RTC_DCHECK(sample_rate_hz == 16000 || sample_rate_hz == 32000);
instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000; instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000;
} }

View file

@ -19,12 +19,13 @@
#include "webrtc/modules/audio_processing/agc/legacy/analog_agc.h" #include "webrtc/modules/audio_processing/agc/legacy/analog_agc.h"
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef WEBRTC_AGC_DEBUG_DUMP #ifdef WEBRTC_AGC_DEBUG_DUMP
#include <stdio.h> #include <stdio.h>
#endif #endif
#include "webrtc/base/checks.h"
/* The slope of in Q13*/ /* The slope of in Q13*/
static const int16_t kSlope1[8] = {21793, 12517, 7189, 4129, static const int16_t kSlope1[8] = {21793, 12517, 7189, 4129,
2372, 1362, 472, 78}; 2372, 1362, 472, 78};
@ -155,14 +156,14 @@ int WebRtcAgc_AddMic(void* state,
if (stt->micVol > stt->maxAnalog) { if (stt->micVol > stt->maxAnalog) {
/* |maxLevel| is strictly >= |micVol|, so this condition should be /* |maxLevel| is strictly >= |micVol|, so this condition should be
* satisfied here, ensuring there is no divide-by-zero. */ * satisfied here, ensuring there is no divide-by-zero. */
assert(stt->maxLevel > stt->maxAnalog); RTC_DCHECK_GT(stt->maxLevel, stt->maxAnalog);
/* Q1 */ /* Q1 */
tmp16 = (int16_t)(stt->micVol - stt->maxAnalog); tmp16 = (int16_t)(stt->micVol - stt->maxAnalog);
tmp32 = (GAIN_TBL_LEN - 1) * tmp16; tmp32 = (GAIN_TBL_LEN - 1) * tmp16;
tmp16 = (int16_t)(stt->maxLevel - stt->maxAnalog); tmp16 = (int16_t)(stt->maxLevel - stt->maxAnalog);
targetGainIdx = tmp32 / tmp16; targetGainIdx = tmp32 / tmp16;
assert(targetGainIdx < GAIN_TBL_LEN); RTC_DCHECK_LT(targetGainIdx, GAIN_TBL_LEN);
/* Increment through the table towards the target gain. /* Increment through the table towards the target gain.
* If micVol drops below maxAnalog, we allow the gain * If micVol drops below maxAnalog, we allow the gain

View file

@ -14,12 +14,12 @@
#include "webrtc/modules/audio_processing/agc/legacy/digital_agc.h" #include "webrtc/modules/audio_processing/agc/legacy/digital_agc.h"
#include <assert.h>
#include <string.h> #include <string.h>
#ifdef WEBRTC_AGC_DEBUG_DUMP #ifdef WEBRTC_AGC_DEBUG_DUMP
#include <stdio.h> #include <stdio.h>
#endif #endif
#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_processing/agc/legacy/gain_control.h" #include "webrtc/modules/audio_processing/agc/legacy/gain_control.h"
// To generate the gaintable, copy&paste the following lines to a Matlab window: // To generate the gaintable, copy&paste the following lines to a Matlab window:
@ -109,7 +109,7 @@ int32_t WebRtcAgc_CalculateGainTable(int32_t* gainTable, // Q16
diffGain = diffGain =
WebRtcSpl_DivW32W16ResW16(tmp32no1 + (kCompRatio >> 1), kCompRatio); WebRtcSpl_DivW32W16ResW16(tmp32no1 + (kCompRatio >> 1), kCompRatio);
if (diffGain < 0 || diffGain >= kGenFuncTableSize) { if (diffGain < 0 || diffGain >= kGenFuncTableSize) {
assert(0); RTC_DCHECK(0);
return -1; return -1;
} }
@ -268,7 +268,7 @@ int32_t WebRtcAgc_InitDigital(DigitalAgc* stt, int16_t agcMode) {
int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* stt, int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* stt,
const int16_t* in_far, const int16_t* in_far,
size_t nrSamples) { size_t nrSamples) {
assert(stt != NULL); RTC_DCHECK(stt);
// VAD for far end // VAD for far end
WebRtcAgc_ProcessVad(&stt->vadFarend, in_far, nrSamples); WebRtcAgc_ProcessVad(&stt->vadFarend, in_far, nrSamples);

View file

@ -8,11 +8,11 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <assert.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "webrtc/base/checks.h"
#include "webrtc/common_audio/fft4g.h" #include "webrtc/common_audio/fft4g.h"
#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
#include "webrtc/modules/audio_processing/ns/noise_suppression.h" #include "webrtc/modules/audio_processing/ns/noise_suppression.h"
@ -857,7 +857,7 @@ static void UpdateBuffer(const float* frame,
size_t frame_length, size_t frame_length,
size_t buffer_length, size_t buffer_length,
float* buffer) { float* buffer) {
assert(buffer_length < 2 * frame_length); RTC_DCHECK_LT(buffer_length, 2 * frame_length);
memcpy(buffer, memcpy(buffer,
buffer + frame_length, buffer + frame_length,
@ -893,7 +893,7 @@ static void FFT(NoiseSuppressionC* self,
float* magn) { float* magn) {
size_t i; 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); WebRtc_rdft(time_data_length, 1, time_data, self->ip, self->wfft);
@ -929,7 +929,7 @@ static void IFFT(NoiseSuppressionC* self,
float* time_data) { float* time_data) {
size_t i; 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[0] = real[0];
time_data[1] = real[magnitude_length - 1]; time_data[1] = real[magnitude_length - 1];
@ -1062,7 +1062,7 @@ void WebRtcNs_AnalyzeCore(NoiseSuppressionC* self, const float* speechFrame) {
float parametric_num = 0.0; float parametric_num = 0.0;
// Check that initiation has been done. // Check that initiation has been done.
assert(self->initFlag == 1); RTC_DCHECK_EQ(1, self->initFlag);
updateParsFlag = self->modelUpdatePars[0]; updateParsFlag = self->modelUpdatePars[0];
// Update analysis buffer for L band. // Update analysis buffer for L band.
@ -1206,8 +1206,8 @@ void WebRtcNs_ProcessCore(NoiseSuppressionC* self,
float sumMagnAnalyze, sumMagnProcess; float sumMagnAnalyze, sumMagnProcess;
// Check that initiation has been done. // Check that initiation has been done.
assert(self->initFlag == 1); RTC_DCHECK_EQ(1, self->initFlag);
assert((num_bands - 1) <= NUM_HIGH_BANDS_MAX); RTC_DCHECK_LE(num_bands - 1, NUM_HIGH_BANDS_MAX);
const float* const* speechFrameHB = NULL; const float* const* speechFrameHB = NULL;
float* const* outFrameHB = NULL; float* const* outFrameHB = NULL;

View file

@ -10,11 +10,11 @@
#include "webrtc/modules/audio_processing/ns/noise_suppression_x.h" #include "webrtc/modules/audio_processing/ns/noise_suppression_x.h"
#include <assert.h>
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "webrtc/base/checks.h"
#include "webrtc/common_audio/signal_processing/include/real_fft.h" #include "webrtc/common_audio/signal_processing/include/real_fft.h"
#include "webrtc/modules/audio_processing/ns/nsx_core.h" #include "webrtc/modules/audio_processing/ns/nsx_core.h"
#include "webrtc/system_wrappers/include/cpu_features_wrapper.h" #include "webrtc/system_wrappers/include/cpu_features_wrapper.h"
@ -344,8 +344,8 @@ static void NoiseEstimationC(NoiseSuppressionFixedC* inst,
size_t i, s, offset; size_t i, s, offset;
tabind = inst->stages - inst->normData; tabind = inst->stages - inst->normData;
assert(tabind < 9); RTC_DCHECK_LT(tabind, 9);
assert(tabind > -9); RTC_DCHECK_GT(tabind, -9);
if (tabind < 0) { if (tabind < 0) {
logval = -WebRtcNsx_kLogTable[-tabind]; logval = -WebRtcNsx_kLogTable[-tabind];
} else { } else {
@ -362,7 +362,7 @@ static void NoiseEstimationC(NoiseSuppressionFixedC* inst,
frac = (int16_t)((((uint32_t)magn[i] << zeros) frac = (int16_t)((((uint32_t)magn[i] << zeros)
& 0x7FFFFFFF) >> 23); & 0x7FFFFFFF) >> 23);
// log2(magn(i)) // log2(magn(i))
assert(frac < 256); RTC_DCHECK_LT(frac, 256);
log2 = (int16_t)(((31 - zeros) << 8) log2 = (int16_t)(((31 - zeros) << 8)
+ WebRtcNsx_kLogTableFrac[frac]); + WebRtcNsx_kLogTableFrac[frac]);
// log2(magn(i))*log(2) // log2(magn(i))*log(2)
@ -380,7 +380,7 @@ static void NoiseEstimationC(NoiseSuppressionFixedC* inst,
// Get counter values from state // Get counter values from state
counter = inst->noiseEstCounter[s]; counter = inst->noiseEstCounter[s];
assert(counter < 201); RTC_DCHECK_LT(counter, 201);
countDiv = WebRtcNsx_kCounterDiv[counter]; countDiv = WebRtcNsx_kCounterDiv[counter];
countProd = (int16_t)(counter * countDiv); countProd = (int16_t)(counter * countDiv);
@ -543,7 +543,7 @@ static void NormalizeRealBufferC(NoiseSuppressionFixedC* inst,
const int16_t* in, const int16_t* in,
int16_t* out) { int16_t* out) {
size_t i = 0; size_t i = 0;
assert(inst->normData >= 0); RTC_DCHECK_GE(inst->normData, 0);
for (i = 0; i < inst->anaLen; ++i) { for (i = 0; i < inst->anaLen; ++i) {
out[i] = in[i] << inst->normData; // Q(normData) out[i] = in[i] << inst->normData; // Q(normData)
} }
@ -594,8 +594,8 @@ void WebRtcNsx_CalcParametricNoiseEstimate(NoiseSuppressionFixedC* inst,
// Use pink noise estimate // Use pink noise estimate
// noise_estimate = 2^(pinkNoiseNumerator + pinkNoiseExp * log2(j)) // noise_estimate = 2^(pinkNoiseNumerator + pinkNoiseExp * log2(j))
assert(freq_index >= 0); RTC_DCHECK_GE(freq_index, 0);
assert(freq_index < 129); RTC_DCHECK_LT(freq_index, 129);
tmp32no2 = (pink_noise_exp_avg * kLogIndex[freq_index]) >> 15; // Q11 tmp32no2 = (pink_noise_exp_avg * kLogIndex[freq_index]) >> 15; // Q11
tmp32no1 = pink_noise_num_avg - tmp32no2; // Q11 tmp32no1 = pink_noise_num_avg - tmp32no2; // Q11
@ -1038,7 +1038,7 @@ void WebRtcNsx_ComputeSpectralFlatness(NoiseSuppressionFixedC* inst,
frac = (int16_t)(((uint32_t)((uint32_t)(magn[i]) << zeros) frac = (int16_t)(((uint32_t)((uint32_t)(magn[i]) << zeros)
& 0x7FFFFFFF) >> 23); & 0x7FFFFFFF) >> 23);
// log2(magn(i)) // log2(magn(i))
assert(frac < 256); RTC_DCHECK_LT(frac, 256);
tmpU32 = (uint32_t)(((31 - zeros) << 8) tmpU32 = (uint32_t)(((31 - zeros) << 8)
+ WebRtcNsx_kLogTableFrac[frac]); // Q8 + WebRtcNsx_kLogTableFrac[frac]); // Q8
avgSpectralFlatnessNum += tmpU32; // Q8 avgSpectralFlatnessNum += tmpU32; // Q8
@ -1053,7 +1053,7 @@ void WebRtcNsx_ComputeSpectralFlatness(NoiseSuppressionFixedC* inst,
zeros = WebRtcSpl_NormU32(avgSpectralFlatnessDen); zeros = WebRtcSpl_NormU32(avgSpectralFlatnessDen);
frac = (int16_t)(((avgSpectralFlatnessDen << zeros) & 0x7FFFFFFF) >> 23); frac = (int16_t)(((avgSpectralFlatnessDen << zeros) & 0x7FFFFFFF) >> 23);
// log2(avgSpectralFlatnessDen) // log2(avgSpectralFlatnessDen)
assert(frac < 256); RTC_DCHECK_LT(frac, 256);
tmp32 = (int32_t)(((31 - zeros) << 8) + WebRtcNsx_kLogTableFrac[frac]); // Q8 tmp32 = (int32_t)(((31 - zeros) << 8) + WebRtcNsx_kLogTableFrac[frac]); // Q8
logCurSpectralFlatness = (int32_t)avgSpectralFlatnessNum; logCurSpectralFlatness = (int32_t)avgSpectralFlatnessNum;
logCurSpectralFlatness += ((int32_t)(inst->stages - 1) << (inst->stages + 7)); // Q(8+stages-1) logCurSpectralFlatness += ((int32_t)(inst->stages - 1) << (inst->stages + 7)); // Q(8+stages-1)
@ -1286,7 +1286,7 @@ void WebRtcNsx_DataAnalysis(NoiseSuppressionFixedC* inst,
frac = (int16_t)((((uint32_t)magnU16[inst->anaLen2] << zeros) & frac = (int16_t)((((uint32_t)magnU16[inst->anaLen2] << zeros) &
0x7FFFFFFF) >> 23); // Q8 0x7FFFFFFF) >> 23); // Q8
// log2(magnU16(i)) in Q8 // log2(magnU16(i)) in Q8
assert(frac < 256); RTC_DCHECK_LT(frac, 256);
log2 = (int16_t)(((31 - zeros) << 8) + WebRtcNsx_kLogTableFrac[frac]); log2 = (int16_t)(((31 - zeros) << 8) + WebRtcNsx_kLogTableFrac[frac]);
} }
@ -1320,7 +1320,7 @@ void WebRtcNsx_DataAnalysis(NoiseSuppressionFixedC* inst,
frac = (int16_t)((((uint32_t)magnU16[i] << zeros) & frac = (int16_t)((((uint32_t)magnU16[i] << zeros) &
0x7FFFFFFF) >> 23); 0x7FFFFFFF) >> 23);
// log2(magnU16(i)) in Q8 // log2(magnU16(i)) in Q8
assert(frac < 256); RTC_DCHECK_LT(frac, 256);
log2 = (int16_t)(((31 - zeros) << 8) log2 = (int16_t)(((31 - zeros) << 8)
+ WebRtcNsx_kLogTableFrac[frac]); + WebRtcNsx_kLogTableFrac[frac]);
} }
@ -1347,14 +1347,14 @@ void WebRtcNsx_DataAnalysis(NoiseSuppressionFixedC* inst,
// Shift to same Q-domain as whiteNoiseLevel // Shift to same Q-domain as whiteNoiseLevel
tmpU32no1 >>= right_shifts_in_magnU16; tmpU32no1 >>= right_shifts_in_magnU16;
// This operation is safe from wrap around as long as END_STARTUP_SHORT < 128 // 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) inst->whiteNoiseLevel += tmpU32no1; // Q(minNorm-stages)
// Estimate Pink noise parameters // Estimate Pink noise parameters
// Denominator used in both parameter estimates. // Denominator used in both parameter estimates.
// The value is only dependent on the size of the frequency band (kStartBand) // The value is only dependent on the size of the frequency band (kStartBand)
// and to reduce computational complexity stored in a table (kDeterminantEstMatrix[]) // and to reduce computational complexity stored in a table (kDeterminantEstMatrix[])
assert(kStartBand < 66); RTC_DCHECK_LT(kStartBand, 66);
matrix_determinant = kDeterminantEstMatrix[kStartBand]; // Q0 matrix_determinant = kDeterminantEstMatrix[kStartBand]; // Q0
sum_log_i = kSumLogIndex[kStartBand]; // Q5 sum_log_i = kSumLogIndex[kStartBand]; // Q5
sum_log_i_square = kSumSquareLogIndex[kStartBand]; // Q2 sum_log_i_square = kSumSquareLogIndex[kStartBand]; // Q2
@ -1469,13 +1469,13 @@ void WebRtcNsx_DataSynthesis(NoiseSuppressionFixedC* inst, short* outFrame) {
inst->energyIn >>= 8 + scaleEnergyOut - inst->scaleEnergyIn; inst->energyIn >>= 8 + scaleEnergyOut - inst->scaleEnergyIn;
} }
assert(inst->energyIn > 0); RTC_DCHECK_GT(inst->energyIn, 0);
energyRatio = (energyOut + inst->energyIn / 2) / inst->energyIn; // Q8 energyRatio = (energyOut + inst->energyIn / 2) / inst->energyIn; // Q8
// Limit the ratio to [0, 1] in Q8, i.e., [0, 256] // Limit the ratio to [0, 1] in Q8, i.e., [0, 256]
energyRatio = WEBRTC_SPL_SAT(256, energyRatio, 0); energyRatio = WEBRTC_SPL_SAT(256, energyRatio, 0);
// all done in lookup tables now // all done in lookup tables now
assert(energyRatio < 257); RTC_DCHECK_LT(energyRatio, 257);
gainFactor1 = kFactor1Table[energyRatio]; // Q8 gainFactor1 = kFactor1Table[energyRatio]; // Q8
gainFactor2 = inst->factor2Table[energyRatio]; // Q8 gainFactor2 = inst->factor2Table[energyRatio]; // Q8
@ -1534,24 +1534,24 @@ void WebRtcNsx_ProcessCore(NoiseSuppressionFixedC* inst,
int q_domain_to_use = 0; int q_domain_to_use = 0;
// Code for ARMv7-Neon platform assumes the following: // Code for ARMv7-Neon platform assumes the following:
assert(inst->anaLen > 0); RTC_DCHECK_GT(inst->anaLen, 0);
assert(inst->anaLen2 > 0); RTC_DCHECK_GT(inst->anaLen2, 0);
assert(inst->anaLen % 16 == 0); RTC_DCHECK_EQ(0, inst->anaLen % 16);
assert(inst->anaLen2 % 8 == 0); RTC_DCHECK_EQ(0, inst->anaLen2 % 8);
assert(inst->blockLen10ms > 0); RTC_DCHECK_GT(inst->blockLen10ms, 0);
assert(inst->blockLen10ms % 16 == 0); RTC_DCHECK_EQ(0, inst->blockLen10ms % 16);
assert(inst->magnLen == inst->anaLen2 + 1); RTC_DCHECK_EQ(inst->magnLen, inst->anaLen2 + 1);
#ifdef NS_FILEDEBUG #ifdef NS_FILEDEBUG
if (fwrite(spframe, sizeof(short), if (fwrite(spframe, sizeof(short),
inst->blockLen10ms, inst->infile) != inst->blockLen10ms) { inst->blockLen10ms, inst->infile) != inst->blockLen10ms) {
assert(false); RTC_DCHECK(false);
} }
#endif #endif
// Check that initialization has been done // Check that initialization has been done
assert(inst->initFlag == 1); RTC_DCHECK_EQ(1, inst->initFlag);
assert((num_bands - 1) <= NUM_HIGH_BANDS_MAX); RTC_DCHECK_LE(num_bands - 1, NUM_HIGH_BANDS_MAX);
const short* const* speechFrameHB = NULL; const short* const* speechFrameHB = NULL;
short* const* outFrameHB = NULL; short* const* outFrameHB = NULL;
@ -1989,7 +1989,7 @@ void WebRtcNsx_ProcessCore(NoiseSuppressionFixedC* inst,
//gain filter //gain filter
tmpU32no1 = inst->overdrive + ((priorSnr + 8192) >> 14); // Q8 tmpU32no1 = inst->overdrive + ((priorSnr + 8192) >> 14); // Q8
assert(inst->overdrive > 0); RTC_DCHECK_GT(inst->overdrive, 0);
tmpU16no1 = (priorSnr + tmpU32no1 / 2) / tmpU32no1; // Q14 tmpU16no1 = (priorSnr + tmpU32no1 / 2) / tmpU32no1; // Q14
inst->noiseSupFilter[i] = WEBRTC_SPL_SAT(16384, tmpU16no1, inst->denoiseBound); // 16384 = Q14(1.0) // Q14 inst->noiseSupFilter[i] = WEBRTC_SPL_SAT(16384, tmpU16no1, inst->denoiseBound); // 16384 = Q14(1.0) // Q14
@ -2025,7 +2025,7 @@ void WebRtcNsx_ProcessCore(NoiseSuppressionFixedC* inst,
#ifdef NS_FILEDEBUG #ifdef NS_FILEDEBUG
if (fwrite(outframe, sizeof(short), if (fwrite(outframe, sizeof(short),
inst->blockLen10ms, inst->outfile) != inst->blockLen10ms) { inst->blockLen10ms, inst->outfile) != inst->blockLen10ms) {
assert(false); RTC_DCHECK(false);
} }
#endif #endif
@ -2052,7 +2052,7 @@ void WebRtcNsx_ProcessCore(NoiseSuppressionFixedC* inst,
tmpU16no1 += nonSpeechProbFinal[i]; // Q8 tmpU16no1 += nonSpeechProbFinal[i]; // Q8
tmpU32no1 += (uint32_t)(inst->noiseSupFilter[i]); // Q14 tmpU32no1 += (uint32_t)(inst->noiseSupFilter[i]); // Q14
} }
assert(inst->stages >= 7); RTC_DCHECK_GE(inst->stages, 7);
avgProbSpeechHB = (4096 - (tmpU16no1 >> (inst->stages - 7))); // Q12 avgProbSpeechHB = (4096 - (tmpU16no1 >> (inst->stages - 7))); // Q12
avgFilterGainHB = (int16_t)(tmpU32no1 >> (inst->stages - 3)); // Q14 avgFilterGainHB = (int16_t)(tmpU32no1 >> (inst->stages - 3)); // Q14

View file

@ -8,8 +8,7 @@
* be found in the AUTHORS file in the root of the source tree. * 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/noise_suppression_x.h"
#include "webrtc/modules/audio_processing/ns/nsx_core.h" #include "webrtc/modules/audio_processing/ns/nsx_core.h"
#include "webrtc/modules/audio_processing/ns/nsx_defines.h" #include "webrtc/modules/audio_processing/ns/nsx_defines.h"
@ -149,7 +148,7 @@ void WebRtcNsx_SpeechNoiseProb(NoiseSuppressionFixedC* inst,
if (inst->featureSpecDiff) { if (inst->featureSpecDiff) {
normTmp = WEBRTC_SPL_MIN(20 - inst->stages, normTmp = WEBRTC_SPL_MIN(20 - inst->stages,
WebRtcSpl_NormU32(inst->featureSpecDiff)); WebRtcSpl_NormU32(inst->featureSpecDiff));
assert(normTmp >= 0); RTC_DCHECK_GE(normTmp, 0);
tmpU32no1 = inst->featureSpecDiff << normTmp; // Q(normTmp-2*stages) tmpU32no1 = inst->featureSpecDiff << normTmp; // Q(normTmp-2*stages)
tmpU32no2 = inst->timeAvgMagnEnergy >> (20 - inst->stages - normTmp); tmpU32no2 = inst->timeAvgMagnEnergy >> (20 - inst->stages - normTmp);
if (tmpU32no2 > 0) { if (tmpU32no2 > 0) {

View file

@ -8,9 +8,9 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <assert.h>
#include <string.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/noise_suppression_x.h"
#include "webrtc/modules/audio_processing/ns/nsx_core.h" #include "webrtc/modules/audio_processing/ns/nsx_core.h"
@ -184,7 +184,7 @@ void WebRtcNsx_SpeechNoiseProb(NoiseSuppressionFixedC* inst,
if (inst->featureSpecDiff) { if (inst->featureSpecDiff) {
normTmp = WEBRTC_SPL_MIN(20 - inst->stages, normTmp = WEBRTC_SPL_MIN(20 - inst->stages,
WebRtcSpl_NormU32(inst->featureSpecDiff)); WebRtcSpl_NormU32(inst->featureSpecDiff));
assert(normTmp >= 0); RTC_DCHECK_GE(normTmp, 0);
tmpU32no1 = inst->featureSpecDiff << normTmp; // Q(normTmp-2*stages) tmpU32no1 = inst->featureSpecDiff << normTmp; // Q(normTmp-2*stages)
tmpU32no2 = inst->timeAvgMagnEnergy >> (20 - inst->stages - normTmp); tmpU32no2 = inst->timeAvgMagnEnergy >> (20 - inst->stages - normTmp);
if (tmpU32no2 > 0) { if (tmpU32no2 > 0) {

View file

@ -11,7 +11,8 @@
#include "webrtc/modules/audio_processing/ns/nsx_core.h" #include "webrtc/modules/audio_processing/ns/nsx_core.h"
#include <arm_neon.h> #include <arm_neon.h>
#include <assert.h>
#include "webrtc/base/checks.h"
// Constants to compensate for shifting signal log(2^shifts). // Constants to compensate for shifting signal log(2^shifts).
const int16_t WebRtcNsx_kLogTable[9] = { const int16_t WebRtcNsx_kLogTable[9] = {
@ -144,8 +145,8 @@ void WebRtcNsx_NoiseEstimationNeon(NoiseSuppressionFixedC* inst,
size_t i, s, offset; size_t i, s, offset;
tabind = inst->stages - inst->normData; tabind = inst->stages - inst->normData;
assert(tabind < 9); RTC_DCHECK_LT(tabind, 9);
assert(tabind > -9); RTC_DCHECK_GT(tabind, -9);
if (tabind < 0) { if (tabind < 0) {
logval = -WebRtcNsx_kLogTable[-tabind]; logval = -WebRtcNsx_kLogTable[-tabind];
} else { } else {
@ -163,7 +164,7 @@ void WebRtcNsx_NoiseEstimationNeon(NoiseSuppressionFixedC* inst,
zeros = WebRtcSpl_NormU32((uint32_t)magn[i]); zeros = WebRtcSpl_NormU32((uint32_t)magn[i]);
frac = (int16_t)((((uint32_t)magn[i] << zeros) frac = (int16_t)((((uint32_t)magn[i] << zeros)
& 0x7FFFFFFF) >> 23); & 0x7FFFFFFF) >> 23);
assert(frac < 256); RTC_DCHECK_LT(frac, 256);
// log2(magn(i)) // log2(magn(i))
log2 = (int16_t)(((31 - zeros) << 8) log2 = (int16_t)(((31 - zeros) << 8)
+ WebRtcNsx_kLogTableFrac[frac]); + WebRtcNsx_kLogTableFrac[frac]);
@ -190,7 +191,7 @@ void WebRtcNsx_NoiseEstimationNeon(NoiseSuppressionFixedC* inst,
// Get counter values from state // Get counter values from state
counter = inst->noiseEstCounter[s]; counter = inst->noiseEstCounter[s];
assert(counter < 201); RTC_DCHECK_LT(counter, 201);
countDiv = WebRtcNsx_kCounterDiv[counter]; countDiv = WebRtcNsx_kCounterDiv[counter];
countProd = (int16_t)(counter * countDiv); countProd = (int16_t)(counter * countDiv);
@ -354,8 +355,8 @@ void WebRtcNsx_NoiseEstimationNeon(NoiseSuppressionFixedC* inst,
// Filter the data in the frequency domain, and create spectrum. // Filter the data in the frequency domain, and create spectrum.
void WebRtcNsx_PrepareSpectrumNeon(NoiseSuppressionFixedC* inst, void WebRtcNsx_PrepareSpectrumNeon(NoiseSuppressionFixedC* inst,
int16_t* freq_buf) { int16_t* freq_buf) {
assert(inst->magnLen % 8 == 1); RTC_DCHECK_EQ(1, inst->magnLen % 8);
assert(inst->anaLen2 % 16 == 0); RTC_DCHECK_EQ(0, inst->anaLen2 % 16);
// (1) Filtering. // (1) Filtering.
@ -445,8 +446,8 @@ void WebRtcNsx_PrepareSpectrumNeon(NoiseSuppressionFixedC* inst,
void WebRtcNsx_SynthesisUpdateNeon(NoiseSuppressionFixedC* inst, void WebRtcNsx_SynthesisUpdateNeon(NoiseSuppressionFixedC* inst,
int16_t* out_frame, int16_t* out_frame,
int16_t gain_factor) { int16_t gain_factor) {
assert(inst->anaLen % 16 == 0); RTC_DCHECK_EQ(0, inst->anaLen % 16);
assert(inst->blockLen10ms % 16 == 0); RTC_DCHECK_EQ(0, inst->blockLen10ms % 16);
int16_t* preal_start = inst->real; int16_t* preal_start = inst->real;
const int16_t* pwindow = inst->window; const int16_t* pwindow = inst->window;
@ -537,8 +538,8 @@ void WebRtcNsx_SynthesisUpdateNeon(NoiseSuppressionFixedC* inst,
void WebRtcNsx_AnalysisUpdateNeon(NoiseSuppressionFixedC* inst, void WebRtcNsx_AnalysisUpdateNeon(NoiseSuppressionFixedC* inst,
int16_t* out, int16_t* out,
int16_t* new_speech) { int16_t* new_speech) {
assert(inst->blockLen10ms % 16 == 0); RTC_DCHECK_EQ(0, inst->blockLen10ms % 16);
assert(inst->anaLen % 16 == 0); RTC_DCHECK_EQ(0, inst->anaLen % 16);
// For lower band update analysis buffer. // For lower band update analysis buffer.
// memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms, // memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,

View file

@ -10,7 +10,6 @@
#include "webrtc/system_wrappers/source/data_log_c_helpers_unittest.h" #include "webrtc/system_wrappers/source/data_log_c_helpers_unittest.h"
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>