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}
This commit is contained in:
Peter Kasting
2015-06-10 21:15:38 -07:00
parent 786dbdcc38
commit f045e4da43
42 changed files with 153 additions and 127 deletions

View File

@ -136,9 +136,9 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeInternal(
(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 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive(
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.";