Replace assert() with RTC_DCHECK().
CL partially auto-generated with:
git grep -l "\bassert(" | grep "\.[c|h]" | \
xargs sed -i 's/\bassert(/RTC_DCHECK(/g'
And with:
git grep -l "RTC_DCHECK(false)" | \
xargs sed -i 's/RTC_DCHECK(false)/RTC_NOTREACHED()/g'
With some manual changes to include "rtc_base/checks.h" where
needed.
A follow-up CL will remove assert() from Obj-C code as well
and remove the #include of <assert.h>.
The choice to replace with RTC_DCHECK is because assert()
is because RTC_DCHECK has similar behavior as assert()
based on NDEBUG.
This CL also contains manual changes to switch from
basic RTC_DCHECK to other (preferred) versions like
RTC_DCHECK_GT (and similar).
Bug: webrtc:6779
Change-Id: I00bed8886e03d685a2f42324e34aef2c9b7a63b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/224846
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34442}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
9b5d570ae0
commit
25ab3228f3
@ -69,7 +69,7 @@ Accelerate::ReturnCodes Accelerate::CheckCriteriaAndStretch(
|
||||
peak_index = (fs_mult_120 / peak_index) * peak_index;
|
||||
}
|
||||
|
||||
assert(fs_mult_120 >= peak_index); // Should be handled in Process().
|
||||
RTC_DCHECK_GE(fs_mult_120, peak_index); // Should be handled in Process().
|
||||
// Copy first part; 0 to 15 ms.
|
||||
output->PushBackInterleaved(
|
||||
rtc::ArrayView<const int16_t>(input, fs_mult_120 * num_channels_));
|
||||
|
||||
@ -77,9 +77,9 @@ double MseInputOutput(const std::vector<int16_t>& input,
|
||||
size_t num_samples,
|
||||
size_t channels,
|
||||
int delay) {
|
||||
assert(delay < static_cast<int>(num_samples));
|
||||
assert(num_samples <= input.size());
|
||||
assert(num_samples * channels <= output.size());
|
||||
RTC_DCHECK_LT(delay, static_cast<int>(num_samples));
|
||||
RTC_DCHECK_LE(num_samples, input.size());
|
||||
RTC_DCHECK_LE(num_samples * channels, output.size());
|
||||
if (num_samples == 0)
|
||||
return 0.0;
|
||||
double squared_sum = 0.0;
|
||||
@ -303,7 +303,7 @@ class AudioDecoderPcm16BTest : public AudioDecoderTest {
|
||||
frame_size_ = 20 * codec_input_rate_hz_ / 1000;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderPcm16B(codec_input_rate_hz_, 1);
|
||||
assert(decoder_);
|
||||
RTC_DCHECK(decoder_);
|
||||
AudioEncoderPcm16B::Config config;
|
||||
config.sample_rate_hz = codec_input_rate_hz_;
|
||||
config.frame_size_ms =
|
||||
@ -320,7 +320,7 @@ class AudioDecoderIlbcTest : public AudioDecoderTest {
|
||||
frame_size_ = 240;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderIlbcImpl;
|
||||
assert(decoder_);
|
||||
RTC_DCHECK(decoder_);
|
||||
AudioEncoderIlbcConfig config;
|
||||
config.frame_size_ms = 30;
|
||||
audio_encoder_.reset(new AudioEncoderIlbcImpl(config, payload_type_));
|
||||
@ -414,7 +414,7 @@ class AudioDecoderG722Test : public AudioDecoderTest {
|
||||
frame_size_ = 160;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderG722Impl;
|
||||
assert(decoder_);
|
||||
RTC_DCHECK(decoder_);
|
||||
AudioEncoderG722Config config;
|
||||
config.frame_size_ms = 10;
|
||||
config.num_channels = 1;
|
||||
@ -430,7 +430,7 @@ class AudioDecoderG722StereoTest : public AudioDecoderTest {
|
||||
frame_size_ = 160;
|
||||
data_length_ = 10 * frame_size_;
|
||||
decoder_ = new AudioDecoderG722StereoImpl;
|
||||
assert(decoder_);
|
||||
RTC_DCHECK(decoder_);
|
||||
AudioEncoderG722Config config;
|
||||
config.frame_size_ms = 10;
|
||||
config.num_channels = 2;
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
namespace webrtc {
|
||||
|
||||
AudioMultiVector::AudioMultiVector(size_t N) {
|
||||
assert(N > 0);
|
||||
RTC_DCHECK_GT(N, 0);
|
||||
if (N < 1)
|
||||
N = 1;
|
||||
for (size_t n = 0; n < N; ++n) {
|
||||
@ -29,7 +29,7 @@ AudioMultiVector::AudioMultiVector(size_t N) {
|
||||
}
|
||||
|
||||
AudioMultiVector::AudioMultiVector(size_t N, size_t initial_size) {
|
||||
assert(N > 0);
|
||||
RTC_DCHECK_GT(N, 0);
|
||||
if (N < 1)
|
||||
N = 1;
|
||||
for (size_t n = 0; n < N; ++n) {
|
||||
@ -91,7 +91,7 @@ void AudioMultiVector::PushBackInterleaved(
|
||||
}
|
||||
|
||||
void AudioMultiVector::PushBack(const AudioMultiVector& append_this) {
|
||||
assert(num_channels_ == append_this.num_channels_);
|
||||
RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
|
||||
if (num_channels_ == append_this.num_channels_) {
|
||||
for (size_t i = 0; i < num_channels_; ++i) {
|
||||
channels_[i]->PushBack(append_this[i]);
|
||||
@ -101,10 +101,10 @@ void AudioMultiVector::PushBack(const AudioMultiVector& append_this) {
|
||||
|
||||
void AudioMultiVector::PushBackFromIndex(const AudioMultiVector& append_this,
|
||||
size_t index) {
|
||||
assert(index < append_this.Size());
|
||||
RTC_DCHECK_LT(index, append_this.Size());
|
||||
index = std::min(index, append_this.Size() - 1);
|
||||
size_t length = append_this.Size() - index;
|
||||
assert(num_channels_ == append_this.num_channels_);
|
||||
RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
|
||||
if (num_channels_ == append_this.num_channels_) {
|
||||
for (size_t i = 0; i < num_channels_; ++i) {
|
||||
channels_[i]->PushBack(append_this[i], length, index);
|
||||
@ -162,9 +162,9 @@ size_t AudioMultiVector::ReadInterleavedFromEnd(size_t length,
|
||||
void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this,
|
||||
size_t length,
|
||||
size_t position) {
|
||||
assert(num_channels_ == insert_this.num_channels_);
|
||||
RTC_DCHECK_EQ(num_channels_, insert_this.num_channels_);
|
||||
// Cap |length| at the length of |insert_this|.
|
||||
assert(length <= insert_this.Size());
|
||||
RTC_DCHECK_LE(length, insert_this.Size());
|
||||
length = std::min(length, insert_this.Size());
|
||||
if (num_channels_ == insert_this.num_channels_) {
|
||||
for (size_t i = 0; i < num_channels_; ++i) {
|
||||
@ -175,7 +175,7 @@ void AudioMultiVector::OverwriteAt(const AudioMultiVector& insert_this,
|
||||
|
||||
void AudioMultiVector::CrossFade(const AudioMultiVector& append_this,
|
||||
size_t fade_length) {
|
||||
assert(num_channels_ == append_this.num_channels_);
|
||||
RTC_DCHECK_EQ(num_channels_, append_this.num_channels_);
|
||||
if (num_channels_ == append_this.num_channels_) {
|
||||
for (size_t i = 0; i < num_channels_; ++i) {
|
||||
channels_[i]->CrossFade(append_this[i], fade_length);
|
||||
@ -188,7 +188,7 @@ size_t AudioMultiVector::Channels() const {
|
||||
}
|
||||
|
||||
size_t AudioMultiVector::Size() const {
|
||||
assert(channels_[0]);
|
||||
RTC_DCHECK(channels_[0]);
|
||||
return channels_[0]->Size();
|
||||
}
|
||||
|
||||
@ -202,13 +202,13 @@ void AudioMultiVector::AssertSize(size_t required_size) {
|
||||
}
|
||||
|
||||
bool AudioMultiVector::Empty() const {
|
||||
assert(channels_[0]);
|
||||
RTC_DCHECK(channels_[0]);
|
||||
return channels_[0]->Empty();
|
||||
}
|
||||
|
||||
void AudioMultiVector::CopyChannel(size_t from_channel, size_t to_channel) {
|
||||
assert(from_channel < num_channels_);
|
||||
assert(to_channel < num_channels_);
|
||||
RTC_DCHECK_LT(from_channel, num_channels_);
|
||||
RTC_DCHECK_LT(to_channel, num_channels_);
|
||||
channels_[from_channel]->CopyTo(channels_[to_channel]);
|
||||
}
|
||||
|
||||
|
||||
@ -247,8 +247,8 @@ void AudioVector::OverwriteAt(const int16_t* insert_this,
|
||||
void AudioVector::CrossFade(const AudioVector& append_this,
|
||||
size_t fade_length) {
|
||||
// Fade length cannot be longer than the current vector or |append_this|.
|
||||
assert(fade_length <= Size());
|
||||
assert(fade_length <= append_this.Size());
|
||||
RTC_DCHECK_LE(fade_length, Size());
|
||||
RTC_DCHECK_LE(fade_length, append_this.Size());
|
||||
fade_length = std::min(fade_length, Size());
|
||||
fade_length = std::min(fade_length, append_this.Size());
|
||||
size_t position = Size() - fade_length + begin_index_;
|
||||
@ -265,7 +265,7 @@ void AudioVector::CrossFade(const AudioVector& append_this,
|
||||
(16384 - alpha) * append_this[i] + 8192) >>
|
||||
14;
|
||||
}
|
||||
assert(alpha >= 0); // Verify that the slope was correct.
|
||||
RTC_DCHECK_GE(alpha, 0); // Verify that the slope was correct.
|
||||
// Append what is left of |append_this|.
|
||||
size_t samples_to_push_back = append_this.Size() - fade_length;
|
||||
if (samples_to_push_back > 0)
|
||||
|
||||
@ -136,7 +136,7 @@ void BackgroundNoise::GenerateBackgroundNoise(
|
||||
int16_t* buffer) {
|
||||
constexpr size_t kNoiseLpcOrder = kMaxLpcOrder;
|
||||
int16_t scaled_random_vector[kMaxSampleRate / 8000 * 125];
|
||||
assert(num_noise_samples <= (kMaxSampleRate / 8000 * 125));
|
||||
RTC_DCHECK_LE(num_noise_samples, (kMaxSampleRate / 8000 * 125));
|
||||
RTC_DCHECK_GE(random_vector.size(), num_noise_samples);
|
||||
int16_t* noise_samples = &buffer[kNoiseLpcOrder];
|
||||
if (initialized()) {
|
||||
@ -178,44 +178,44 @@ void BackgroundNoise::GenerateBackgroundNoise(
|
||||
}
|
||||
|
||||
int32_t BackgroundNoise::Energy(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].energy;
|
||||
}
|
||||
|
||||
void BackgroundNoise::SetMuteFactor(size_t channel, int16_t value) {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
channel_parameters_[channel].mute_factor = value;
|
||||
}
|
||||
|
||||
int16_t BackgroundNoise::MuteFactor(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].mute_factor;
|
||||
}
|
||||
|
||||
const int16_t* BackgroundNoise::Filter(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].filter;
|
||||
}
|
||||
|
||||
const int16_t* BackgroundNoise::FilterState(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].filter_state;
|
||||
}
|
||||
|
||||
void BackgroundNoise::SetFilterState(size_t channel,
|
||||
rtc::ArrayView<const int16_t> input) {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
size_t length = std::min(input.size(), kMaxLpcOrder);
|
||||
memcpy(channel_parameters_[channel].filter_state, input.data(),
|
||||
length * sizeof(int16_t));
|
||||
}
|
||||
|
||||
int16_t BackgroundNoise::Scale(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].scale;
|
||||
}
|
||||
int16_t BackgroundNoise::ScaleShift(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].scale_shift;
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ void BackgroundNoise::IncrementEnergyThreshold(size_t channel,
|
||||
// to the limited-width operations, it is not exactly the same. The
|
||||
// difference should be inaudible, but bit-exactness would not be
|
||||
// maintained.
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
ChannelParameters& parameters = channel_parameters_[channel];
|
||||
int32_t temp_energy =
|
||||
(kThresholdIncrement * parameters.low_energy_update_threshold) >> 16;
|
||||
@ -278,7 +278,7 @@ void BackgroundNoise::SaveParameters(size_t channel,
|
||||
const int16_t* filter_state,
|
||||
int32_t sample_energy,
|
||||
int32_t residual_energy) {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
ChannelParameters& parameters = channel_parameters_[channel];
|
||||
memcpy(parameters.filter, lpc_coefficients,
|
||||
(kMaxLpcOrder + 1) * sizeof(int16_t));
|
||||
|
||||
@ -45,8 +45,8 @@ int ComfortNoise::UpdateParameters(const Packet& packet) {
|
||||
|
||||
int ComfortNoise::Generate(size_t requested_length, AudioMultiVector* output) {
|
||||
// TODO(hlundin): Change to an enumerator and skip assert.
|
||||
assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
|
||||
fs_hz_ == 48000);
|
||||
RTC_DCHECK(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
|
||||
fs_hz_ == 48000);
|
||||
// Not adapted for multi-channel yet.
|
||||
if (output->Channels() != 1) {
|
||||
RTC_LOG(LS_ERROR) << "No multi-channel support";
|
||||
|
||||
@ -96,7 +96,8 @@ void DecisionLogic::SoftReset() {
|
||||
|
||||
void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) {
|
||||
// TODO(hlundin): Change to an enumerator and skip assert.
|
||||
assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
|
||||
RTC_DCHECK(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 ||
|
||||
fs_hz == 48000);
|
||||
sample_rate_ = fs_hz;
|
||||
output_size_samples_ = output_size_samples;
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ int DspHelper::RampSignal(AudioMultiVector* signal,
|
||||
size_t length,
|
||||
int factor,
|
||||
int increment) {
|
||||
assert(start_index + length <= signal->Size());
|
||||
RTC_DCHECK_LE(start_index + length, signal->Size());
|
||||
if (start_index + length > signal->Size()) {
|
||||
// Wrong parameters. Do nothing and return the scale factor unaltered.
|
||||
return factor;
|
||||
@ -355,7 +355,7 @@ int DspHelper::DownsampleTo4kHz(const int16_t* input,
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assert(false);
|
||||
RTC_NOTREACHED();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,9 +48,10 @@ Expand::Expand(BackgroundNoise* background_noise,
|
||||
stop_muting_(false),
|
||||
expand_duration_samples_(0),
|
||||
channel_parameters_(new ChannelParameters[num_channels_]) {
|
||||
assert(fs == 8000 || fs == 16000 || fs == 32000 || fs == 48000);
|
||||
assert(fs <= static_cast<int>(kMaxSampleRate)); // Should not be possible.
|
||||
assert(num_channels_ > 0);
|
||||
RTC_DCHECK(fs == 8000 || fs == 16000 || fs == 32000 || fs == 48000);
|
||||
RTC_DCHECK_LE(fs,
|
||||
static_cast<int>(kMaxSampleRate)); // Should not be possible.
|
||||
RTC_DCHECK_GT(num_channels_, 0);
|
||||
memset(expand_lags_, 0, sizeof(expand_lags_));
|
||||
Reset();
|
||||
}
|
||||
@ -91,7 +92,7 @@ int Expand::Process(AudioMultiVector* output) {
|
||||
// Extract a noise segment.
|
||||
size_t rand_length = max_lag_;
|
||||
// This only applies to SWB where length could be larger than 256.
|
||||
assert(rand_length <= kMaxSampleRate / 8000 * 120 + 30);
|
||||
RTC_DCHECK_LE(rand_length, kMaxSampleRate / 8000 * 120 + 30);
|
||||
GenerateRandomVector(2, rand_length, random_vector);
|
||||
}
|
||||
|
||||
@ -110,8 +111,8 @@ int Expand::Process(AudioMultiVector* output) {
|
||||
ChannelParameters& parameters = channel_parameters_[channel_ix];
|
||||
if (current_lag_index_ == 0) {
|
||||
// Use only expand_vector0.
|
||||
assert(expansion_vector_position + temp_length <=
|
||||
parameters.expand_vector0.Size());
|
||||
RTC_DCHECK_LE(expansion_vector_position + temp_length,
|
||||
parameters.expand_vector0.Size());
|
||||
parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position,
|
||||
voiced_vector_storage);
|
||||
} else if (current_lag_index_ == 1) {
|
||||
@ -126,10 +127,10 @@ int Expand::Process(AudioMultiVector* output) {
|
||||
voiced_vector_storage, temp_length);
|
||||
} else if (current_lag_index_ == 2) {
|
||||
// Mix 1/2 of expand_vector0 with 1/2 of expand_vector1.
|
||||
assert(expansion_vector_position + temp_length <=
|
||||
parameters.expand_vector0.Size());
|
||||
assert(expansion_vector_position + temp_length <=
|
||||
parameters.expand_vector1.Size());
|
||||
RTC_DCHECK_LE(expansion_vector_position + temp_length,
|
||||
parameters.expand_vector0.Size());
|
||||
RTC_DCHECK_LE(expansion_vector_position + temp_length,
|
||||
parameters.expand_vector1.Size());
|
||||
|
||||
std::unique_ptr<int16_t[]> temp_0(new int16_t[temp_length]);
|
||||
parameters.expand_vector0.CopyTo(temp_length, expansion_vector_position,
|
||||
@ -303,7 +304,7 @@ int Expand::Process(AudioMultiVector* output) {
|
||||
if (channel_ix == 0) {
|
||||
output->AssertSize(current_lag);
|
||||
} else {
|
||||
assert(output->Size() == current_lag);
|
||||
RTC_DCHECK_EQ(output->Size(), current_lag);
|
||||
}
|
||||
(*output)[channel_ix].OverwriteAt(temp_data, current_lag, 0);
|
||||
}
|
||||
@ -465,7 +466,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) {
|
||||
size_t start_index = std::min(distortion_lag, correlation_lag);
|
||||
size_t correlation_lags = static_cast<size_t>(
|
||||
WEBRTC_SPL_ABS_W16((distortion_lag - correlation_lag)) + 1);
|
||||
assert(correlation_lags <= static_cast<size_t>(99 * fs_mult + 1));
|
||||
RTC_DCHECK_LE(correlation_lags, static_cast<size_t>(99 * fs_mult + 1));
|
||||
|
||||
for (size_t channel_ix = 0; channel_ix < num_channels_; ++channel_ix) {
|
||||
ChannelParameters& parameters = channel_parameters_[channel_ix];
|
||||
@ -659,7 +660,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) {
|
||||
// |kRandomTableSize|.
|
||||
memcpy(random_vector, RandomVector::kRandomTable,
|
||||
sizeof(int16_t) * RandomVector::kRandomTableSize);
|
||||
assert(noise_length <= kMaxSampleRate / 8000 * 120 + 30);
|
||||
RTC_DCHECK_LE(noise_length, kMaxSampleRate / 8000 * 120 + 30);
|
||||
random_vector_->IncreaseSeedIncrement(2);
|
||||
random_vector_->Generate(
|
||||
noise_length - RandomVector::kRandomTableSize,
|
||||
|
||||
@ -59,7 +59,7 @@ class Expand {
|
||||
|
||||
// Returns the mute factor for |channel|.
|
||||
int16_t MuteFactor(size_t channel) const {
|
||||
assert(channel < num_channels_);
|
||||
RTC_DCHECK_LT(channel, num_channels_);
|
||||
return channel_parameters_[channel].mute_factor;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ Merge::Merge(int fs_hz,
|
||||
expand_(expand),
|
||||
sync_buffer_(sync_buffer),
|
||||
expanded_(num_channels_) {
|
||||
assert(num_channels_ > 0);
|
||||
RTC_DCHECK_GT(num_channels_, 0);
|
||||
}
|
||||
|
||||
Merge::~Merge() = default;
|
||||
@ -47,9 +47,9 @@ size_t Merge::Process(int16_t* input,
|
||||
size_t input_length,
|
||||
AudioMultiVector* output) {
|
||||
// TODO(hlundin): Change to an enumerator and skip assert.
|
||||
assert(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
|
||||
fs_hz_ == 48000);
|
||||
assert(fs_hz_ <= kMaxSampleRate); // Should not be possible.
|
||||
RTC_DCHECK(fs_hz_ == 8000 || fs_hz_ == 16000 || fs_hz_ == 32000 ||
|
||||
fs_hz_ == 48000);
|
||||
RTC_DCHECK_LE(fs_hz_, kMaxSampleRate); // Should not be possible.
|
||||
if (input_length == 0) {
|
||||
return 0;
|
||||
}
|
||||
@ -64,7 +64,7 @@ size_t Merge::Process(int16_t* input,
|
||||
input_vector.PushBackInterleaved(
|
||||
rtc::ArrayView<const int16_t>(input, input_length));
|
||||
size_t input_length_per_channel = input_vector.Size();
|
||||
assert(input_length_per_channel == input_length / num_channels_);
|
||||
RTC_DCHECK_EQ(input_length_per_channel, input_length / num_channels_);
|
||||
|
||||
size_t best_correlation_index = 0;
|
||||
size_t output_length = 0;
|
||||
@ -142,10 +142,10 @@ size_t Merge::Process(int16_t* input,
|
||||
|
||||
output_length = best_correlation_index + input_length_per_channel;
|
||||
if (channel == 0) {
|
||||
assert(output->Empty()); // Output should be empty at this point.
|
||||
RTC_DCHECK(output->Empty()); // Output should be empty at this point.
|
||||
output->AssertSize(output_length);
|
||||
} else {
|
||||
assert(output->Size() == output_length);
|
||||
RTC_DCHECK_EQ(output->Size(), output_length);
|
||||
}
|
||||
(*output)[channel].OverwriteAt(temp_data_.data(), output_length, 0);
|
||||
}
|
||||
@ -165,7 +165,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
|
||||
// Check how much data that is left since earlier.
|
||||
*old_length = sync_buffer_->FutureLength();
|
||||
// Should never be less than overlap_length.
|
||||
assert(*old_length >= expand_->overlap_length());
|
||||
RTC_DCHECK_GE(*old_length, expand_->overlap_length());
|
||||
// Generate data to merge the overlap with using expand.
|
||||
expand_->SetParametersForMergeAfterExpand();
|
||||
|
||||
@ -182,7 +182,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
|
||||
// This is the truncated length.
|
||||
}
|
||||
// This assert should always be true thanks to the if statement above.
|
||||
assert(210 * kMaxSampleRate / 8000 >= *old_length);
|
||||
RTC_DCHECK_GE(210 * kMaxSampleRate / 8000, *old_length);
|
||||
|
||||
AudioMultiVector expanded_temp(num_channels_);
|
||||
expand_->Process(&expanded_temp);
|
||||
@ -191,8 +191,8 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
|
||||
expanded_.Clear();
|
||||
// Copy what is left since earlier into the expanded vector.
|
||||
expanded_.PushBackFromIndex(*sync_buffer_, sync_buffer_->next_index());
|
||||
assert(expanded_.Size() == *old_length);
|
||||
assert(expanded_temp.Size() > 0);
|
||||
RTC_DCHECK_EQ(expanded_.Size(), *old_length);
|
||||
RTC_DCHECK_GT(expanded_temp.Size(), 0);
|
||||
// Do "ugly" copy and paste from the expanded in order to generate more data
|
||||
// to correlate (but not interpolate) with.
|
||||
const size_t required_length = static_cast<size_t>((120 + 80 + 2) * fs_mult_);
|
||||
@ -204,7 +204,7 @@ size_t Merge::GetExpandedSignal(size_t* old_length, size_t* expand_period) {
|
||||
// Trim the length to exactly |required_length|.
|
||||
expanded_.PopBack(expanded_.Size() - required_length);
|
||||
}
|
||||
assert(expanded_.Size() >= required_length);
|
||||
RTC_DCHECK_GE(expanded_.Size(), required_length);
|
||||
return required_length;
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ size_t Merge::CorrelateAndPeakSearch(size_t start_position,
|
||||
while (((best_correlation_index + input_length) <
|
||||
(timestamps_per_call_ + expand_->overlap_length())) ||
|
||||
((best_correlation_index + input_length) < start_position)) {
|
||||
assert(false); // Should never happen.
|
||||
RTC_NOTREACHED(); // Should never happen.
|
||||
best_correlation_index += expand_period; // Jump one lag ahead.
|
||||
}
|
||||
return best_correlation_index;
|
||||
|
||||
@ -44,7 +44,7 @@ NackTracker* NackTracker::Create(int nack_threshold_packets) {
|
||||
}
|
||||
|
||||
void NackTracker::UpdateSampleRate(int sample_rate_hz) {
|
||||
assert(sample_rate_hz > 0);
|
||||
RTC_DCHECK_GT(sample_rate_hz, 0);
|
||||
sample_rate_khz_ = sample_rate_hz / 1000;
|
||||
}
|
||||
|
||||
@ -120,9 +120,9 @@ uint32_t NackTracker::EstimateTimestamp(uint16_t sequence_num) {
|
||||
}
|
||||
|
||||
void NackTracker::AddToList(uint16_t sequence_number_current_received_rtp) {
|
||||
assert(!any_rtp_decoded_ ||
|
||||
IsNewerSequenceNumber(sequence_number_current_received_rtp,
|
||||
sequence_num_last_decoded_rtp_));
|
||||
RTC_DCHECK(!any_rtp_decoded_ ||
|
||||
IsNewerSequenceNumber(sequence_number_current_received_rtp,
|
||||
sequence_num_last_decoded_rtp_));
|
||||
|
||||
// Packets with sequence numbers older than |upper_bound_missing| are
|
||||
// considered missing, and the rest are considered late.
|
||||
@ -164,7 +164,7 @@ void NackTracker::UpdateLastDecodedPacket(uint16_t sequence_number,
|
||||
++it)
|
||||
it->second.time_to_play_ms = TimeToPlay(it->second.estimated_timestamp);
|
||||
} else {
|
||||
assert(sequence_number == sequence_num_last_decoded_rtp_);
|
||||
RTC_DCHECK_EQ(sequence_number, sequence_num_last_decoded_rtp_);
|
||||
|
||||
// Same sequence number as before. 10 ms is elapsed, update estimations for
|
||||
// time-to-play.
|
||||
|
||||
@ -343,7 +343,7 @@ void NetEqImpl::RemoveAllPayloadTypes() {
|
||||
bool NetEqImpl::SetMinimumDelay(int delay_ms) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (delay_ms >= 0 && delay_ms <= 10000) {
|
||||
assert(controller_.get());
|
||||
RTC_DCHECK(controller_.get());
|
||||
return controller_->SetMinimumDelay(
|
||||
std::max(delay_ms - output_delay_chain_ms_, 0));
|
||||
}
|
||||
@ -353,7 +353,7 @@ bool NetEqImpl::SetMinimumDelay(int delay_ms) {
|
||||
bool NetEqImpl::SetMaximumDelay(int delay_ms) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (delay_ms >= 0 && delay_ms <= 10000) {
|
||||
assert(controller_.get());
|
||||
RTC_DCHECK(controller_.get());
|
||||
return controller_->SetMaximumDelay(
|
||||
std::max(delay_ms - output_delay_chain_ms_, 0));
|
||||
}
|
||||
@ -392,7 +392,7 @@ int NetEqImpl::FilteredCurrentDelayMs() const {
|
||||
|
||||
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
|
||||
MutexLock lock(&mutex_);
|
||||
assert(decoder_database_.get());
|
||||
RTC_DCHECK(decoder_database_.get());
|
||||
*stats = CurrentNetworkStatisticsInternal();
|
||||
stats_->GetNetworkStatistics(decoder_frame_length_, stats);
|
||||
// Compensate for output delay chain.
|
||||
@ -409,13 +409,13 @@ NetEqNetworkStatistics NetEqImpl::CurrentNetworkStatistics() const {
|
||||
}
|
||||
|
||||
NetEqNetworkStatistics NetEqImpl::CurrentNetworkStatisticsInternal() const {
|
||||
assert(decoder_database_.get());
|
||||
RTC_DCHECK(decoder_database_.get());
|
||||
NetEqNetworkStatistics stats;
|
||||
const size_t total_samples_in_buffers =
|
||||
packet_buffer_->NumSamplesInBuffer(decoder_frame_length_) +
|
||||
sync_buffer_->FutureLength();
|
||||
|
||||
assert(controller_.get());
|
||||
RTC_DCHECK(controller_.get());
|
||||
stats.preferred_buffer_size_ms = controller_->TargetLevelMs();
|
||||
stats.jitter_peaks_found = controller_->PeakFound();
|
||||
RTC_DCHECK_GT(fs_hz_, 0);
|
||||
@ -449,13 +449,13 @@ NetEqOperationsAndState NetEqImpl::GetOperationsAndState() const {
|
||||
|
||||
void NetEqImpl::EnableVad() {
|
||||
MutexLock lock(&mutex_);
|
||||
assert(vad_.get());
|
||||
RTC_DCHECK(vad_.get());
|
||||
vad_->Enable();
|
||||
}
|
||||
|
||||
void NetEqImpl::DisableVad() {
|
||||
MutexLock lock(&mutex_);
|
||||
assert(vad_.get());
|
||||
RTC_DCHECK(vad_.get());
|
||||
vad_->Disable();
|
||||
}
|
||||
|
||||
@ -506,8 +506,8 @@ void NetEqImpl::FlushBuffers() {
|
||||
MutexLock lock(&mutex_);
|
||||
RTC_LOG(LS_VERBOSE) << "FlushBuffers";
|
||||
packet_buffer_->Flush(stats_.get());
|
||||
assert(sync_buffer_.get());
|
||||
assert(expand_.get());
|
||||
RTC_DCHECK(sync_buffer_.get());
|
||||
RTC_DCHECK(expand_.get());
|
||||
sync_buffer_->Flush();
|
||||
sync_buffer_->set_next_index(sync_buffer_->next_index() -
|
||||
expand_->overlap_length());
|
||||
@ -797,12 +797,12 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header,
|
||||
size_t channels = 1;
|
||||
if (!decoder_database_->IsComfortNoise(payload_type)) {
|
||||
AudioDecoder* decoder = decoder_database_->GetDecoder(payload_type);
|
||||
assert(decoder); // Payloads are already checked to be valid.
|
||||
RTC_DCHECK(decoder); // Payloads are already checked to be valid.
|
||||
channels = decoder->Channels();
|
||||
}
|
||||
const DecoderDatabase::DecoderInfo* decoder_info =
|
||||
decoder_database_->GetDecoderInfo(payload_type);
|
||||
assert(decoder_info);
|
||||
RTC_DCHECK(decoder_info);
|
||||
if (decoder_info->SampleRateHz() != fs_hz_ ||
|
||||
channels != algorithm_buffer_->Channels()) {
|
||||
SetSampleRateAndChannels(decoder_info->SampleRateHz(), channels);
|
||||
@ -816,7 +816,7 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header,
|
||||
|
||||
const DecoderDatabase::DecoderInfo* dec_info =
|
||||
decoder_database_->GetDecoderInfo(main_payload_type);
|
||||
assert(dec_info); // Already checked that the payload type is known.
|
||||
RTC_DCHECK(dec_info); // Already checked that the payload type is known.
|
||||
|
||||
NetEqController::PacketArrivedInfo info;
|
||||
info.is_cng_or_dtmf = dec_info->IsComfortNoise() || dec_info->IsDtmf();
|
||||
@ -894,7 +894,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
|
||||
int decode_return_value =
|
||||
Decode(&packet_list, &operation, &length, &speech_type);
|
||||
|
||||
assert(vad_.get());
|
||||
RTC_DCHECK(vad_.get());
|
||||
bool sid_frame_available =
|
||||
(operation == Operation::kRfc3389Cng && !packet_list.empty());
|
||||
vad_->Update(decoded_buffer_.get(), static_cast<size_t>(length), speech_type,
|
||||
@ -965,7 +965,7 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
|
||||
}
|
||||
case Operation::kUndefined: {
|
||||
RTC_LOG(LS_ERROR) << "Invalid operation kUndefined.";
|
||||
assert(false); // This should not happen.
|
||||
RTC_NOTREACHED(); // This should not happen.
|
||||
last_mode_ = Mode::kError;
|
||||
return kInvalidOperation;
|
||||
}
|
||||
@ -1101,7 +1101,7 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
*play_dtmf = false;
|
||||
*operation = Operation::kUndefined;
|
||||
|
||||
assert(sync_buffer_.get());
|
||||
RTC_DCHECK(sync_buffer_.get());
|
||||
uint32_t end_timestamp = sync_buffer_->end_timestamp();
|
||||
if (!new_codec_) {
|
||||
const uint32_t five_seconds_samples = 5 * fs_hz_;
|
||||
@ -1128,7 +1128,7 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
// Don't use this packet, discard it.
|
||||
if (packet_buffer_->DiscardNextPacket(stats_.get()) !=
|
||||
PacketBuffer::kOK) {
|
||||
assert(false); // Must be ok by design.
|
||||
RTC_NOTREACHED(); // Must be ok by design.
|
||||
}
|
||||
// Check buffer again.
|
||||
if (!new_codec_) {
|
||||
@ -1139,7 +1139,7 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
}
|
||||
}
|
||||
|
||||
assert(expand_.get());
|
||||
RTC_DCHECK(expand_.get());
|
||||
const int samples_left = static_cast<int>(sync_buffer_->FutureLength() -
|
||||
expand_->overlap_length());
|
||||
if (last_mode_ == Mode::kAccelerateSuccess ||
|
||||
@ -1159,8 +1159,8 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
}
|
||||
|
||||
// Get instruction.
|
||||
assert(sync_buffer_.get());
|
||||
assert(expand_.get());
|
||||
RTC_DCHECK(sync_buffer_.get());
|
||||
RTC_DCHECK(expand_.get());
|
||||
generated_noise_samples =
|
||||
generated_noise_stopwatch_
|
||||
? generated_noise_stopwatch_->ElapsedTicks() * output_size_samples_ +
|
||||
@ -1228,7 +1228,7 @@ int NetEqImpl::GetDecision(Operation* operation,
|
||||
// Check conditions for reset.
|
||||
if (new_codec_ || *operation == Operation::kUndefined) {
|
||||
// The only valid reason to get kUndefined is that new_codec_ is set.
|
||||
assert(new_codec_);
|
||||
RTC_DCHECK(new_codec_);
|
||||
if (*play_dtmf && !packet) {
|
||||
timestamp_ = dtmf_event->timestamp;
|
||||
} else {
|
||||
@ -1400,7 +1400,7 @@ int NetEqImpl::Decode(PacketList* packet_list,
|
||||
uint8_t payload_type = packet.payload_type;
|
||||
if (!decoder_database_->IsComfortNoise(payload_type)) {
|
||||
decoder = decoder_database_->GetDecoder(payload_type);
|
||||
assert(decoder);
|
||||
RTC_DCHECK(decoder);
|
||||
if (!decoder) {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< "Unknown payload type " << static_cast<int>(payload_type);
|
||||
@ -1413,7 +1413,7 @@ int NetEqImpl::Decode(PacketList* packet_list,
|
||||
// We have a new decoder. Re-init some values.
|
||||
const DecoderDatabase::DecoderInfo* decoder_info =
|
||||
decoder_database_->GetDecoderInfo(payload_type);
|
||||
assert(decoder_info);
|
||||
RTC_DCHECK(decoder_info);
|
||||
if (!decoder_info) {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< "Unknown payload type " << static_cast<int>(payload_type);
|
||||
@ -1485,8 +1485,8 @@ int NetEqImpl::Decode(PacketList* packet_list,
|
||||
// Don't increment timestamp if codec returned CNG speech type
|
||||
// since in this case, the we will increment the CNGplayedTS counter.
|
||||
// Increase with number of samples per channel.
|
||||
assert(*decoded_length == 0 ||
|
||||
(decoder && decoder->Channels() == sync_buffer_->Channels()));
|
||||
RTC_DCHECK(*decoded_length == 0 ||
|
||||
(decoder && decoder->Channels() == sync_buffer_->Channels()));
|
||||
sync_buffer_->IncreaseEndTimestamp(
|
||||
*decoded_length / static_cast<int>(sync_buffer_->Channels()));
|
||||
}
|
||||
@ -1535,16 +1535,16 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list,
|
||||
// Do decoding.
|
||||
while (!packet_list->empty() && !decoder_database_->IsComfortNoise(
|
||||
packet_list->front().payload_type)) {
|
||||
assert(decoder); // At this point, we must have a decoder object.
|
||||
RTC_DCHECK(decoder); // At this point, we must have a decoder object.
|
||||
// The number of channels in the |sync_buffer_| should be the same as the
|
||||
// number decoder channels.
|
||||
assert(sync_buffer_->Channels() == decoder->Channels());
|
||||
assert(decoded_buffer_length_ >= kMaxFrameSize * decoder->Channels());
|
||||
assert(operation == Operation::kNormal ||
|
||||
operation == Operation::kAccelerate ||
|
||||
operation == Operation::kFastAccelerate ||
|
||||
operation == Operation::kMerge ||
|
||||
operation == Operation::kPreemptiveExpand);
|
||||
RTC_DCHECK_EQ(sync_buffer_->Channels(), decoder->Channels());
|
||||
RTC_DCHECK_GE(decoded_buffer_length_, kMaxFrameSize * decoder->Channels());
|
||||
RTC_DCHECK(operation == Operation::kNormal ||
|
||||
operation == Operation::kAccelerate ||
|
||||
operation == Operation::kFastAccelerate ||
|
||||
operation == Operation::kMerge ||
|
||||
operation == Operation::kPreemptiveExpand);
|
||||
|
||||
auto opt_result = packet_list->front().frame->Decode(
|
||||
rtc::ArrayView<int16_t>(&decoded_buffer_[*decoded_length],
|
||||
@ -1581,9 +1581,10 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list,
|
||||
|
||||
// If the list is not empty at this point, either a decoding error terminated
|
||||
// the while-loop, or list must hold exactly one CNG packet.
|
||||
assert(packet_list->empty() || *decoded_length < 0 ||
|
||||
(packet_list->size() == 1 && decoder_database_->IsComfortNoise(
|
||||
packet_list->front().payload_type)));
|
||||
RTC_DCHECK(
|
||||
packet_list->empty() || *decoded_length < 0 ||
|
||||
(packet_list->size() == 1 &&
|
||||
decoder_database_->IsComfortNoise(packet_list->front().payload_type)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1591,7 +1592,7 @@ void NetEqImpl::DoNormal(const int16_t* decoded_buffer,
|
||||
size_t decoded_length,
|
||||
AudioDecoder::SpeechType speech_type,
|
||||
bool play_dtmf) {
|
||||
assert(normal_.get());
|
||||
RTC_DCHECK(normal_.get());
|
||||
normal_->Process(decoded_buffer, decoded_length, last_mode_,
|
||||
algorithm_buffer_.get());
|
||||
if (decoded_length != 0) {
|
||||
@ -1614,7 +1615,7 @@ void NetEqImpl::DoMerge(int16_t* decoded_buffer,
|
||||
size_t decoded_length,
|
||||
AudioDecoder::SpeechType speech_type,
|
||||
bool play_dtmf) {
|
||||
assert(merge_.get());
|
||||
RTC_DCHECK(merge_.get());
|
||||
size_t new_length =
|
||||
merge_->Process(decoded_buffer, decoded_length, algorithm_buffer_.get());
|
||||
// Correction can be negative.
|
||||
@ -1775,7 +1776,7 @@ int NetEqImpl::DoAccelerate(int16_t* decoded_buffer,
|
||||
sync_buffer_->Size() - borrowed_samples_per_channel);
|
||||
sync_buffer_->PushFrontZeros(borrowed_samples_per_channel - length);
|
||||
algorithm_buffer_->PopFront(length);
|
||||
assert(algorithm_buffer_->Empty());
|
||||
RTC_DCHECK(algorithm_buffer_->Empty());
|
||||
} else {
|
||||
sync_buffer_->ReplaceAtIndex(
|
||||
*algorithm_buffer_, borrowed_samples_per_channel,
|
||||
@ -1864,7 +1865,7 @@ int NetEqImpl::DoPreemptiveExpand(int16_t* decoded_buffer,
|
||||
int NetEqImpl::DoRfc3389Cng(PacketList* packet_list, bool play_dtmf) {
|
||||
if (!packet_list->empty()) {
|
||||
// Must have exactly one SID frame at this point.
|
||||
assert(packet_list->size() == 1);
|
||||
RTC_DCHECK_EQ(packet_list->size(), 1);
|
||||
const Packet& packet = packet_list->front();
|
||||
if (!decoder_database_->IsComfortNoise(packet.payload_type)) {
|
||||
RTC_LOG(LS_ERROR) << "Trying to decode non-CNG payload as CNG.";
|
||||
@ -1947,14 +1948,14 @@ int NetEqImpl::DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf) {
|
||||
// // it must be copied to the speech buffer.
|
||||
// // TODO(hlundin): This code seems incorrect. (Legacy.) Write test and
|
||||
// // verify correct operation.
|
||||
// assert(false);
|
||||
// RTC_NOTREACHED();
|
||||
// // Must generate enough data to replace all of the |sync_buffer_|
|
||||
// // "future".
|
||||
// int required_length = sync_buffer_->FutureLength();
|
||||
// assert(dtmf_tone_generator_->initialized());
|
||||
// RTC_DCHECK(dtmf_tone_generator_->initialized());
|
||||
// dtmf_return_value = dtmf_tone_generator_->Generate(required_length,
|
||||
// algorithm_buffer_);
|
||||
// assert((size_t) required_length == algorithm_buffer_->Size());
|
||||
// RTC_DCHECK((size_t) required_length == algorithm_buffer_->Size());
|
||||
// if (dtmf_return_value < 0) {
|
||||
// algorithm_buffer_->Zeros(output_size_samples_);
|
||||
// return dtmf_return_value;
|
||||
@ -1964,7 +1965,7 @@ int NetEqImpl::DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf) {
|
||||
// // data.
|
||||
// // TODO(hlundin): It seems that this overwriting has gone lost.
|
||||
// // Not adapted for multi-channel yet.
|
||||
// assert(algorithm_buffer_->Channels() == 1);
|
||||
// RTC_DCHECK(algorithm_buffer_->Channels() == 1);
|
||||
// if (algorithm_buffer_->Channels() != 1) {
|
||||
// RTC_LOG(LS_WARNING) << "DTMF not supported for more than one channel";
|
||||
// return kStereoNotSupported;
|
||||
@ -2006,7 +2007,7 @@ int NetEqImpl::DtmfOverdub(const DtmfEvent& dtmf_event,
|
||||
if (dtmf_return_value == 0) {
|
||||
dtmf_return_value =
|
||||
dtmf_tone_generator_->Generate(overdub_length, &dtmf_output);
|
||||
assert(overdub_length == dtmf_output.Size());
|
||||
RTC_DCHECK_EQ(overdub_length, dtmf_output.Size());
|
||||
}
|
||||
dtmf_output.ReadInterleaved(overdub_length, &output[out_index]);
|
||||
return dtmf_return_value < 0 ? dtmf_return_value : 0;
|
||||
@ -2037,7 +2038,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples,
|
||||
next_packet = nullptr;
|
||||
if (!packet) {
|
||||
RTC_LOG(LS_ERROR) << "Should always be able to extract a packet here";
|
||||
assert(false); // Should always be able to extract a packet here.
|
||||
RTC_NOTREACHED(); // Should always be able to extract a packet here.
|
||||
return -1;
|
||||
}
|
||||
const uint64_t waiting_time_ms = packet->waiting_time->ElapsedMs();
|
||||
@ -2130,8 +2131,9 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
|
||||
RTC_LOG(LS_VERBOSE) << "SetSampleRateAndChannels " << fs_hz << " "
|
||||
<< channels;
|
||||
// TODO(hlundin): Change to an enumerator and skip assert.
|
||||
assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 || fs_hz == 48000);
|
||||
assert(channels > 0);
|
||||
RTC_DCHECK(fs_hz == 8000 || fs_hz == 16000 || fs_hz == 32000 ||
|
||||
fs_hz == 48000);
|
||||
RTC_DCHECK_GT(channels, 0);
|
||||
|
||||
// Before changing the sample rate, end and report any ongoing expand event.
|
||||
stats_->EndExpandEvent(fs_hz_);
|
||||
@ -2147,7 +2149,7 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
|
||||
cng_decoder->Reset();
|
||||
|
||||
// Reinit post-decode VAD with new sample rate.
|
||||
assert(vad_.get()); // Cannot be NULL here.
|
||||
RTC_DCHECK(vad_.get()); // Cannot be NULL here.
|
||||
vad_->Init();
|
||||
|
||||
// Delete algorithm buffer and create a new one.
|
||||
@ -2190,8 +2192,8 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
|
||||
}
|
||||
|
||||
NetEqImpl::OutputType NetEqImpl::LastOutputType() {
|
||||
assert(vad_.get());
|
||||
assert(expand_.get());
|
||||
RTC_DCHECK(vad_.get());
|
||||
RTC_DCHECK(expand_.get());
|
||||
if (last_mode_ == Mode::kCodecInternalCng ||
|
||||
last_mode_ == Mode::kRfc3389Cng) {
|
||||
return OutputType::kCNG;
|
||||
|
||||
@ -41,7 +41,7 @@ bool RedPayloadSplitter::SplitRed(PacketList* packet_list) {
|
||||
PacketList::iterator it = packet_list->begin();
|
||||
while (it != packet_list->end()) {
|
||||
const Packet& red_packet = *it;
|
||||
assert(!red_packet.payload.empty());
|
||||
RTC_DCHECK(!red_packet.payload.empty());
|
||||
const uint8_t* payload_ptr = red_packet.payload.data();
|
||||
size_t payload_length = red_packet.payload.size();
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ Packet CreateRedPayload(size_t num_payloads,
|
||||
rtc::checked_cast<int>((num_payloads - i - 1) * timestamp_offset);
|
||||
*payload_ptr = this_offset >> 6;
|
||||
++payload_ptr;
|
||||
assert(kPayloadLength <= 1023); // Max length described by 10 bits.
|
||||
RTC_DCHECK_LE(kPayloadLength, 1023); // Max length described by 10 bits.
|
||||
*payload_ptr = ((this_offset & 0x3F) << 2) | (kPayloadLength >> 8);
|
||||
++payload_ptr;
|
||||
*payload_ptr = kPayloadLength & 0xFF;
|
||||
|
||||
@ -375,7 +375,7 @@ uint16_t StatisticsCalculator::CalculateQ14Ratio(size_t numerator,
|
||||
return 0;
|
||||
} else if (numerator < denominator) {
|
||||
// Ratio must be smaller than 1 in Q14.
|
||||
assert((numerator << 14) / denominator < (1 << 14));
|
||||
RTC_DCHECK_LT((numerator << 14) / denominator, (1 << 14));
|
||||
return static_cast<uint16_t>((numerator << 14) / denominator);
|
||||
} else {
|
||||
// Will not produce a ratio larger than 1, since this is probably an error.
|
||||
|
||||
@ -28,7 +28,7 @@ void SyncBuffer::PushBack(const AudioMultiVector& append_this) {
|
||||
next_index_ -= samples_added;
|
||||
} else {
|
||||
// This means that we are pushing out future data that was never used.
|
||||
// assert(false);
|
||||
// RTC_NOTREACHED();
|
||||
// TODO(hlundin): This assert must be disabled to support 60 ms frames.
|
||||
// This should not happen even for 60 ms frames, but it does. Investigate
|
||||
// why.
|
||||
|
||||
@ -66,7 +66,7 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input,
|
||||
DspHelper::PeakDetection(auto_correlation_, kCorrelationLen, kNumPeaks,
|
||||
fs_mult_, &peak_index, &peak_value);
|
||||
// Assert that |peak_index| stays within boundaries.
|
||||
assert(peak_index <= (2 * kCorrelationLen - 1) * fs_mult_);
|
||||
RTC_DCHECK_LE(peak_index, (2 * kCorrelationLen - 1) * fs_mult_);
|
||||
|
||||
// Compensate peak_index for displaced starting position. The displacement
|
||||
// happens in AutoCorrelation(). Here, |kMinLag| is in the down-sampled 4 kHz
|
||||
@ -74,8 +74,9 @@ TimeStretch::ReturnCodes TimeStretch::Process(const int16_t* input,
|
||||
// multiplication by fs_mult_ * 2.
|
||||
peak_index += kMinLag * fs_mult_ * 2;
|
||||
// Assert that |peak_index| stays within boundaries.
|
||||
assert(peak_index >= static_cast<size_t>(20 * fs_mult_));
|
||||
assert(peak_index <= 20 * fs_mult_ + (2 * kCorrelationLen - 1) * fs_mult_);
|
||||
RTC_DCHECK_GE(peak_index, static_cast<size_t>(20 * fs_mult_));
|
||||
RTC_DCHECK_LE(peak_index,
|
||||
20 * fs_mult_ + (2 * kCorrelationLen - 1) * fs_mult_);
|
||||
|
||||
// Calculate scaling to ensure that |peak_index| samples can be square-summed
|
||||
// without overflowing.
|
||||
|
||||
@ -42,9 +42,9 @@ class TimeStretch {
|
||||
num_channels_(num_channels),
|
||||
background_noise_(background_noise),
|
||||
max_input_value_(0) {
|
||||
assert(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 ||
|
||||
sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000);
|
||||
assert(num_channels_ > 0);
|
||||
RTC_DCHECK(sample_rate_hz_ == 8000 || sample_rate_hz_ == 16000 ||
|
||||
sample_rate_hz_ == 32000 || sample_rate_hz_ == 48000);
|
||||
RTC_DCHECK_GT(num_channels_, 0);
|
||||
memset(auto_correlation_, 0, sizeof(auto_correlation_));
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ class OutputAudioFile : public AudioSink {
|
||||
}
|
||||
|
||||
bool WriteArray(const int16_t* audio, size_t num_samples) override {
|
||||
assert(out_file_);
|
||||
RTC_DCHECK(out_file_);
|
||||
return fwrite(audio, sizeof(*audio), num_samples, out_file_) == num_samples;
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ int main(int argc, char* argv[]) {
|
||||
printf("Input file: %s\n", args[1]);
|
||||
std::unique_ptr<webrtc::test::RtpFileSource> file_source(
|
||||
webrtc::test::RtpFileSource::Create(args[1]));
|
||||
assert(file_source.get());
|
||||
RTC_DCHECK(file_source.get());
|
||||
// Set RTP extension IDs.
|
||||
bool print_audio_level = false;
|
||||
if (absl::GetFlag(FLAGS_audio_level) != -1) {
|
||||
@ -151,7 +151,7 @@ int main(int argc, char* argv[]) {
|
||||
packet->ExtractRedHeaders(&red_headers);
|
||||
while (!red_headers.empty()) {
|
||||
webrtc::RTPHeader* red = red_headers.front();
|
||||
assert(red);
|
||||
RTC_DCHECK(red);
|
||||
fprintf(out_file, "* %5u %10u %10u %5i\n", red->sequenceNumber,
|
||||
red->timestamp, static_cast<unsigned int>(packet->time_ms()),
|
||||
red->payloadType);
|
||||
|
||||
@ -18,7 +18,7 @@ namespace test {
|
||||
uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type,
|
||||
size_t payload_length_samples,
|
||||
RTPHeader* rtp_header) {
|
||||
assert(rtp_header);
|
||||
RTC_DCHECK(rtp_header);
|
||||
if (!rtp_header) {
|
||||
return 0;
|
||||
}
|
||||
@ -31,7 +31,7 @@ uint32_t RtpGenerator::GetRtpHeader(uint8_t payload_type,
|
||||
rtp_header->numCSRCs = 0;
|
||||
|
||||
uint32_t this_send_time = next_send_time_ms_;
|
||||
assert(samples_per_ms_ > 0);
|
||||
RTC_DCHECK_GT(samples_per_ms_, 0);
|
||||
next_send_time_ms_ +=
|
||||
((1.0 + drift_factor_) * payload_length_samples) / samples_per_ms_;
|
||||
return this_send_time;
|
||||
|
||||
Reference in New Issue
Block a user