RTC_[D]CHECK_op: Remove superfluous casts
There's no longer any need to make the two arguments have the same signedness, so we can remove a bunch of superfluous (and sometimes dangerous) casts. It turned out I also had to fix the safe_cmp functions to properly handle enums that are implicitly convertible to integers. NOPRESUBMIT=true BUG=webrtc:6645 Review-Url: https://codereview.webrtc.org/2534683002 Cr-Commit-Position: refs/heads/master@{#15281}
This commit is contained in:
parent
af476c737f
commit
352444fcac
@ -110,14 +110,13 @@ void AudioTransportProxy::PullRenderData(int bits_per_sample,
|
||||
void* audio_data,
|
||||
int64_t* elapsed_time_ms,
|
||||
int64_t* ntp_time_ms) {
|
||||
RTC_DCHECK_EQ(static_cast<size_t>(bits_per_sample), 16);
|
||||
RTC_DCHECK_EQ(bits_per_sample, 16);
|
||||
RTC_DCHECK_GE(number_of_channels, 1);
|
||||
RTC_DCHECK_LE(number_of_channels, 2);
|
||||
RTC_DCHECK_GE(static_cast<int>(sample_rate),
|
||||
AudioProcessing::NativeRate::kSampleRate8kHz);
|
||||
RTC_DCHECK_GE(sample_rate, AudioProcessing::NativeRate::kSampleRate8kHz);
|
||||
|
||||
// 100 = 1 second / data duration (10 ms).
|
||||
RTC_DCHECK_EQ(static_cast<int>(number_of_frames * 100), sample_rate);
|
||||
RTC_DCHECK_EQ(number_of_frames * 100, sample_rate);
|
||||
|
||||
// 8 = bits per byte.
|
||||
RTC_DCHECK_LE(bits_per_sample / 8 * number_of_frames * number_of_channels,
|
||||
|
||||
@ -246,8 +246,7 @@ class FatalMessage {
|
||||
// remainder is zero.
|
||||
template <typename T>
|
||||
inline T CheckedDivExact(T a, T b) {
|
||||
RTC_CHECK_EQ(a % b, static_cast<T>(0)) << a << " is not evenly divisible by "
|
||||
<< b;
|
||||
RTC_CHECK_EQ(a % b, 0) << a << " is not evenly divisible by " << b;
|
||||
return a / b;
|
||||
}
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ size_t File::ReadAt(uint8_t* buffer, size_t length, size_t offset) {
|
||||
}
|
||||
|
||||
bool File::Seek(size_t offset) {
|
||||
RTC_DCHECK_LE(offset, static_cast<size_t>(std::numeric_limits<off_t>::max()));
|
||||
RTC_DCHECK_LE(offset, std::numeric_limits<off_t>::max());
|
||||
return lseek(file_, static_cast<off_t>(offset), SEEK_SET) != -1;
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ namespace {
|
||||
// Computes the positive remainder of x/n.
|
||||
template <typename T>
|
||||
T fdiv_remainder(T x, T n) {
|
||||
RTC_CHECK_GE(n, static_cast<T>(0));
|
||||
RTC_CHECK_GE(n, 0);
|
||||
T remainder = x % n;
|
||||
if (remainder < 0)
|
||||
remainder += n;
|
||||
|
||||
@ -145,26 +145,81 @@ RTC_SAFECMP_MAKE_OP(GtOp, >)
|
||||
RTC_SAFECMP_MAKE_OP(GeOp, >=)
|
||||
#undef RTC_SAFECMP_MAKE_OP
|
||||
|
||||
// Determines if the given type is an enum that converts implicitly to
|
||||
// an integral type.
|
||||
template <typename T>
|
||||
struct IsIntEnum {
|
||||
private:
|
||||
// This overload is used if the type is an enum, and unary plus
|
||||
// compiles and turns it into an integral type.
|
||||
template <typename X,
|
||||
typename std::enable_if<
|
||||
std::is_enum<X>::value &&
|
||||
std::is_integral<decltype(+std::declval<X>())>::value>::type* =
|
||||
nullptr>
|
||||
static int Test(int);
|
||||
|
||||
// Otherwise, this overload is used.
|
||||
template <typename>
|
||||
static char Test(...);
|
||||
|
||||
public:
|
||||
static constexpr bool value =
|
||||
std::is_same<decltype(Test<typename std::remove_reference<T>::type>(0)),
|
||||
int>::value;
|
||||
};
|
||||
|
||||
// Determines if the given type is integral, or an enum that
|
||||
// converts implicitly to an integral type.
|
||||
template <typename T>
|
||||
struct IsIntlike {
|
||||
private:
|
||||
using X = typename std::remove_reference<T>::type;
|
||||
|
||||
public:
|
||||
static constexpr bool value =
|
||||
std::is_integral<X>::value || IsIntEnum<X>::value;
|
||||
};
|
||||
|
||||
namespace test_enum_intlike {
|
||||
|
||||
enum E1 { e1 };
|
||||
enum { e2 };
|
||||
enum class E3 { e3 };
|
||||
struct S {};
|
||||
|
||||
static_assert(IsIntEnum<E1>::value, "");
|
||||
static_assert(IsIntEnum<decltype(e2)>::value, "");
|
||||
static_assert(!IsIntEnum<E3>::value, "");
|
||||
static_assert(!IsIntEnum<int>::value, "");
|
||||
static_assert(!IsIntEnum<float>::value, "");
|
||||
static_assert(!IsIntEnum<S>::value, "");
|
||||
|
||||
static_assert(IsIntlike<E1>::value, "");
|
||||
static_assert(IsIntlike<decltype(e2)>::value, "");
|
||||
static_assert(!IsIntlike<E3>::value, "");
|
||||
static_assert(IsIntlike<int>::value, "");
|
||||
static_assert(!IsIntlike<float>::value, "");
|
||||
static_assert(!IsIntlike<S>::value, "");
|
||||
|
||||
} // test_enum_intlike
|
||||
} // namespace safe_cmp_impl
|
||||
|
||||
#define RTC_SAFECMP_MAKE_FUN(name) \
|
||||
template < \
|
||||
typename T1, typename T2, \
|
||||
typename std::enable_if< \
|
||||
std::is_integral<typename std::remove_reference<T1>::type>::value && \
|
||||
std::is_integral<typename std::remove_reference<T2>::type>::value>:: \
|
||||
type* = nullptr> \
|
||||
inline bool name(T1 a, T2 b) { \
|
||||
return safe_cmp_impl::Cmp<safe_cmp_impl::name##Op>(a, b); \
|
||||
} \
|
||||
template <typename T1, typename T2, \
|
||||
typename std::enable_if< \
|
||||
!std::is_integral< \
|
||||
typename std::remove_reference<T1>::type>::value || \
|
||||
!std::is_integral<typename std::remove_reference<T2>::type>:: \
|
||||
value>::type* = nullptr> \
|
||||
inline bool name(T1&& a, T2&& b) { \
|
||||
return safe_cmp_impl::name##Op::Op(a, b); \
|
||||
#define RTC_SAFECMP_MAKE_FUN(name) \
|
||||
template <typename T1, typename T2, \
|
||||
typename std::enable_if< \
|
||||
safe_cmp_impl::IsIntlike<T1>::value && \
|
||||
safe_cmp_impl::IsIntlike<T2>::value>::type* = nullptr> \
|
||||
inline bool name(T1 a, T2 b) { \
|
||||
/* Unary plus here turns enums into real integral types. */ \
|
||||
return safe_cmp_impl::Cmp<safe_cmp_impl::name##Op>(+a, +b); \
|
||||
} \
|
||||
template <typename T1, typename T2, \
|
||||
typename std::enable_if< \
|
||||
!safe_cmp_impl::IsIntlike<T1>::value || \
|
||||
!safe_cmp_impl::IsIntlike<T2>::value>::type* = nullptr> \
|
||||
inline bool name(T1&& a, T2&& b) { \
|
||||
return safe_cmp_impl::name##Op::Op(a, b); \
|
||||
}
|
||||
RTC_SAFECMP_MAKE_FUN(Eq)
|
||||
RTC_SAFECMP_MAKE_FUN(Ne)
|
||||
|
||||
@ -376,4 +376,19 @@ TEST(SafeCmpTest, Ge) {
|
||||
EXPECT_TRUE(safe_cmp::Ge(p2, p2));
|
||||
}
|
||||
|
||||
TEST(SafeCmpTest, Enum) {
|
||||
enum E1 { e1 = 13 };
|
||||
enum { e2 = 13 };
|
||||
enum E3 : unsigned { e3 = 13 };
|
||||
enum : unsigned { e4 = 13 };
|
||||
EXPECT_TRUE(safe_cmp::Eq(13, e1));
|
||||
EXPECT_TRUE(safe_cmp::Eq(13u, e1));
|
||||
EXPECT_TRUE(safe_cmp::Eq(13, e2));
|
||||
EXPECT_TRUE(safe_cmp::Eq(13u, e2));
|
||||
EXPECT_TRUE(safe_cmp::Eq(13, e3));
|
||||
EXPECT_TRUE(safe_cmp::Eq(13u, e3));
|
||||
EXPECT_TRUE(safe_cmp::Eq(13, e4));
|
||||
EXPECT_TRUE(safe_cmp::Eq(13u, e4));
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
@ -57,7 +57,7 @@ int ascii_string_compare(const wchar_t* s1, const char* s2, size_t n,
|
||||
if (n-- == 0) return 0;
|
||||
c1 = transformation(*s1);
|
||||
// Double check that characters are not UTF-8
|
||||
RTC_DCHECK_LT(static_cast<unsigned char>(*s2), 128);
|
||||
RTC_DCHECK_LT(*s2, 128);
|
||||
// Note: *s2 gets implicitly promoted to wchar_t
|
||||
c2 = transformation(*s2);
|
||||
if (c1 != c2) return (c1 < c2) ? -1 : 1;
|
||||
@ -80,7 +80,7 @@ size_t asccpyn(wchar_t* buffer, size_t buflen,
|
||||
#if RTC_DCHECK_IS_ON
|
||||
// Double check that characters are not UTF-8
|
||||
for (size_t pos = 0; pos < srclen; ++pos)
|
||||
RTC_DCHECK_LT(static_cast<unsigned char>(source[pos]), 128);
|
||||
RTC_DCHECK_LT(source[pos], 128);
|
||||
#endif
|
||||
std::copy(source, source + srclen, buffer);
|
||||
buffer[srclen] = 0;
|
||||
|
||||
@ -61,7 +61,7 @@ TaskQueue::TaskQueue(const char* queue_name)
|
||||
TaskQueue::~TaskQueue() {
|
||||
RTC_DCHECK(!IsCurrent());
|
||||
while (!PostThreadMessage(thread_.GetThreadRef(), WM_QUIT, 0, 0)) {
|
||||
RTC_CHECK_EQ(static_cast<DWORD>(ERROR_NOT_ENOUGH_QUOTA), ::GetLastError());
|
||||
RTC_CHECK_EQ(ERROR_NOT_ENOUGH_QUOTA, ::GetLastError());
|
||||
Sleep(1);
|
||||
}
|
||||
thread_.Stop();
|
||||
|
||||
@ -154,8 +154,8 @@ BitrateAllocation::BitrateAllocation() : sum_(0), bitrates_{} {}
|
||||
bool BitrateAllocation::SetBitrate(size_t spatial_index,
|
||||
size_t temporal_index,
|
||||
uint32_t bitrate_bps) {
|
||||
RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers));
|
||||
RTC_DCHECK_LT(temporal_index, static_cast<size_t>(kMaxTemporalStreams));
|
||||
RTC_DCHECK_LT(spatial_index, kMaxSpatialLayers);
|
||||
RTC_DCHECK_LT(temporal_index, kMaxTemporalStreams);
|
||||
RTC_DCHECK_LE(bitrates_[spatial_index][temporal_index], sum_);
|
||||
uint64_t new_bitrate_sum_bps = sum_;
|
||||
new_bitrate_sum_bps -= bitrates_[spatial_index][temporal_index];
|
||||
@ -170,14 +170,14 @@ bool BitrateAllocation::SetBitrate(size_t spatial_index,
|
||||
|
||||
uint32_t BitrateAllocation::GetBitrate(size_t spatial_index,
|
||||
size_t temporal_index) const {
|
||||
RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers));
|
||||
RTC_DCHECK_LT(temporal_index, static_cast<size_t>(kMaxTemporalStreams));
|
||||
RTC_DCHECK_LT(spatial_index, kMaxSpatialLayers);
|
||||
RTC_DCHECK_LT(temporal_index, kMaxTemporalStreams);
|
||||
return bitrates_[spatial_index][temporal_index];
|
||||
}
|
||||
|
||||
// Get the sum of all the temporal layer for a specific spatial layer.
|
||||
uint32_t BitrateAllocation::GetSpatialLayerSum(size_t spatial_index) const {
|
||||
RTC_DCHECK_LT(spatial_index, static_cast<size_t>(kMaxSpatialLayers));
|
||||
RTC_DCHECK_LT(spatial_index, kMaxSpatialLayers);
|
||||
uint32_t sum = 0;
|
||||
for (int i = 0; i < kMaxTemporalStreams; ++i)
|
||||
sum += bitrates_[spatial_index][i];
|
||||
|
||||
@ -98,7 +98,7 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeImpl(
|
||||
if (rtp_timestamps_.size() < frames_to_encode) {
|
||||
return EncodedInfo();
|
||||
}
|
||||
RTC_CHECK_LE(static_cast<int>(frames_to_encode * 10), kMaxFrameSizeMs)
|
||||
RTC_CHECK_LE(frames_to_encode * 10, kMaxFrameSizeMs)
|
||||
<< "Frame size cannot be larger than " << kMaxFrameSizeMs
|
||||
<< " ms when using VAD/CNG.";
|
||||
|
||||
|
||||
@ -260,7 +260,7 @@ size_t ComfortNoiseEncoder::Encode(rtc::ArrayView<const int16_t> speech,
|
||||
int16_t speechBuf[kCngMaxOutsizeOrder];
|
||||
|
||||
const size_t num_samples = speech.size();
|
||||
RTC_CHECK_LE(num_samples, static_cast<size_t>(kCngMaxOutsizeOrder));
|
||||
RTC_CHECK_LE(num_samples, kCngMaxOutsizeOrder);
|
||||
|
||||
for (i = 0; i < num_samples; i++) {
|
||||
speechBuf[i] = speech[i];
|
||||
|
||||
@ -138,14 +138,14 @@ int DtmfToneGenerator::Init(int fs, int event, int attenuation) {
|
||||
RTC_DCHECK_GT(arraysize(kCoeff1), fs_index);
|
||||
RTC_DCHECK_GT(arraysize(kCoeff2), fs_index);
|
||||
RTC_DCHECK_LE(0, event);
|
||||
RTC_DCHECK_GT(arraysize(kCoeff1[fs_index]), static_cast<size_t>(event));
|
||||
RTC_DCHECK_GT(arraysize(kCoeff2[fs_index]), static_cast<size_t>(event));
|
||||
RTC_DCHECK_GT(arraysize(kCoeff1[fs_index]), event);
|
||||
RTC_DCHECK_GT(arraysize(kCoeff2[fs_index]), event);
|
||||
coeff1_ = kCoeff1[fs_index][event];
|
||||
coeff2_ = kCoeff2[fs_index][event];
|
||||
|
||||
// Look up amplitude multiplier.
|
||||
RTC_DCHECK_LE(0, attenuation);
|
||||
RTC_DCHECK_GT(arraysize(kAmplitude), static_cast<size_t>(attenuation));
|
||||
RTC_DCHECK_GT(arraysize(kAmplitude), attenuation);
|
||||
amplitude_ = kAmplitude[attenuation];
|
||||
|
||||
// Initialize sample history.
|
||||
@ -153,8 +153,8 @@ int DtmfToneGenerator::Init(int fs, int event, int attenuation) {
|
||||
RTC_DCHECK_GT(arraysize(kInitValue1), fs_index);
|
||||
RTC_DCHECK_GT(arraysize(kInitValue2), fs_index);
|
||||
RTC_DCHECK_LE(0, event);
|
||||
RTC_DCHECK_GT(arraysize(kInitValue1[fs_index]), static_cast<size_t>(event));
|
||||
RTC_DCHECK_GT(arraysize(kInitValue2[fs_index]), static_cast<size_t>(event));
|
||||
RTC_DCHECK_GT(arraysize(kInitValue1[fs_index]), event);
|
||||
RTC_DCHECK_GT(arraysize(kInitValue2[fs_index]), event);
|
||||
sample_history1_[0] = kInitValue1[fs_index][event];
|
||||
sample_history1_[1] = 0;
|
||||
sample_history2_[0] = kInitValue2[fs_index][event];
|
||||
|
||||
@ -152,7 +152,7 @@ int Normal::Process(const int16_t* input,
|
||||
} else if (last_mode == kModeRfc3389Cng) {
|
||||
RTC_DCHECK_EQ(output->Channels(), 1); // Not adapted for multi-channel yet.
|
||||
static const size_t kCngLength = 48;
|
||||
RTC_DCHECK_LE(static_cast<size_t>(8 * fs_mult), kCngLength);
|
||||
RTC_DCHECK_LE(8 * fs_mult, kCngLength);
|
||||
int16_t cng_output[kCngLength];
|
||||
// Reset mute factor and start up fresh.
|
||||
external_mute_factor_array[0] = 16384;
|
||||
|
||||
@ -255,7 +255,7 @@ void AudioTrackJni::OnGetPlayoutData(size_t length) {
|
||||
ALOGE("AudioDeviceBuffer::RequestPlayoutData failed!");
|
||||
return;
|
||||
}
|
||||
RTC_DCHECK_EQ(static_cast<size_t>(samples), frames_per_buffer_);
|
||||
RTC_DCHECK_EQ(samples, frames_per_buffer_);
|
||||
// Copy decoded data into common byte buffer to ensure that it can be
|
||||
// written to the Java based audio track.
|
||||
samples = audio_device_buffer_->GetPlayoutData(direct_buffer_address_);
|
||||
|
||||
@ -106,7 +106,7 @@ void FineAudioBuffer::GetPlayoutData(int8_t* buffer) {
|
||||
// If playout_cached_bytes_ is larger than the cache buffer, uninitialized
|
||||
// memory will be read.
|
||||
RTC_CHECK_LE(playout_cached_bytes_, bytes_per_10_ms_);
|
||||
RTC_CHECK_EQ(static_cast<size_t>(-bytes_left), playout_cached_bytes_);
|
||||
RTC_CHECK_EQ(-bytes_left, playout_cached_bytes_);
|
||||
playout_cached_buffer_start_ = 0;
|
||||
memcpy(playout_cache_buffer_.get(), cache_ptr, playout_cached_bytes_);
|
||||
}
|
||||
|
||||
@ -1744,7 +1744,7 @@ void FormNearendBlock(
|
||||
const float nearend_buffer[NUM_HIGH_BANDS_MAX + 1]
|
||||
[PART_LEN - (FRAME_LEN - PART_LEN)],
|
||||
float nearend_block[NUM_HIGH_BANDS_MAX + 1][PART_LEN]) {
|
||||
RTC_DCHECK_LE(num_samples_from_nearend_frame, static_cast<size_t>(PART_LEN));
|
||||
RTC_DCHECK_LE(num_samples_from_nearend_frame, PART_LEN);
|
||||
const int num_samples_from_buffer = PART_LEN - num_samples_from_nearend_frame;
|
||||
|
||||
if (num_samples_from_buffer > 0) {
|
||||
@ -1795,15 +1795,14 @@ void FormOutputFrame(size_t output_start_index,
|
||||
size_t* output_buffer_size,
|
||||
float output_buffer[NUM_HIGH_BANDS_MAX + 1][2 * PART_LEN],
|
||||
float* const* output_frame) {
|
||||
RTC_DCHECK_LE(static_cast<size_t>(FRAME_LEN), *output_buffer_size);
|
||||
RTC_DCHECK_LE(FRAME_LEN, *output_buffer_size);
|
||||
for (size_t i = 0; i < num_bands; ++i) {
|
||||
memcpy(&output_frame[i][output_start_index], &output_buffer[i][0],
|
||||
FRAME_LEN * sizeof(float));
|
||||
}
|
||||
(*output_buffer_size) -= FRAME_LEN;
|
||||
if (*output_buffer_size > 0) {
|
||||
RTC_DCHECK_GE(static_cast<size_t>(2 * PART_LEN - FRAME_LEN),
|
||||
(*output_buffer_size));
|
||||
RTC_DCHECK_GE(2 * PART_LEN - FRAME_LEN, (*output_buffer_size));
|
||||
for (size_t i = 0; i < num_bands; ++i) {
|
||||
memcpy(&output_buffer[i][0], &output_buffer[i][FRAME_LEN],
|
||||
(*output_buffer_size) * sizeof(float));
|
||||
|
||||
@ -69,12 +69,11 @@ void DownSampler::Initialize(int sample_rate_hz) {
|
||||
void DownSampler::DownSample(rtc::ArrayView<const float> in,
|
||||
rtc::ArrayView<float> out) {
|
||||
data_dumper_->DumpWav("lc_down_sampler_input", in, sample_rate_hz_, 1);
|
||||
RTC_DCHECK_EQ(static_cast<size_t>(sample_rate_hz_ *
|
||||
AudioProcessing::kChunkSizeMs / 1000),
|
||||
RTC_DCHECK_EQ(sample_rate_hz_ * AudioProcessing::kChunkSizeMs / 1000,
|
||||
in.size());
|
||||
RTC_DCHECK_EQ(static_cast<size_t>(AudioProcessing::kSampleRate8kHz *
|
||||
AudioProcessing::kChunkSizeMs / 1000),
|
||||
out.size());
|
||||
RTC_DCHECK_EQ(
|
||||
AudioProcessing::kSampleRate8kHz * AudioProcessing::kChunkSizeMs / 1000,
|
||||
out.size());
|
||||
const size_t kMaxNumFrames =
|
||||
AudioProcessing::kSampleRate48kHz * AudioProcessing::kChunkSizeMs / 1000;
|
||||
float x[kMaxNumFrames];
|
||||
|
||||
@ -129,7 +129,7 @@ void SignalClassifier::Initialize(int sample_rate_hz) {
|
||||
|
||||
void SignalClassifier::Analyze(const AudioBuffer& audio,
|
||||
SignalType* signal_type) {
|
||||
RTC_DCHECK_EQ(audio.num_frames(), static_cast<size_t>(sample_rate_hz_ / 100));
|
||||
RTC_DCHECK_EQ(audio.num_frames(), sample_rate_hz_ / 100);
|
||||
|
||||
// Compute the signal power spectrum.
|
||||
float downsampled_frame[80];
|
||||
|
||||
@ -39,7 +39,7 @@ VoiceActivityDetector::~VoiceActivityDetector() = default;
|
||||
void VoiceActivityDetector::ProcessChunk(const int16_t* audio,
|
||||
size_t length,
|
||||
int sample_rate_hz) {
|
||||
RTC_DCHECK_EQ(static_cast<int>(length), sample_rate_hz / 100);
|
||||
RTC_DCHECK_EQ(length, sample_rate_hz / 100);
|
||||
RTC_DCHECK_LE(length, kMaxLength);
|
||||
// Resample to the required rate.
|
||||
const int16_t* resampled_ptr = audio;
|
||||
|
||||
@ -105,7 +105,7 @@ int ForwardErrorCorrection::EncodeFec(const PacketList& media_packets,
|
||||
// Sanity check arguments.
|
||||
RTC_DCHECK_GT(num_media_packets, 0);
|
||||
RTC_DCHECK_GE(num_important_packets, 0);
|
||||
RTC_DCHECK_LE(static_cast<size_t>(num_important_packets), num_media_packets);
|
||||
RTC_DCHECK_LE(num_important_packets, num_media_packets);
|
||||
RTC_DCHECK(fec_packets->empty());
|
||||
const size_t max_media_packets = fec_header_writer_->MaxMediaPackets();
|
||||
if (num_media_packets > max_media_packets) {
|
||||
|
||||
@ -103,7 +103,7 @@ class PacketContainer : public rtcp::CompoundPacket,
|
||||
}
|
||||
|
||||
size_t SendPackets(size_t max_payload_length) {
|
||||
RTC_DCHECK_LE(max_payload_length, static_cast<size_t>(IP_PACKET_SIZE));
|
||||
RTC_DCHECK_LE(max_payload_length, IP_PACKET_SIZE);
|
||||
uint8_t buffer[IP_PACKET_SIZE];
|
||||
BuildExternalBuffer(buffer, max_payload_length, this);
|
||||
return bytes_sent_;
|
||||
@ -325,7 +325,7 @@ int32_t RTCPSender::SetCNAME(const char* c_name) {
|
||||
if (!c_name)
|
||||
return -1;
|
||||
|
||||
RTC_DCHECK_LT(strlen(c_name), static_cast<size_t>(RTCP_CNAME_SIZE));
|
||||
RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE);
|
||||
rtc::CritScope lock(&critical_section_rtcp_sender_);
|
||||
cname_ = c_name;
|
||||
return 0;
|
||||
@ -333,7 +333,7 @@ int32_t RTCPSender::SetCNAME(const char* c_name) {
|
||||
|
||||
int32_t RTCPSender::AddMixedCNAME(uint32_t SSRC, const char* c_name) {
|
||||
RTC_DCHECK(c_name);
|
||||
RTC_DCHECK_LT(strlen(c_name), static_cast<size_t>(RTCP_CNAME_SIZE));
|
||||
RTC_DCHECK_LT(strlen(c_name), RTCP_CNAME_SIZE);
|
||||
rtc::CritScope lock(&critical_section_rtcp_sender_);
|
||||
if (csrc_cnames_.size() >= kRtpCsrcSize)
|
||||
return -1;
|
||||
@ -466,7 +466,7 @@ std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSR(const RtcpContext& ctx) {
|
||||
std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildSDES(
|
||||
const RtcpContext& ctx) {
|
||||
size_t length_cname = cname_.length();
|
||||
RTC_CHECK_LT(length_cname, static_cast<size_t>(RTCP_CNAME_SIZE));
|
||||
RTC_CHECK_LT(length_cname, RTCP_CNAME_SIZE);
|
||||
|
||||
rtcp::Sdes* sdes = new rtcp::Sdes();
|
||||
sdes->AddCName(ssrc_, cname_);
|
||||
@ -933,7 +933,7 @@ bool RTCPSender::AddReportBlock(const FeedbackState& feedback_state,
|
||||
}
|
||||
|
||||
void RTCPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) {
|
||||
RTC_DCHECK_LE(csrcs.size(), static_cast<size_t>(kRtpCsrcSize));
|
||||
RTC_DCHECK_LE(csrcs.size(), kRtpCsrcSize);
|
||||
rtc::CritScope lock(&critical_section_rtcp_sender_);
|
||||
csrcs_ = csrcs;
|
||||
}
|
||||
@ -1037,7 +1037,7 @@ bool RTCPSender::SendFeedbackPacket(const rtcp::TransportFeedback& packet) {
|
||||
// but we can't because of an incorrect warning (C4822) in MVS 2013.
|
||||
} sender(transport_, event_log_);
|
||||
|
||||
RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE));
|
||||
RTC_DCHECK_LE(max_payload_length_, IP_PACKET_SIZE);
|
||||
uint8_t buffer[IP_PACKET_SIZE];
|
||||
return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) &&
|
||||
!sender.send_failure_;
|
||||
|
||||
@ -95,7 +95,7 @@ static void RtpFragmentize(EncodedImage* encoded_image,
|
||||
for (int nal = 0; nal < layerInfo.iNalCount; ++nal, ++fragments_count) {
|
||||
RTC_CHECK_GE(layerInfo.pNalLengthInByte[nal], 0);
|
||||
// Ensure |required_size| will not overflow.
|
||||
RTC_CHECK_LE(static_cast<size_t>(layerInfo.pNalLengthInByte[nal]),
|
||||
RTC_CHECK_LE(layerInfo.pNalLengthInByte[nal],
|
||||
std::numeric_limits<size_t>::max() - required_size);
|
||||
required_size += layerInfo.pNalLengthInByte[nal];
|
||||
}
|
||||
@ -326,7 +326,7 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
|
||||
bool force_key_frame = false;
|
||||
if (frame_types != nullptr) {
|
||||
// We only support a single stream.
|
||||
RTC_DCHECK_EQ(frame_types->size(), static_cast<size_t>(1));
|
||||
RTC_DCHECK_EQ(frame_types->size(), 1);
|
||||
// Skip frame?
|
||||
if ((*frame_types)[0] == kEmptyFrame) {
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
|
||||
@ -697,8 +697,8 @@ int VP8EncoderImpl::Encode(const VideoFrame& frame,
|
||||
// |raw_images_[0]|, the resolution of these frames must match. Note that
|
||||
// |input_image| might be scaled from |frame|. In that case, the resolution of
|
||||
// |raw_images_[0]| should have been updated in UpdateCodecFrameSize.
|
||||
RTC_DCHECK_EQ(input_image->width(), static_cast<int>(raw_images_[0].d_w));
|
||||
RTC_DCHECK_EQ(input_image->height(), static_cast<int>(raw_images_[0].d_h));
|
||||
RTC_DCHECK_EQ(input_image->width(), raw_images_[0].d_w);
|
||||
RTC_DCHECK_EQ(input_image->height(), raw_images_[0].d_h);
|
||||
|
||||
// Image in vpx_image_t format.
|
||||
// Input image is const. VP8's raw image is not defined as const.
|
||||
|
||||
@ -497,8 +497,8 @@ int VP9EncoderImpl::Encode(const VideoFrame& input_image,
|
||||
if (frame_types && frame_types->size() > 0) {
|
||||
frame_type = (*frame_types)[0];
|
||||
}
|
||||
RTC_DCHECK_EQ(input_image.width(), static_cast<int>(raw_->d_w));
|
||||
RTC_DCHECK_EQ(input_image.height(), static_cast<int>(raw_->d_h));
|
||||
RTC_DCHECK_EQ(input_image.width(), raw_->d_w);
|
||||
RTC_DCHECK_EQ(input_image.height(), raw_->d_h);
|
||||
|
||||
// Set input image for use in the callback.
|
||||
// This was necessary since you need some information from input_image.
|
||||
|
||||
@ -164,7 +164,7 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
|
||||
video_codec.minBitrate = streams[0].min_bitrate_bps / 1000;
|
||||
if (video_codec.minBitrate < kEncoderMinBitrateKbps)
|
||||
video_codec.minBitrate = kEncoderMinBitrateKbps;
|
||||
RTC_DCHECK_LE(streams.size(), static_cast<size_t>(kMaxSimulcastStreams));
|
||||
RTC_DCHECK_LE(streams.size(), kMaxSimulcastStreams);
|
||||
if (video_codec.codecType == kVideoCodecVP9) {
|
||||
// If the vector is empty, bitrates will be configured automatically.
|
||||
RTC_DCHECK(config.spatial_layers.empty() ||
|
||||
|
||||
@ -118,7 +118,7 @@ static bool CreateCryptoParams(int tag, const std::string& cipher,
|
||||
return false;
|
||||
}
|
||||
|
||||
RTC_CHECK_EQ(static_cast<size_t>(master_key_len), master_key.size());
|
||||
RTC_CHECK_EQ(master_key_len, master_key.size());
|
||||
std::string key = rtc::Base64::Encode(master_key);
|
||||
|
||||
out->tag = tag;
|
||||
|
||||
@ -70,7 +70,7 @@ class FakeNetworkPipeTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
void SendPackets(FakeNetworkPipe* pipe, int number_packets, int packet_size) {
|
||||
RTC_DCHECK_GE(packet_size, static_cast<int>(sizeof(int)));
|
||||
RTC_DCHECK_GE(packet_size, sizeof(int));
|
||||
std::unique_ptr<uint8_t[]> packet(new uint8_t[packet_size]);
|
||||
for (int i = 0; i < number_packets; ++i) {
|
||||
// Set a sequence number for the packets by
|
||||
|
||||
@ -51,7 +51,7 @@ bool LayerFilteringTransport::SendRtp(const uint8_t* packet,
|
||||
RTPHeader header;
|
||||
parser.Parse(&header);
|
||||
|
||||
RTC_DCHECK_LE(length, static_cast<size_t>(IP_PACKET_SIZE));
|
||||
RTC_DCHECK_LE(length, IP_PACKET_SIZE);
|
||||
uint8_t temp_buffer[IP_PACKET_SIZE];
|
||||
memcpy(temp_buffer, packet, length);
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ template <typename Packet>
|
||||
bool ParseSinglePacket(const uint8_t* buffer, size_t size, Packet* packet) {
|
||||
rtcp::CommonHeader header;
|
||||
RTC_CHECK(header.Parse(buffer, size));
|
||||
RTC_CHECK_EQ(static_cast<ptrdiff_t>(size), header.NextPacket() - buffer);
|
||||
RTC_CHECK_EQ(size, header.NextPacket() - buffer);
|
||||
return packet->Parse(header);
|
||||
}
|
||||
// Same function, but takes raw buffer as single argument instead of pair.
|
||||
|
||||
@ -877,7 +877,7 @@ void VideoQualityTest::CheckParams() {
|
||||
RTC_CHECK_GE(stream.min_bitrate_bps, 0);
|
||||
RTC_CHECK_GE(stream.target_bitrate_bps, stream.min_bitrate_bps);
|
||||
RTC_CHECK_GE(stream.max_bitrate_bps, stream.target_bitrate_bps);
|
||||
RTC_CHECK_EQ(static_cast<int>(stream.temporal_layer_thresholds_bps.size()),
|
||||
RTC_CHECK_EQ(stream.temporal_layer_thresholds_bps.size(),
|
||||
params_.video.num_temporal_layers - 1);
|
||||
}
|
||||
// TODO(ivica): Should we check if the sum of all streams/layers is equal to
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user