Prepare to convert various types to size_t.
This makes some behaviorally-invariant changes to make certain code that
currently only works correctly with signed types work safely regardless of the
signedness of the types in question. This is preparation for a future change
that will convert a variety of types to size_t.
There are also some formatting changes (e.g. converting "enum hack" usage to real consts) to make it simpler to just change "int" to "size_t" in the future to change the types of those constants.
BUG=none
R=andrew@webrtc.org, juberti@webrtc.org, kwiberg@webrtc.org
TBR=ajm
Review URL: https://codereview.webrtc.org/1174813003
Cr-Commit-Position: refs/heads/master@{#9413}
diff --git a/talk/app/webrtc/test/fakeaudiocapturemodule.h b/talk/app/webrtc/test/fakeaudiocapturemodule.h
index 57c1e58..8ff4aa1 100644
--- a/talk/app/webrtc/test/fakeaudiocapturemodule.h
+++ b/talk/app/webrtc/test/fakeaudiocapturemodule.h
@@ -58,8 +58,8 @@
// The value for the following constants have been derived by running VoE
// using a real ADM. The constants correspond to 10ms of mono audio at 44kHz.
- enum{kNumberSamples = 440};
- enum{kNumberBytesPerSample = sizeof(Sample)};
+ static const int kNumberSamples = 440;
+ static const int kNumberBytesPerSample = sizeof(Sample);
// Creates a FakeAudioCaptureModule or returns NULL on failure.
// |process_thread| is used to push and pull audio frames to and from the
diff --git a/webrtc/common_audio/audio_converter_unittest.cc b/webrtc/common_audio/audio_converter_unittest.cc
index 6da339f..590c8ce 100644
--- a/webrtc/common_audio/audio_converter_unittest.cc
+++ b/webrtc/common_audio/audio_converter_unittest.cc
@@ -49,7 +49,7 @@
int best_delay = 0;
// Search within one sample of the expected delay.
- for (int delay = std::max(expected_delay - 1, 0);
+ for (int delay = std::max(expected_delay, 1) - 1;
delay <= std::min(expected_delay + 1, ref.num_frames());
++delay) {
float mse = 0;
diff --git a/webrtc/common_audio/real_fourier.cc b/webrtc/common_audio/real_fourier.cc
index dec2be6..30c8ee3 100644
--- a/webrtc/common_audio/real_fourier.cc
+++ b/webrtc/common_audio/real_fourier.cc
@@ -40,8 +40,7 @@
}
int RealFourier::ComplexLength(int order) {
- CHECK_GE(order, 0);
- return (1 << order) / 2 + 1;
+ return FftLength(order) / 2 + 1;
}
RealFourier::fft_real_scoper RealFourier::AllocRealBuffer(int count) {
diff --git a/webrtc/common_audio/resampler/sinc_resampler.h b/webrtc/common_audio/resampler/sinc_resampler.h
index 9ad7895..062117a 100644
--- a/webrtc/common_audio/resampler/sinc_resampler.h
+++ b/webrtc/common_audio/resampler/sinc_resampler.h
@@ -34,22 +34,20 @@
// SincResampler is a high-quality single-channel sample-rate converter.
class SincResampler {
public:
- enum {
- // The kernel size can be adjusted for quality (higher is better) at the
- // expense of performance. Must be a multiple of 32.
- // TODO(dalecurtis): Test performance to see if we can jack this up to 64+.
- kKernelSize = 32,
+ // The kernel size can be adjusted for quality (higher is better) at the
+ // expense of performance. Must be a multiple of 32.
+ // TODO(dalecurtis): Test performance to see if we can jack this up to 64+.
+ static const int kKernelSize = 32;
- // Default request size. Affects how often and for how much SincResampler
- // calls back for input. Must be greater than kKernelSize.
- kDefaultRequestSize = 512,
+ // Default request size. Affects how often and for how much SincResampler
+ // calls back for input. Must be greater than kKernelSize.
+ static const int kDefaultRequestSize = 512;
- // The kernel offset count is used for interpolation and is the number of
- // sub-sample kernel shifts. Can be adjusted for quality (higher is better)
- // at the expense of allocating more memory.
- kKernelOffsetCount = 32,
- kKernelStorageSize = kKernelSize * (kKernelOffsetCount + 1),
- };
+ // The kernel offset count is used for interpolation and is the number of
+ // sub-sample kernel shifts. Can be adjusted for quality (higher is better)
+ // at the expense of allocating more memory.
+ static const int kKernelOffsetCount = 32;
+ static const int kKernelStorageSize = kKernelSize * (kKernelOffsetCount + 1);
// Constructs a SincResampler with the specified |read_cb|, which is used to
// acquire audio data for resampling. |io_sample_rate_ratio| is the ratio
diff --git a/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc b/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc
index d38263c..597820b 100644
--- a/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc
+++ b/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc
@@ -36,12 +36,11 @@
destination[i] = 0;
} else {
// Calculate time in seconds.
- double t = (static_cast<double>(current_index_) - delay_samples_) /
- sample_rate_;
- if (t < 0) {
+ if (current_index_ < delay_samples_) {
destination[i] = 0;
} else {
// Sinusoidal linear chirp.
+ double t = (current_index_ - delay_samples_) / sample_rate_;
destination[i] =
sin(2 * M_PI * (kMinFrequency * t + (k_ / 2) * t * t));
}
diff --git a/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h b/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h
index d6b8ce3..1bddfc9 100644
--- a/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h
+++ b/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.h
@@ -40,7 +40,7 @@
kMinFrequency = 5
};
- double sample_rate_;
+ int sample_rate_;
int total_samples_;
double max_frequency_;
double k_;
diff --git a/webrtc/common_audio/signal_processing/auto_correlation.c b/webrtc/common_audio/signal_processing/auto_correlation.c
index 9fb9824..fed1312 100644
--- a/webrtc/common_audio/signal_processing/auto_correlation.c
+++ b/webrtc/common_audio/signal_processing/auto_correlation.c
@@ -51,7 +51,7 @@
for (i = 0; i < order + 1; i++) {
sum = 0;
/* Unroll the loop to improve performance. */
- for (j = 0; j < in_vector_length - i - 3; j += 4) {
+ for (j = 0; i + j + 3 < in_vector_length; j += 4) {
sum += (in_vector[j + 0] * in_vector[i + j + 0]) >> scaling;
sum += (in_vector[j + 1] * in_vector[i + j + 1]) >> scaling;
sum += (in_vector[j + 2] * in_vector[i + j + 2]) >> scaling;
diff --git a/webrtc/common_audio/signal_processing/dot_product_with_scale.c b/webrtc/common_audio/signal_processing/dot_product_with_scale.c
index 389bcf0..c01ec57 100644
--- a/webrtc/common_audio/signal_processing/dot_product_with_scale.c
+++ b/webrtc/common_audio/signal_processing/dot_product_with_scale.c
@@ -18,7 +18,7 @@
int i = 0;
/* Unroll the loop to improve performance. */
- for (i = 0; i < length - 3; i += 4) {
+ for (i = 0; i + 3 < length; i += 4) {
sum += (vector1[i + 0] * vector2[i + 0]) >> scaling;
sum += (vector1[i + 1] * vector2[i + 1]) >> scaling;
sum += (vector1[i + 2] * vector2[i + 2]) >> scaling;
diff --git a/webrtc/common_audio/signal_processing/levinson_durbin.c b/webrtc/common_audio/signal_processing/levinson_durbin.c
index eaf5143..536bd0b 100644
--- a/webrtc/common_audio/signal_processing/levinson_durbin.c
+++ b/webrtc/common_audio/signal_processing/levinson_durbin.c
@@ -41,7 +41,7 @@
norm = WebRtcSpl_NormW32(R[0]);
- for (i = order; i >= 0; i--)
+ for (i = 0; i <= order; ++i)
{
temp1W32 = WEBRTC_SPL_LSHIFT_W32(R[i], norm);
// Put R in hi and low format
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 dec31ad..e4b3041 100644
--- a/webrtc/common_audio/signal_processing/min_max_operations_neon.c
+++ b/webrtc/common_audio/signal_processing/min_max_operations_neon.c
@@ -86,7 +86,7 @@
uint32x4_t max32x4_1 = vdupq_n_u32(0);
// First part, unroll the loop 8 times.
- for (i = length - residual; i >0; i -= 8) {
+ for (i = 0; i < length - residual; i += 8) {
int32x4_t in32x4_0 = vld1q_s32(p_start);
p_start += 4;
int32x4_t in32x4_1 = vld1q_s32(p_start);
@@ -139,7 +139,7 @@
int16x8_t max16x8 = vdupq_n_s16(WEBRTC_SPL_WORD16_MIN);
// First part, unroll the loop 8 times.
- for (i = length - residual; i >0; i -= 8) {
+ for (i = 0; i < length - residual; i += 8) {
int16x8_t in16x8 = vld1q_s16(p_start);
max16x8 = vmaxq_s16(max16x8, in16x8);
p_start += 8;
@@ -180,7 +180,7 @@
int32x4_t max32x4_1 = vdupq_n_s32(WEBRTC_SPL_WORD32_MIN);
// First part, unroll the loop 8 times.
- for (i = length - residual; i >0; i -= 8) {
+ for (i = 0; i < length - residual; i += 8) {
int32x4_t in32x4_0 = vld1q_s32(p_start);
p_start += 4;
int32x4_t in32x4_1 = vld1q_s32(p_start);
@@ -223,7 +223,7 @@
int16x8_t min16x8 = vdupq_n_s16(WEBRTC_SPL_WORD16_MAX);
// First part, unroll the loop 8 times.
- for (i = length - residual; i >0; i -= 8) {
+ for (i = 0; i < length - residual; i += 8) {
int16x8_t in16x8 = vld1q_s16(p_start);
min16x8 = vminq_s16(min16x8, in16x8);
p_start += 8;
@@ -264,7 +264,7 @@
int32x4_t min32x4_1 = vdupq_n_s32(WEBRTC_SPL_WORD32_MAX);
// First part, unroll the loop 8 times.
- for (i = length - residual; i >0; i -= 8) {
+ for (i = 0; i < length - residual; i += 8) {
int32x4_t in32x4_0 = vld1q_s32(p_start);
p_start += 4;
int32x4_t in32x4_1 = vld1q_s32(p_start);
diff --git a/webrtc/modules/audio_coding/codecs/audio_decoder.cc b/webrtc/modules/audio_coding/codecs/audio_decoder.cc
index 9e88f89..0a4a6a9 100644
--- a/webrtc/modules/audio_coding/codecs/audio_decoder.cc
+++ b/webrtc/modules/audio_coding/codecs/audio_decoder.cc
@@ -56,7 +56,7 @@
bool AudioDecoder::HasDecodePlc() const { return false; }
-int AudioDecoder::DecodePlc(int num_frames, int16_t* decoded) { return -1; }
+int AudioDecoder::DecodePlc(int num_frames, int16_t* decoded) { return 0; }
int AudioDecoder::IncomingPacket(const uint8_t* payload,
size_t payload_len,
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
index 9b23607..c662b5b 100644
--- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
@@ -136,9 +136,9 @@
(frames_to_encode > 3 ? 3 : frames_to_encode);
if (frames_to_encode == 4)
blocks_in_first_vad_call = 2;
+ CHECK_GE(frames_to_encode, blocks_in_first_vad_call);
const int blocks_in_second_vad_call =
frames_to_encode - blocks_in_first_vad_call;
- CHECK_GE(blocks_in_second_vad_call, 0);
// Check if all of the buffer is passive speech. Start with checking the first
// block.
@@ -217,7 +217,7 @@
info = speech_encoder_->Encode(
rtp_timestamps_.front(), &speech_buffer_[i * samples_per_10ms_frame],
samples_per_10ms_frame, max_encoded_bytes, encoded);
- if (i == frames_to_encode - 1) {
+ if (i + 1 == frames_to_encode) {
CHECK_GT(info.encoded_bytes, 0u) << "Encoder didn't deliver data.";
} else {
CHECK_EQ(info.encoded_bytes, 0u) << "Encoder delivered data too early.";
diff --git a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
index 0a3a639..ed49618 100644
--- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
+++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
@@ -88,13 +88,13 @@
}
CHECK_EQ(speech_buffer_.size(), full_frame_samples_);
CHECK_GE(max_encoded_bytes, full_frame_samples_);
- int16_t ret = EncodeCall(&speech_buffer_[0], full_frame_samples_, encoded);
- CHECK_GE(ret, 0);
- speech_buffer_.clear();
EncodedInfo info;
info.encoded_timestamp = first_timestamp_in_buffer_;
info.payload_type = payload_type_;
+ int16_t ret = EncodeCall(&speech_buffer_[0], full_frame_samples_, encoded);
+ CHECK_GE(ret, 0);
info.encoded_bytes = static_cast<size_t>(ret);
+ speech_buffer_.clear();
return info;
}
diff --git a/webrtc/modules/audio_coding/codecs/g711/test/testG711.cc b/webrtc/modules/audio_coding/codecs/g711/test/testG711.cc
index e891810..9511df7 100644
--- a/webrtc/modules/audio_coding/codecs/g711/test/testG711.cc
+++ b/webrtc/modules/audio_coding/codecs/g711/test/testG711.cc
@@ -86,6 +86,10 @@
printf("G.711 version: %s\n\n", versionNumber);
/* Get frame length */
framelength = atoi(argv[1]);
+ if (framelength < 0) {
+ printf(" G.711: Invalid framelength %d.\n", framelength);
+ exit(1);
+ }
/* Get compression law */
strcpy(law, argv[2]);
diff --git a/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc b/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
index effb405..8e10dff 100644
--- a/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
+++ b/webrtc/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
@@ -24,7 +24,8 @@
} // namespace
bool AudioEncoderG722::Config::IsOk() const {
- return (frame_size_ms % 10 == 0) && (num_channels >= 1);
+ return (frame_size_ms > 0) && (frame_size_ms % 10 == 0) &&
+ (num_channels >= 1);
}
AudioEncoderG722::EncoderState::EncoderState() {
diff --git a/webrtc/modules/audio_coding/codecs/g722/test/testG722.cc b/webrtc/modules/audio_coding/codecs/g722/test/testG722.cc
index 6d0c432..9b2f54c 100644
--- a/webrtc/modules/audio_coding/codecs/g722/test/testG722.cc
+++ b/webrtc/modules/audio_coding/codecs/g722/test/testG722.cc
@@ -83,6 +83,10 @@
/* Get frame length */
framelength = atoi(argv[1]);
+ if (framelength < 0) {
+ printf(" G.722: Invalid framelength %d.\n", framelength);
+ exit(1);
+ }
/* Get Input and Output files */
sscanf(argv[2], "%s", inname);
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
index b675441..bfe0e64 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
@@ -41,7 +41,7 @@
eSh_ptr = &energyShifts[1+base_size];
eW16_ptr = &energyW16[1+base_size];
- for(j=0;j<range-1;j++) {
+ for (j = 0; j + 1 < range; j++) {
/* Calculate next energy by a +/-
operation on the edge samples */
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
index 2a77f4f..877a1c6 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/cb_search.c
@@ -227,12 +227,9 @@
inverseEnergy[indexNew+indexOffset], inverseEnergyShifts[indexNew+indexOffset],
&CritMax, &shTotMax, &bestIndex, &bestGain);
- sInd=bestIndex-(int16_t)(CB_RESRANGE>>1);
+ sInd = ((CB_RESRANGE >> 1) > bestIndex) ?
+ 0 : (bestIndex - (CB_RESRANGE >> 1));
eInd=sInd+CB_RESRANGE;
- if (sInd<0) {
- eInd-=sInd;
- sInd=0;
- }
if (eInd>=range) {
eInd=range-1;
sInd=eInd-CB_RESRANGE;
@@ -247,9 +244,11 @@
interpSamplesFilt, cDot,
(int16_t)(sInd+20), (int16_t)(WEBRTC_SPL_MIN(39, (eInd+20))), scale);
i=20;
+ cDotPtr = &cDot[20 - sInd];
+ } else {
+ cDotPtr = cDot;
}
- cDotPtr=&cDot[WEBRTC_SPL_MAX(0,(20-sInd))];
cb_vecPtr = cbvectors+lMem-20-i;
/* Calculate the cross correlations (main part of the filtered CB) */
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c b/webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c
index 169218a..c04fd99 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/decode_residual.c
@@ -41,7 +41,7 @@
int16_t *syntdenum /* (i) the decoded synthesis filter
coefficients */
) {
- int16_t meml_gotten, Nfor, Nback, diff, start_pos;
+ int16_t meml_gotten, diff, start_pos;
int16_t subcount, subframe;
int16_t *reverseDecresidual = iLBCdec_inst->enh_buf; /* Reversed decoded data, used for decoding backwards in time (reuse memory in state) */
int16_t *memVec = iLBCdec_inst->prevResidual; /* Memory for codebook and filter state (reuse memory in state) */
@@ -110,9 +110,7 @@
/* forward prediction of subframes */
- Nfor = iLBCdec_inst->nsub-iLBC_encbits->startIdx-1;
-
- if( Nfor > 0 ) {
+ if (iLBCdec_inst->nsub > iLBC_encbits->startIdx + 1) {
/* setup memory */
WebRtcSpl_MemSetW16(mem, 0, CB_MEML-STATE_LEN);
@@ -121,6 +119,7 @@
/* loop over subframes to encode */
+ int16_t Nfor = iLBCdec_inst->nsub - iLBC_encbits->startIdx - 1;
for (subframe=0; subframe<Nfor; subframe++) {
/* construct decoded vector */
@@ -143,9 +142,7 @@
/* backward prediction of subframes */
- Nback = iLBC_encbits->startIdx-1;
-
- if( Nback > 0 ){
+ if (iLBC_encbits->startIdx > 1) {
/* setup memory */
@@ -160,6 +157,7 @@
/* loop over subframes to decode */
+ int16_t Nback = iLBC_encbits->startIdx - 1;
for (subframe=0; subframe<Nback; subframe++) {
/* construct decoded vector */
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/do_plc.c b/webrtc/modules/audio_coding/codecs/ilbc/do_plc.c
index 2d72075..ecdd68a 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/do_plc.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/do_plc.c
@@ -37,7 +37,7 @@
IlbcDecoder *iLBCdec_inst
/* (i/o) decoder instance */
){
- int16_t i, pick;
+ int16_t i;
int32_t cross, ener, cross_comp, ener_comp = 0;
int32_t measure, maxMeasure, energy;
int16_t max, crossSquareMax, crossSquare;
@@ -234,22 +234,19 @@
/* noise component - 52 < randlagFIX < 117 */
iLBCdec_inst->seed = (int16_t)(iLBCdec_inst->seed * 31821 + 13849);
randlag = 53 + (int16_t)(iLBCdec_inst->seed & 63);
-
- pick = i - randlag;
-
- if (pick < 0) {
- randvec[i] = iLBCdec_inst->prevResidual[iLBCdec_inst->blockl+pick];
+ if (randlag > i) {
+ randvec[i] =
+ iLBCdec_inst->prevResidual[iLBCdec_inst->blockl + i - randlag];
} else {
- randvec[i] = iLBCdec_inst->prevResidual[pick];
+ randvec[i] = iLBCdec_inst->prevResidual[i - randlag];
}
/* pitch repeatition component */
- pick = i - use_lag;
-
- if (pick < 0) {
- PLCresidual[i] = iLBCdec_inst->prevResidual[iLBCdec_inst->blockl+pick];
+ if (use_lag > i) {
+ PLCresidual[i] =
+ iLBCdec_inst->prevResidual[iLBCdec_inst->blockl + i - use_lag];
} else {
- PLCresidual[i] = PLCresidual[pick];
+ PLCresidual[i] = PLCresidual[i - use_lag];
}
/* Attinuate total gain for each 10 ms */
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/encode.c b/webrtc/modules/audio_coding/codecs/ilbc/encode.c
index 1d46eff..3de8425 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/encode.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/encode.c
@@ -48,7 +48,7 @@
IlbcEncoder *iLBCenc_inst /* (i/o) the general encoder
state */
){
- int n, meml_gotten, Nfor, Nback;
+ int n, meml_gotten, Nfor;
int16_t diff, start_pos;
int index;
int subcount, subframe;
@@ -379,15 +379,14 @@
/* backward prediction of subframes */
- Nback = iLBCbits_inst->startIdx-1;
-
- if( Nback > 0 ){
+ if (iLBCbits_inst->startIdx > 1) {
/* create reverse order vectors
(The decresidual does not need to be copied since it is
contained in the same vector as the residual)
*/
+ int Nback = iLBCbits_inst->startIdx - 1;
WebRtcSpl_MemCpyReversedOrder(&reverseResidual[Nback*SUBL-1], residual, Nback*SUBL);
/* setup memory */
@@ -425,11 +424,11 @@
if (iLBCenc_inst->section == 1)
{
start_count = 0;
- end_count = WEBRTC_SPL_MAX (2 - Nfor, 0);
+ end_count = (Nfor >= 2) ? 0 : (2 - NFor);
}
if (iLBCenc_inst->section == 2)
{
- start_count = WEBRTC_SPL_MAX (2 - Nfor, 0);
+ start_count = (Nfor >= 2) ? 0 : (2 - NFor);
end_count = Nback;
}
}
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
index db4b8d4..257013c 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/enhancer_interface.c
@@ -110,9 +110,8 @@
for(iblock = 0; iblock<new_blocks; iblock++){
/* references */
- i = 60 + iblock * ENH_BLOCKL_HALF;
- target=downsampled+i;
- regressor=downsampled+i-10;
+ target = downsampled + 60 + iblock * ENH_BLOCKL_HALF;
+ regressor = target - 10;
/* scaling */
max16=WebRtcSpl_MaxAbsValueW16(®ressor[-50],
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c
index 3daf186..9c42037 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_test.c
@@ -165,6 +165,10 @@
fprintf(stderr, "--- Encoding block %i --- ",blockcount);
len = WebRtcIlbcfix_Encode(Enc_Inst, data, (int16_t)frameLen, encoded_data);
+ if (len < 0) {
+ fprintf(stderr, "Error encoding\n");
+ exit(0);
+ }
fprintf(stderr, "\r");
/* write byte file */
@@ -202,6 +206,10 @@
if (pli==1) {
len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data,
(int16_t)len, decoded_data,&speechType);
+ if (len < 0) {
+ fprintf(stderr, "Error decoding\n");
+ exit(0);
+ }
} else {
len=WebRtcIlbcfix_DecodePlc(Dec_Inst, decoded_data, 1);
}
diff --git a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c
index 1e966a7..103a136 100644
--- a/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c
+++ b/webrtc/modules/audio_coding/codecs/ilbc/test/iLBC_testLib.c
@@ -139,6 +139,10 @@
#else
len=WebRtcIlbcfix_Encode(Enc_Inst, data, (short)(mode<<3), encoded_data);
#endif
+ if (len < 0) {
+ fprintf(stderr, "Error encoding\n");
+ exit(0);
+ }
fprintf(stderr, "\r");
#ifdef JUNK_DATA
@@ -176,6 +180,10 @@
if (pli==1) {
len=WebRtcIlbcfix_Decode(Dec_Inst, encoded_data, (int16_t)len, data,
&speechType);
+ if (len < 0) {
+ fprintf(stderr, "Error decoding\n");
+ exit(0);
+ }
} else {
len=WebRtcIlbcfix_DecodePlc(Dec_Inst, data, 1);
}
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h b/webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h
index 3d003e4..8c5c7e6 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h
@@ -37,8 +37,8 @@
int16_t* current_framesamples);
int16_t WebRtcIsacfix_DecodePlcImpl(int16_t* decoded,
- IsacFixDecoderInstance* ISACdec_obj,
- int16_t* current_framesample );
+ IsacFixDecoderInstance* ISACdec_obj,
+ int16_t* current_framesample );
int WebRtcIsacfix_EncodeImpl(int16_t* in,
IsacFixEncoderInstance* ISACenc_obj,
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c
index 75ae542..d2cfb3a 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c
@@ -309,7 +309,7 @@
&((ISACdec_obj->plcstr_obj).prevPitchInvIn[FRAMESAMPLES_HALF - lag0]);
minCorr = WEBRTC_SPL_WORD32_MAX;
- if ( (FRAMESAMPLES_HALF - 2*lag0 - 10) > 0 )
+ if ((FRAMESAMPLES_HALF - 10) > 2 * lag0)
{
minIdx = 11;
for( i = 0; i < 21; i++ )
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c
index cfd9a9e..3b26a98 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c
@@ -279,13 +279,15 @@
ARfQ0vec[i] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0
}
- for (i=orderCoef-1;i>=0;i--) //get the state of f&g for the first input, for all orders
+ for (i=orderCoef;i>0;i--) //get the state of f&g for the first input, for all orders
{
- tmp32 = (cthQ15[i] * ARfQ0vec[0] - sthQ15[i] * stateGQ0[i] + 16384) >> 15;
+ tmp32 = (cthQ15[i - 1] * ARfQ0vec[0] - sthQ15[i - 1] * stateGQ0[i - 1] +
+ 16384) >> 15;
tmpAR = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0
- tmp32 = (sthQ15[i] * ARfQ0vec[0] + cthQ15[i] * stateGQ0[i] + 16384) >> 15;
- ARgQ0vec[i+1] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0
+ tmp32 = (sthQ15[i - 1] * ARfQ0vec[0] + cthQ15[i - 1] * stateGQ0[i - 1] +
+ 16384) >> 15;
+ ARgQ0vec[i] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0
ARfQ0vec[0] = tmpAR;
}
ARgQ0vec[0] = ARfQ0vec[0];
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S
index 35fd9ef..ccea467 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_armv7.S
@@ -46,21 +46,21 @@
add r2, r9, asl #1 @ Restore r2 to &cth_Q15[order_coef]
add r3, r9, asl #1 @ Restore r3 to &sth_Q15[order_coef]
-ORDER_COEF_LOOP: @ for(k = order_coef - 1 ; k >= 0; k--)
+ORDER_COEF_LOOP: @ for(k = order_coef ; k > 0; k--)
- ldrh r7, [r3, #-2]! @ sth_Q15[k]
- ldrh r6, [r2, #-2]! @ cth_Q15[k]
+ ldrh r7, [r3, #-2]! @ sth_Q15[k - 1]
+ ldrh r6, [r2, #-2]! @ cth_Q15[k - 1]
- ldrh r8, [r0, #-2] @ ar_g_Q0[k]
- smlabb r11, r7, r5, r12 @ sth_Q15[k] * tmpAR + 16384
- smlabb r10, r6, r5, r12 @ cth_Q15[k] * tmpAR + 16384
- smulbb r7, r7, r8 @ sth_Q15[k] * ar_g_Q0[k]
- smlabb r11, r6, r8, r11 @ cth_Q15[k]*ar_g_Q0[k]+(sth_Q15[k]*tmpAR+16384)
+ ldrh r8, [r0, #-2] @ ar_g_Q0[k - 1]
+ smlabb r11, r7, r5, r12 @ sth_Q15[k - 1] * tmpAR + 16384
+ smlabb r10, r6, r5, r12 @ cth_Q15[k - 1] * tmpAR + 16384
+ smulbb r7, r7, r8 @ sth_Q15[k - 1] * ar_g_Q0[k - 1]
+ smlabb r11, r6, r8, r11 @ cth_Q15[k - 1]*ar_g_Q0[k - 1]+(sth_Q15[k - 1]*tmpAR+16384)
- sub r10, r10, r7 @ cth_Q15[k]*tmpAR+16384-(sth_Q15[k]*ar_g_Q0[k])
+ sub r10, r10, r7 @ cth_Q15[k - 1]*tmpAR+16384-(sth_Q15[k - 1]*ar_g_Q0[k - 1])
ssat r11, #16, r11, asr #15
ssat r5, #16, r10, asr #15
- strh r11, [r0], #-2 @ Output: ar_g_Q0[k+1]
+ strh r11, [r0], #-2 @ Output: ar_g_Q0[k]
subs r9, #1
bgt ORDER_COEF_LOOP
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_c.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_c.c
index 8c53b0b..43a1579 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_c.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice_c.c
@@ -35,11 +35,13 @@
int32_t tmp32_2 = 0;
tmpAR = ar_f_Q0[n + 1];
- for (k = order_coef - 1; k >= 0; k--) {
- tmp32 = (cth_Q15[k] * tmpAR - sth_Q15[k] * ar_g_Q0[k] + 16384) >> 15;
- tmp32_2 = (sth_Q15[k] * tmpAR + cth_Q15[k] * ar_g_Q0[k] + 16384) >> 15;
+ for (k = order_coef; k > 0; k--) {
+ tmp32 = (cth_Q15[k - 1] * tmpAR - sth_Q15[k - 1] * ar_g_Q0[k - 1] +
+ 16384) >> 15;
+ tmp32_2 = (sth_Q15[k - 1] * tmpAR + cth_Q15[k - 1] * ar_g_Q0[k - 1] +
+ 16384) >> 15;
tmpAR = (int16_t)WebRtcSpl_SatW32ToW16(tmp32);
- ar_g_Q0[k + 1] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32_2);
+ ar_g_Q0[k] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32_2);
}
ar_f_Q0[n + 1] = tmpAR;
ar_g_Q0[0] = tmpAR;
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c
index eaf131d..1149d50 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c
@@ -69,7 +69,6 @@
int16_t oldLagQ7;
int16_t oldGainQ12, lagdeltaQ7, curLagQ7, gaindeltaQ12, curGainQ12;
int indW32 = 0, frcQQ = 0;
- int32_t tmpW32;
const int16_t* fracoeffQQ = NULL;
// Assumptions in ARM assembly for WebRtcIsacfix_PitchFilterCoreARM().
@@ -123,8 +122,7 @@
curGainQ12 += gaindeltaQ12;
curLagQ7 += lagdeltaQ7;
indW32 = CalcLrIntQ(curLagQ7, 7);
- tmpW32 = (indW32 << 7) - curLagQ7;
- frcQQ = (tmpW32 >> 4) + 4;
+ frcQQ = ((indW32 << 7) + 64 - curLagQ7) >> 4;
if (frcQQ == PITCH_FRACS) {
frcQQ = 0;
@@ -195,8 +193,7 @@
// Update parameters for each segment.
curLagQ7 += lagdeltaQ7;
indW16 = (int16_t)CalcLrIntQ(curLagQ7, 7);
- tmpW16 = (indW16 << 7) - curLagQ7;
- frcQQ = (tmpW16 >> 4) + 4;
+ frcQQ = ((indW16 << 7) + 64 - curLagQ7) >> 4;
if (frcQQ == PITCH_FRACS) {
frcQQ = 0;
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc b/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
index bb76257..3089f58 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
@@ -65,18 +65,21 @@
// ISAC takes 10 ms everycall
const int subblocks = block_duration_ms_ / 10;
const int subblock_length = 10 * input_sampling_khz_;
- int value;
+ int value = 0;
clock_t clocks = clock();
size_t pointer = 0;
for (int idx = 0; idx < subblocks; idx++, pointer += subblock_length) {
value = WebRtcIsacfix_Encode(ISACFIX_main_inst_, &in_data[pointer],
bit_stream);
+ if (idx == subblocks - 1)
+ EXPECT_GT(value, 0);
+ else
+ EXPECT_EQ(0, value);
}
clocks = clock() - clocks;
- EXPECT_GT(value, 0);
- assert(value <= max_bytes);
*encoded_bytes = value;
+ assert(*encoded_bytes <= max_bytes);
return 1000.0 * clocks / CLOCKS_PER_SEC;
}
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/test/kenny.cc b/webrtc/modules/audio_coding/codecs/isac/fix/test/kenny.cc
index bc1a194..ac1efe4 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/test/kenny.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/test/kenny.cc
@@ -232,7 +232,7 @@
CodingMode = 0;
testNum = 0;
testCE = 0;
- for (i = 1; i < argc-2;i++) {
+ for (i = 1; i + 2 < argc; i++) {
/* Instantaneous mode */
if (!strcmp ("-I", argv[i])) {
printf("\nInstantaneous BottleNeck\n");
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc b/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
index f6bfcdc..496e8c9 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
@@ -185,7 +185,7 @@
char transCodingFileName[500];
int16_t totFileLoop = 0;
int16_t numFileLoop = 0;
- for (i = 1; i < argc - 2; i++) {
+ for (i = 1; i + 2 < argc; i++) {
if (!strcmp("-LOOP", argv[i])) {
i++;
totFileLoop = (int16_t)atol(argv[i]);
diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc b/webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc
index 15188a9..bb7bee9 100644
--- a/webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/opus_unittest.cc
@@ -106,6 +106,7 @@
input_audio,
input_samples, kMaxBytes,
bitstream_);
+ EXPECT_GE(encoded_bytes_, 0);
return WebRtcOpus_Decode(decoder, bitstream_,
encoded_bytes_, output_audio,
audio_type);
@@ -539,6 +540,7 @@
speech_data_.GetNextBlock(),
kOpus10msFrameSamples, kMaxBytes,
bitstream_);
+ EXPECT_GE(encoded_bytes_, 0);
EXPECT_EQ(kOpus10msFrameSamples,
WebRtcOpus_DurationEst(opus_decoder_, bitstream_,
encoded_bytes_));
@@ -548,6 +550,7 @@
speech_data_.GetNextBlock(),
kOpus20msFrameSamples, kMaxBytes,
bitstream_);
+ EXPECT_GE(encoded_bytes_, 0);
EXPECT_EQ(kOpus20msFrameSamples,
WebRtcOpus_DurationEst(opus_decoder_, bitstream_,
encoded_bytes_));
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
index 0da2eb5..b659649 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
@@ -89,9 +89,11 @@
if (length_out_buff < frame.samples_per_channel_) {
return -1;
}
- for (int n = frame.samples_per_channel_ - 1; n >= 0; --n) {
- out_buff[2 * n + 1] = frame.data_[n];
- out_buff[2 * n] = frame.data_[n];
+ for (int n = frame.samples_per_channel_; n > 0; --n) {
+ int i = n - 1;
+ int16_t sample = frame.data_[i];
+ out_buff[2 * i + 1] = sample;
+ out_buff[2 * i] = sample;
}
return 0;
}
diff --git a/webrtc/modules/audio_coding/neteq/expand.cc b/webrtc/modules/audio_coding/neteq/expand.cc
index 4bcb7a8..cfd2701 100644
--- a/webrtc/modules/audio_coding/neteq/expand.cc
+++ b/webrtc/modules/audio_coding/neteq/expand.cc
@@ -404,7 +404,7 @@
// Find the maximizing index |i| of the cost function
// f[i] = best_correlation[i] / best_distortion[i].
int32_t best_ratio = std::numeric_limits<int32_t>::min();
- int best_index = -1;
+ int best_index = std::numeric_limits<int>::max();
for (int i = 0; i < kNumCorrelationCandidates; ++i) {
int32_t ratio;
if (best_distortion[i] > 0) {
@@ -549,9 +549,7 @@
}
// Set the 3 lag values.
- int lag_difference = distortion_lag - correlation_lag;
- if (lag_difference == 0) {
- // |distortion_lag| and |correlation_lag| are equal.
+ if (distortion_lag == correlation_lag) {
expand_lags_[0] = distortion_lag;
expand_lags_[1] = distortion_lag;
expand_lags_[2] = distortion_lag;
@@ -563,7 +561,7 @@
// Second lag is the average of the two.
expand_lags_[1] = (distortion_lag + correlation_lag) / 2;
// Third lag is the average again, but rounding towards |correlation_lag|.
- if (lag_difference > 0) {
+ if (distortion_lag > correlation_lag) {
expand_lags_[2] = (distortion_lag + correlation_lag - 1) / 2;
} else {
expand_lags_[2] = (distortion_lag + correlation_lag + 1) / 2;
@@ -691,9 +689,8 @@
temp_sum += kCoefficients[1] * x1;
temp_sum += kCoefficients[2] * x2;
temp_sum += kCoefficients[3] * x3;
- parameters.voice_mix_factor = temp_sum / 4096;
- parameters.voice_mix_factor = std::min(parameters.voice_mix_factor,
- static_cast<int16_t>(16384));
+ parameters.voice_mix_factor =
+ static_cast<int16_t>(std::min(temp_sum / 4096, 16384));
parameters.voice_mix_factor = std::max(parameters.voice_mix_factor,
static_cast<int16_t>(0));
} else {
diff --git a/webrtc/modules/audio_coding/neteq/merge.cc b/webrtc/modules/audio_coding/neteq/merge.cc
index fa033cf..23382ac 100644
--- a/webrtc/modules/audio_coding/neteq/merge.cc
+++ b/webrtc/modules/audio_coding/neteq/merge.cc
@@ -175,7 +175,7 @@
// This is the truncated length.
}
// This assert should always be true thanks to the if statement above.
- assert(210 * kMaxSampleRate / 8000 - *old_length >= 0);
+ assert(210 * kMaxSampleRate / 8000 >= *old_length);
AudioMultiVector expanded_temp(num_channels_);
expand_->Process(&expanded_temp);
@@ -342,7 +342,7 @@
int start_index = timestamps_per_call_ +
static_cast<int>(expand_->overlap_length());
start_index = std::max(start_position, start_index);
- start_index = std::max(start_index - input_length, 0);
+ start_index = (input_length > start_index) ? 0 : (start_index - input_length);
// Downscale starting index to 4kHz domain. (fs_mult_ * 2 = fs_hz_ / 4000.)
int start_index_downsamp = start_index / (fs_mult_ * 2);
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index 8cd9aeb..2d4ff27 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -1520,10 +1520,10 @@
borrowed_samples_per_channel = static_cast<int>(required_samples -
decoded_length_per_channel);
// Calculate how many of these were already played out.
- old_borrowed_samples_per_channel = static_cast<int>(
- borrowed_samples_per_channel - sync_buffer_->FutureLength());
- old_borrowed_samples_per_channel = std::max(
- 0, old_borrowed_samples_per_channel);
+ const int future_length = static_cast<int>(sync_buffer_->FutureLength());
+ old_borrowed_samples_per_channel =
+ (borrowed_samples_per_channel > future_length) ?
+ (borrowed_samples_per_channel - future_length) : 0;
memmove(&decoded_buffer[borrowed_samples_per_channel * num_channels],
decoded_buffer,
sizeof(int16_t) * decoded_length);
diff --git a/webrtc/modules/audio_coding/neteq/normal.cc b/webrtc/modules/audio_coding/neteq/normal.cc
index ce774d7..b172d56 100644
--- a/webrtc/modules/audio_coding/neteq/normal.cc
+++ b/webrtc/modules/audio_coding/neteq/normal.cc
@@ -83,8 +83,10 @@
scaling = std::max(scaling, 0); // |scaling| should always be >= 0.
int32_t energy = WebRtcSpl_DotProductWithScale(signal, signal,
energy_length, scaling);
- if ((energy_length >> scaling) > 0) {
- energy = energy / (energy_length >> scaling);
+ int32_t scaled_energy_length =
+ static_cast<int32_t>(energy_length >> scaling);
+ if (scaled_energy_length > 0) {
+ energy = energy / scaled_energy_length;
} else {
energy = 0;
}
diff --git a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc
index 7d8d60d..1ef9ce5 100644
--- a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc
+++ b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc
@@ -450,7 +450,10 @@
CHECK_NOT_NULL(out_file);
printf("Output file: %s\n\n", argv[2]);
packet_size = atoi(argv[3]);
- CHECK_NOT_NULL(packet_size);
+ if (packet_size <= 0) {
+ printf("Packet size %d must be positive", packet_size);
+ return -1;
+ }
printf("Packet size: %i\n", packet_size);
// check for stereo
diff --git a/webrtc/modules/audio_processing/ns/nsx_core_neon.c b/webrtc/modules/audio_processing/ns/nsx_core_neon.c
index 1c4c816..9675d11 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core_neon.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core_neon.c
@@ -208,7 +208,7 @@
uint16x8_t tmp16x8_4;
int32x4_t tmp32x4;
- for (i = 0; i < inst->magnLen - 7; i += 8) {
+ for (i = 0; i + 7 < inst->magnLen; i += 8) {
// Compute delta.
// Smaller step size during startup. This prevents from using
// unrealistic values causing overflow.
diff --git a/webrtc/modules/interface/module_common_types.h b/webrtc/modules/interface/module_common_types.h
index 0b0e063..9222155 100644
--- a/webrtc/modules/interface/module_common_types.h
+++ b/webrtc/modules/interface/module_common_types.h
@@ -442,8 +442,9 @@
num_channels_ = num_channels;
energy_ = energy;
+ assert(num_channels >= 0);
const int length = samples_per_channel * num_channels;
- assert(length <= kMaxDataSizeSamples && length >= 0);
+ assert(length <= kMaxDataSizeSamples);
if (data != NULL) {
memcpy(data_, data, sizeof(int16_t) * length);
} else {
@@ -466,8 +467,9 @@
energy_ = src.energy_;
interleaved_ = src.interleaved_;
+ assert(num_channels_ >= 0);
const int length = samples_per_channel_ * num_channels_;
- assert(length <= kMaxDataSizeSamples && length >= 0);
+ assert(length <= kMaxDataSizeSamples);
memcpy(data_, src.data_, sizeof(int16_t) * length);
}