Misc. small cleanups.

* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests).  Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks

All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.

BUG=none
TEST=none

Review URL: https://codereview.webrtc.org/1534193008

Cr-Commit-Position: refs/heads/master@{#11191}
diff --git a/webrtc/modules/audio_coding/acm2/acm_codec_database.cc b/webrtc/modules/audio_coding/acm2/acm_codec_database.cc
index 8d4072f..bbd4509 100644
--- a/webrtc/modules/audio_coding/acm2/acm_codec_database.cc
+++ b/webrtc/modules/audio_coding/acm2/acm_codec_database.cc
@@ -106,7 +106,7 @@
   {127, "red", 8000, 0, 1, 0},
 #endif
   // To prevent compile errors due to trailing commas.
-  {-1, "Null", -1, -1, -1, -1}
+  {-1, "Null", -1, -1, 0, -1}
 };
 
 // Create database with all codec settings at compile time.
@@ -162,7 +162,7 @@
     {1, {0}, 0, 1},
 #endif
     // To prevent compile errors due to trailing commas.
-    {-1, {-1}, -1, -1}
+    {-1, {-1}, -1, 0}
 };
 
 // Create a database of all NetEQ decoders at compile time.
diff --git a/webrtc/modules/audio_coding/acm2/acm_resampler.cc b/webrtc/modules/audio_coding/acm2/acm_resampler.cc
index 5df87d2..d7ceb8a 100644
--- a/webrtc/modules/audio_coding/acm2/acm_resampler.cc
+++ b/webrtc/modules/audio_coding/acm2/acm_resampler.cc
@@ -32,7 +32,6 @@
                                  size_t out_capacity_samples,
                                  int16_t* out_audio) {
   size_t in_length = static_cast<size_t>(in_freq_hz * num_audio_channels / 100);
-  int out_length = out_freq_hz * num_audio_channels / 100;
   if (in_freq_hz == out_freq_hz) {
     if (out_capacity_samples < in_length) {
       assert(false);
@@ -49,7 +48,7 @@
     return -1;
   }
 
-  out_length =
+  int out_length =
       resampler_.Resample(in_audio, in_length, out_audio, out_capacity_samples);
   if (out_length == -1) {
     LOG(LS_ERROR) << "Resample(" << in_audio << ", " << in_length << ", "
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 210791c..26c7838 100644
--- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
+++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
@@ -83,7 +83,8 @@
 }
 
 int AudioEncoderPcm::GetTargetBitrate() const {
-  return 8 * BytesPerSample() * SampleRateHz() * NumChannels();
+  return static_cast<int>(
+      8 * BytesPerSample() * SampleRateHz() * NumChannels());
 }
 
 AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal(
@@ -122,7 +123,7 @@
   return WebRtcG711_EncodeA(audio, input_len, encoded);
 }
 
-int AudioEncoderPcmA::BytesPerSample() const {
+size_t AudioEncoderPcmA::BytesPerSample() const {
   return 1;
 }
 
@@ -135,7 +136,7 @@
   return WebRtcG711_EncodeU(audio, input_len, encoded);
 }
 
-int AudioEncoderPcmU::BytesPerSample() const {
+size_t AudioEncoderPcmU::BytesPerSample() const {
   return 1;
 }
 
diff --git a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h
index fd996dc..6891cbd 100644
--- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h
+++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h
@@ -54,7 +54,7 @@
                             size_t input_len,
                             uint8_t* encoded) = 0;
 
-  virtual int BytesPerSample() const = 0;
+  virtual size_t BytesPerSample() const = 0;
 
  private:
   const int sample_rate_hz_;
@@ -83,7 +83,7 @@
                     size_t input_len,
                     uint8_t* encoded) override;
 
-  int BytesPerSample() const override;
+  size_t BytesPerSample() const override;
 
  private:
   static const int kSampleRateHz = 8000;
@@ -105,7 +105,7 @@
                     size_t input_len,
                     uint8_t* encoded) override;
 
-  int BytesPerSample() const override;
+  size_t BytesPerSample() const override;
 
  private:
   static const int kSampleRateHz = 8000;
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 632a4fe..32f36c5 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
@@ -92,7 +92,7 @@
   value = WebRtcIsacfix_Decode(ISACFIX_main_inst_, bit_stream, encoded_bytes,
                                out_data, &audio_type);
   clocks = clock() - clocks;
-  EXPECT_EQ(output_length_sample_, value);
+  EXPECT_EQ(output_length_sample_, static_cast<size_t>(value));
   return 1000.0 * clocks / CLOCKS_PER_SEC;
 }
 
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 3e7d3ec..0806bb8 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -137,15 +137,14 @@
     uint8_t* encoded) {
   if (input_buffer_.empty())
     first_timestamp_in_buffer_ = rtp_timestamp;
-  RTC_DCHECK_EQ(static_cast<size_t>(SamplesPer10msFrame()), audio.size());
+  RTC_DCHECK_EQ(SamplesPer10msFrame(), audio.size());
   input_buffer_.insert(input_buffer_.end(), audio.cbegin(), audio.cend());
   if (input_buffer_.size() <
-      (static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame())) {
+      (Num10msFramesPerPacket() * SamplesPer10msFrame())) {
     return EncodedInfo();
   }
-  RTC_CHECK_EQ(
-      input_buffer_.size(),
-      static_cast<size_t>(Num10msFramesPerPacket()) * SamplesPer10msFrame());
+  RTC_CHECK_EQ(input_buffer_.size(),
+               Num10msFramesPerPacket() * SamplesPer10msFrame());
   int status = WebRtcOpus_Encode(
       inst_, &input_buffer_[0],
       rtc::CheckedDivExact(input_buffer_.size(),
@@ -214,11 +213,11 @@
   RTC_CHECK_EQ(0, WebRtcOpus_SetBitRate(inst_, config_.bitrate_bps));
 }
 
-int AudioEncoderOpus::Num10msFramesPerPacket() const {
-  return rtc::CheckedDivExact(config_.frame_size_ms, 10);
+size_t AudioEncoderOpus::Num10msFramesPerPacket() const {
+  return static_cast<size_t>(rtc::CheckedDivExact(config_.frame_size_ms, 10));
 }
 
-int AudioEncoderOpus::SamplesPer10msFrame() const {
+size_t AudioEncoderOpus::SamplesPer10msFrame() const {
   return rtc::CheckedDivExact(kSampleRateHz, 100) * config_.num_channels;
 }
 
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h
index 36011fa..f37e344 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h
@@ -85,8 +85,8 @@
   bool dtx_enabled() const { return config_.dtx_enabled; }
 
  private:
-  int Num10msFramesPerPacket() const;
-  int SamplesPer10msFrame() const;
+  size_t Num10msFramesPerPacket() const;
+  size_t SamplesPer10msFrame() const;
   bool RecreateEncoderInstance(const Config& config);
 
   Config config_;
diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_speed_test.cc b/webrtc/modules/audio_coding/codecs/opus/opus_speed_test.cc
index f95cc71..4d1aa42 100644
--- a/webrtc/modules/audio_coding/codecs/opus/opus_speed_test.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/opus_speed_test.cc
@@ -77,7 +77,7 @@
   value = WebRtcOpus_Decode(opus_decoder_, bit_stream, encoded_bytes, out_data,
                             &audio_type);
   clocks = clock() - clocks;
-  EXPECT_EQ(output_length_sample_, value);
+  EXPECT_EQ(output_length_sample_, static_cast<size_t>(value));
   return 1000.0 * clocks / CLOCKS_PER_SEC;
 }
 
diff --git a/webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc b/webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc
index 50d2041..f4d4022 100644
--- a/webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc
+++ b/webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc
@@ -22,7 +22,7 @@
   return WebRtcPcm16b_Encode(audio, input_len, encoded);
 }
 
-int AudioEncoderPcm16B::BytesPerSample() const {
+size_t AudioEncoderPcm16B::BytesPerSample() const {
   return 2;
 }
 
diff --git a/webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h b/webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h
index 3645a6f..68ca2da 100644
--- a/webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h
+++ b/webrtc/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h
@@ -37,7 +37,7 @@
                     size_t input_len,
                     uint8_t* encoded) override;
 
-  int BytesPerSample() const override;
+  size_t BytesPerSample() const override;
 
  private:
   RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcm16B);
diff --git a/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc b/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
index 3395721..07a15ff 100644
--- a/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
+++ b/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.cc
@@ -23,8 +23,10 @@
     : block_duration_ms_(block_duration_ms),
       input_sampling_khz_(input_sampling_khz),
       output_sampling_khz_(output_sampling_khz),
-      input_length_sample_(block_duration_ms_ * input_sampling_khz_),
-      output_length_sample_(block_duration_ms_ * output_sampling_khz_),
+      input_length_sample_(
+          static_cast<size_t>(block_duration_ms_ * input_sampling_khz_)),
+      output_length_sample_(
+          static_cast<size_t>(block_duration_ms_ * output_sampling_khz_)),
       data_pointer_(0),
       loop_length_samples_(0),
       max_bytes_(0),
@@ -65,8 +67,7 @@
   memcpy(&in_data_[loop_length_samples_], &in_data_[0],
          input_length_sample_ * channels_ * sizeof(int16_t));
 
-  max_bytes_ =
-      static_cast<size_t>(input_length_sample_ * channels_ * sizeof(int16_t));
+  max_bytes_ = input_length_sample_ * channels_ * sizeof(int16_t);
   out_data_.reset(new int16_t[output_length_sample_ * channels_]);
   bit_stream_.reset(new uint8_t[max_bytes_]);
 
diff --git a/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.h b/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.h
index 2736c29..b5aef75 100644
--- a/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.h
+++ b/webrtc/modules/audio_coding/codecs/tools/audio_codec_speed_test.h
@@ -55,10 +55,10 @@
   int output_sampling_khz_;
 
   // Number of samples-per-channel in a frame.
-  int input_length_sample_;
+  size_t input_length_sample_;
 
   // Expected output number of samples-per-channel in a frame.
-  int output_length_sample_;
+  size_t output_length_sample_;
 
   rtc::scoped_ptr<int16_t[]> in_data_;
   rtc::scoped_ptr<int16_t[]> out_data_;
diff --git a/webrtc/modules/audio_coding/include/audio_coding_module.h b/webrtc/modules/audio_coding/include/audio_coding_module.h
index f5af65a..52fe383 100644
--- a/webrtc/modules/audio_coding/include/audio_coding_module.h
+++ b/webrtc/modules/audio_coding/include/audio_coding_module.h
@@ -134,7 +134,7 @@
   //    0 if succeeded.
   //
   static int Codec(const char* payload_name, CodecInst* codec,
-                       int sampling_freq_hz, int channels);
+                   int sampling_freq_hz, int channels);
 
   ///////////////////////////////////////////////////////////////////////////
   // int32_t Codec()
@@ -153,7 +153,7 @@
   //   -1 if the codec is not found.
   //
   static int Codec(const char* payload_name, int sampling_freq_hz,
-                             int channels);
+                   int channels);
 
   ///////////////////////////////////////////////////////////////////////////
   // bool IsCodecValid()
diff --git a/webrtc/modules/audio_coding/test/opus_test.cc b/webrtc/modules/audio_coding/test/opus_test.cc
index a68db91..466db9f 100644
--- a/webrtc/modules/audio_coding/test/opus_test.cc
+++ b/webrtc/modules/audio_coding/test/opus_test.cc
@@ -206,16 +206,16 @@
 }
 
 void OpusTest::Run(TestPackStereo* channel, int channels, int bitrate,
-                   int frame_length, int percent_loss) {
+                   size_t frame_length, int percent_loss) {
   AudioFrame audio_frame;
   int32_t out_freq_hz_b = out_file_.SamplingFrequency();
-  const int kBufferSizeSamples = 480 * 12 * 2;  // Can hold 120 ms stereo audio.
+  const size_t kBufferSizeSamples = 480 * 12 * 2;  // 120 ms stereo audio.
   int16_t audio[kBufferSizeSamples];
   int16_t out_audio[kBufferSizeSamples];
   int16_t audio_type;
-  int written_samples = 0;
-  int read_samples = 0;
-  int decoded_samples = 0;
+  size_t written_samples = 0;
+  size_t read_samples = 0;
+  size_t decoded_samples = 0;
   bool first_packet = true;
   uint32_t start_time_stamp = 0;
 
@@ -268,14 +268,14 @@
 
     // Sometimes we need to loop over the audio vector to produce the right
     // number of packets.
-    int loop_encode = (written_samples - read_samples) /
+    size_t loop_encode = (written_samples - read_samples) /
         (channels * frame_length);
 
     if (loop_encode > 0) {
-      const int kMaxBytes = 1000;  // Maximum number of bytes for one packet.
+      const size_t kMaxBytes = 1000;  // Maximum number of bytes for one packet.
       size_t bitstream_len_byte;
       uint8_t bitstream[kMaxBytes];
-      for (int i = 0; i < loop_encode; i++) {
+      for (size_t i = 0; i < loop_encode; i++) {
         int bitstream_len_byte_int = WebRtcOpus_Encode(
             (channels == 1) ? opus_mono_encoder_ : opus_stereo_encoder_,
             &audio[read_samples], frame_length, kMaxBytes, bitstream);
@@ -326,7 +326,7 @@
           first_packet = false;
           start_time_stamp = rtp_timestamp_;
         }
-        rtp_timestamp_ += frame_length;
+        rtp_timestamp_ += static_cast<uint32_t>(frame_length);
         read_samples += frame_length * channels;
       }
       if (read_samples == written_samples) {
@@ -344,8 +344,7 @@
         audio_frame.samples_per_channel_ * audio_frame.num_channels_);
 
     // Write stand-alone speech to file.
-    out_file_standalone_.Write10MsData(
-        out_audio, static_cast<size_t>(decoded_samples) * channels);
+    out_file_standalone_.Write10MsData(out_audio, decoded_samples * channels);
 
     if (audio_frame.timestamp_ > start_time_stamp) {
       // Number of channels should be the same for both stand-alone and
diff --git a/webrtc/modules/audio_coding/test/opus_test.h b/webrtc/modules/audio_coding/test/opus_test.h
index 090c8fa..88ef0ec 100644
--- a/webrtc/modules/audio_coding/test/opus_test.h
+++ b/webrtc/modules/audio_coding/test/opus_test.h
@@ -31,7 +31,10 @@
   void Perform();
 
  private:
-  void Run(TestPackStereo* channel, int channels, int bitrate, int frame_length,
+  void Run(TestPackStereo* channel,
+           int channels,
+           int bitrate,
+           size_t frame_length,
            int percent_loss = 0);
 
   void OpenOutFile(int test_number);
@@ -44,7 +47,7 @@
   PCMFile out_file_standalone_;
   int counter_;
   uint8_t payload_type_;
-  int rtp_timestamp_;
+  uint32_t rtp_timestamp_;
   acm2::ACMResampler resampler_;
   WebRtcOpusEncInst* opus_mono_encoder_;
   WebRtcOpusEncInst* opus_stereo_encoder_;