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:
0
webrtc/modules/audio_coding/codecs/isac/empty.cc
Normal file
0
webrtc/modules/audio_coding/codecs/isac/empty.cc
Normal file
@ -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 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
|
||||
|
||||
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 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bweStr,
|
||||
{
|
||||
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 @@ uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bweStr)
|
||||
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 WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bweStr)
|
||||
{
|
||||
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 @@ int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bweStr)
|
||||
|
||||
/* 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 @@ int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr* bweStr) {
|
||||
|
||||
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);
|
||||
|
@ -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 @@ int WebRtcIsacfix_EncodeImpl(int16_t *in,
|
||||
|
||||
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] |=
|
||||
|
@ -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 @@ void WebRtcIsacfix_MatrixProduct1Neon(const int16_t matrix0[],
|
||||
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++) {
|
||||
|
@ -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 @@ void WebRtcIsacfix_AllpassFilter2FixDec16C(
|
||||
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:
|
||||
|
@ -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 @@ void WebRtcIsacfix_AllpassFilter2FixDec16Neon(
|
||||
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;
|
||||
|
@ -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 @@ int WebRtcIsacfix_AutocorrC(int32_t* __restrict r,
|
||||
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++) {
|
||||
|
@ -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 @@ int WebRtcIsacfix_AutocorrNeon(int32_t* __restrict r,
|
||||
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;
|
||||
|
@ -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 @@ int16_t WebRtcIsacfix_Control(ISACFIX_MainStruct *ISAC_main_inst,
|
||||
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_version(char *version)
|
||||
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);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
'<(webrtc_root)',
|
||||
],
|
||||
'sources': [
|
||||
'empty.cc', # force build system to use C++ linker
|
||||
'./main/test/simpleKenny.c',
|
||||
'./main/util/utility.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 @@ int16_t WebRtcIsac_UpdateBandwidthEstimator(
|
||||
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 WebRtcIsac_UpdateUplinkBwImpl(
|
||||
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 @@ int16_t WebRtcIsac_UpdateUplinkJitter(
|
||||
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 @@ int32_t WebRtcIsac_GetDownlinkBandwidth( const BwEstimatorstr *bwest_str)
|
||||
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 @@ WebRtcIsac_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str)
|
||||
{
|
||||
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 @@ WebRtcIsac_GetDownlinkMaxDelay(const BwEstimatorstr *bwest_str)
|
||||
|
||||
/* 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 @@ int32_t WebRtcIsac_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str) {
|
||||
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);
|
||||
|
@ -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 @@ int16_t WebRtcIsac_Control(ISACStruct* ISAC_main_inst,
|
||||
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 @@ uint16_t WebRtcIsac_DecSampRate(ISACStruct* ISAC_main_inst) {
|
||||
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_GetBandwidthInfo(ISACStruct* inst,
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user