Use size_t more consistently for packet/payload lengths.

See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.

This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.

BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom

Review URL: https://webrtc-codereview.appspot.com/23129004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc
index fb36cf8..a6ba799 100644
--- a/talk/app/webrtc/java/jni/peerconnection_jni.cc
+++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc
@@ -1258,7 +1258,7 @@
   // |codec_thread_| for execution.
   virtual int32_t InitEncode(const webrtc::VideoCodec* codec_settings,
                              int32_t /* number_of_cores */,
-                             uint32_t /* max_payload_size */) OVERRIDE;
+                             size_t /* max_payload_size */) OVERRIDE;
   virtual int32_t Encode(
       const webrtc::I420VideoFrame& input_image,
       const webrtc::CodecSpecificInfo* /* codec_specific_info */,
@@ -1433,7 +1433,7 @@
 int32_t MediaCodecVideoEncoder::InitEncode(
     const webrtc::VideoCodec* codec_settings,
     int32_t /* number_of_cores */,
-    uint32_t /* max_payload_size */) {
+    size_t /* max_payload_size */) {
   // Factory should guard against other codecs being used with us.
   CHECK(codec_settings->codecType == kVideoCodecVP8) << "Unsupported codec";
 
diff --git a/talk/media/webrtc/fakewebrtcvideoengine.h b/talk/media/webrtc/fakewebrtcvideoengine.h
index 677f899..f729ddd 100644
--- a/talk/media/webrtc/fakewebrtcvideoengine.h
+++ b/talk/media/webrtc/fakewebrtcvideoengine.h
@@ -152,7 +152,7 @@
 
   virtual int32 InitEncode(const webrtc::VideoCodec* codecSettings,
                            int32 numberOfCores,
-                           uint32 maxPayloadSize) {
+                           size_t maxPayloadSize) {
     return WEBRTC_VIDEO_CODEC_OK;
   }
 
@@ -351,7 +351,7 @@
 
     // From ViEExternalCapture
     virtual int IncomingFrame(unsigned char* videoFrame,
-                              unsigned int videoFrameLength,
+                              size_t videoFrameLength,
                               unsigned short width,
                               unsigned short height,
                               webrtc::RawVideoType videoType,
@@ -890,7 +890,7 @@
 
   WEBRTC_FUNC(ReceivedRTPPacket, (const int channel,
                                   const void* packet,
-                                  const int length,
+                                  const size_t length,
                                   const webrtc::PacketTime& packet_time)) {
     WEBRTC_ASSERT_CHANNEL(channel);
     ASSERT(length > 1);
@@ -899,11 +899,11 @@
     return 0;
   }
 
-  WEBRTC_STUB(ReceivedRTCPPacket, (const int, const void*, const int));
+  WEBRTC_STUB(ReceivedRTCPPacket, (const int, const void*, const size_t));
   // Not using WEBRTC_STUB due to bool return value
   virtual bool IsIPv6Enabled(int channel) { return true; }
   WEBRTC_STUB(SetMTU, (int, unsigned int));
-  WEBRTC_STUB(ReceivedBWEPacket, (const int, int64_t, int,
+  WEBRTC_STUB(ReceivedBWEPacket, (const int, int64_t, size_t,
       const webrtc::RTPHeader&));
   virtual bool SetBandwidthEstimationConfig(int, const webrtc::Config&) {
     return true;
@@ -1140,8 +1140,8 @@
       unsigned int&, unsigned int&, unsigned int&, int&));
   WEBRTC_STUB_CONST(GetSentRTCPStatistics, (const int, unsigned short&,
       unsigned int&, unsigned int&, unsigned int&, int&));
-  WEBRTC_STUB_CONST(GetRTPStatistics, (const int, unsigned int&, unsigned int&,
-      unsigned int&, unsigned int&));
+  WEBRTC_STUB_CONST(GetRTPStatistics, (const int, size_t&, unsigned int&,
+      size_t&, unsigned int&));
   WEBRTC_STUB_CONST(GetReceiveChannelRtcpStatistics, (const int,
       webrtc::RtcpStatistics&, int&));
   WEBRTC_STUB_CONST(GetSendChannelRtcpStatistics, (const int,
diff --git a/talk/media/webrtc/fakewebrtcvoiceengine.h b/talk/media/webrtc/fakewebrtcvoiceengine.h
index 222ce4b..dc27e96 100644
--- a/talk/media/webrtc/fakewebrtcvoiceengine.h
+++ b/talk/media/webrtc/fakewebrtcvoiceengine.h
@@ -858,7 +858,7 @@
     return 0;
   }
   WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
-                                  unsigned int length)) {
+                                  size_t length)) {
     WEBRTC_CHECK_CHANNEL(channel);
     if (!channels_[channel]->external_transport) return -1;
     channels_[channel]->packets.push_back(
@@ -866,7 +866,7 @@
     return 0;
   }
   WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data,
-                                  unsigned int length,
+                                  size_t length,
                                   const webrtc::PacketTime& packet_time)) {
     WEBRTC_CHECK_CHANNEL(channel);
     if (ReceivedRTPPacket(channel, data, length) == -1) {
@@ -877,7 +877,7 @@
   }
 
   WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data,
-                                   unsigned int length));
+                                   size_t length));
 
   // webrtc::VoERTP_RTCP
   WEBRTC_STUB(RegisterRTPObserver, (int channel,
diff --git a/talk/media/webrtc/webrtcvideocapturer.cc b/talk/media/webrtc/webrtcvideocapturer.cc
index ea8b61a..32f105d 100644
--- a/talk/media/webrtc/webrtcvideocapturer.cc
+++ b/talk/media/webrtc/webrtcvideocapturer.cc
@@ -36,6 +36,7 @@
 #include "talk/media/webrtc/webrtcvideoframefactory.h"
 #include "webrtc/base/criticalsection.h"
 #include "webrtc/base/logging.h"
+#include "webrtc/base/safe_conversions.h"
 #include "webrtc/base/thread.h"
 #include "webrtc/base/timeutils.h"
 
@@ -351,8 +352,8 @@
   // Signal down stream components on captured frame.
   // The CapturedFrame class doesn't support planes. We have to ExtractBuffer
   // to one block for it.
-  int length = webrtc::CalcBufferSize(webrtc::kI420,
-                                      sample.width(), sample.height());
+  size_t length =
+      webrtc::CalcBufferSize(webrtc::kI420, sample.width(), sample.height());
   capture_buffer_.resize(length);
   // TODO(ronghuawu): Refactor the WebRtcCapturedFrame to avoid memory copy.
   webrtc::ExtractBuffer(sample, length, &capture_buffer_[0]);
@@ -368,7 +369,7 @@
 // WebRtcCapturedFrame
 WebRtcCapturedFrame::WebRtcCapturedFrame(const webrtc::I420VideoFrame& sample,
                                          void* buffer,
-                                         int length) {
+                                         size_t length) {
   width = sample.width();
   height = sample.height();
   fourcc = FOURCC_I420;
@@ -378,7 +379,7 @@
   // Convert units from VideoFrame RenderTimeMs to CapturedFrame (nanoseconds).
   elapsed_time = sample.render_time_ms() * rtc::kNumNanosecsPerMillisec;
   time_stamp = elapsed_time;
-  data_size = length;
+  data_size = rtc::checked_cast<uint32>(length);
   data = buffer;
 }
 
diff --git a/talk/media/webrtc/webrtcvideocapturer.h b/talk/media/webrtc/webrtcvideocapturer.h
index 39a71f8..7d09040 100644
--- a/talk/media/webrtc/webrtcvideocapturer.h
+++ b/talk/media/webrtc/webrtcvideocapturer.h
@@ -98,7 +98,7 @@
 struct WebRtcCapturedFrame : public CapturedFrame {
  public:
   WebRtcCapturedFrame(const webrtc::I420VideoFrame& frame,
-                      void* buffer, int length);
+                      void* buffer, size_t length);
 };
 
 }  // namespace cricket
diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc
index 88acc3f..1e8c43b 100644
--- a/talk/media/webrtc/webrtcvideoengine.cc
+++ b/talk/media/webrtc/webrtcvideoengine.cc
@@ -305,7 +305,7 @@
   }
 
   virtual int DeliverFrame(unsigned char* buffer,
-                           int buffer_size,
+                           size_t buffer_size,
                            uint32_t rtp_time_stamp,
                            int64_t ntp_time_ms,
                            int64_t render_time,
@@ -347,14 +347,14 @@
 
   virtual bool IsTextureSupported() { return true; }
 
-  int DeliverBufferFrame(unsigned char* buffer, int buffer_size,
+  int DeliverBufferFrame(unsigned char* buffer, size_t buffer_size,
                          int64 time_stamp, int64 elapsed_time) {
     WebRtcVideoFrame video_frame;
     video_frame.Alias(buffer, buffer_size, width_, height_,
                       1, 1, elapsed_time, time_stamp, 0);
 
     // Sanity check on decoded frame size.
-    if (buffer_size != static_cast<int>(VideoFrame::SizeOf(width_, height_))) {
+    if (buffer_size != VideoFrame::SizeOf(width_, height_)) {
       LOG(LS_WARNING) << "WebRtcRenderAdapter (channel " << channel_id_
                       << ") received a strange frame size: "
                       << buffer_size;
@@ -2499,7 +2499,8 @@
         ASSERT(channel_id == default_channel_id_);
         continue;
       }
-      unsigned int bytes_sent, packets_sent, bytes_recv, packets_recv;
+      size_t bytes_sent, bytes_recv;
+      unsigned int packets_sent, packets_recv;
       if (engine_->vie()->rtp()->GetRTPStatistics(channel_id, bytes_sent,
                                                   packets_sent, bytes_recv,
                                                   packets_recv) != 0) {
@@ -2829,7 +2830,7 @@
   engine()->vie()->network()->ReceivedRTPPacket(
       processing_channel_id,
       packet->data(),
-      static_cast<int>(packet->length()),
+      packet->length(),
       webrtc::PacketTime(packet_time.timestamp, packet_time.not_before));
 }
 
@@ -2858,7 +2859,7 @@
       engine_->vie()->network()->ReceivedRTCPPacket(
           recv_channel_id,
           packet->data(),
-          static_cast<int>(packet->length()));
+          packet->length());
     }
   }
   // SR may continue RR and any RR entry may correspond to any one of the send
@@ -2871,7 +2872,7 @@
     engine_->vie()->network()->ReceivedRTCPPacket(
         channel_id,
         packet->data(),
-        static_cast<int>(packet->length()));
+        packet->length());
   }
 }
 
@@ -4022,16 +4023,16 @@
 }
 
 int WebRtcVideoMediaChannel::SendPacket(int channel, const void* data,
-                                        int len) {
+                                        size_t len) {
   rtc::Buffer packet(data, len, kMaxRtpPacketLen);
-  return MediaChannel::SendPacket(&packet) ? len : -1;
+  return MediaChannel::SendPacket(&packet) ? static_cast<int>(len) : -1;
 }
 
 int WebRtcVideoMediaChannel::SendRTCPPacket(int channel,
                                             const void* data,
-                                            int len) {
+                                            size_t len) {
   rtc::Buffer packet(data, len, kMaxRtpPacketLen);
-  return MediaChannel::SendRtcp(&packet) ? len : -1;
+  return MediaChannel::SendRtcp(&packet) ? static_cast<int>(len) : -1;
 }
 
 void WebRtcVideoMediaChannel::QueueBlackFrame(uint32 ssrc, int64 timestamp,
diff --git a/talk/media/webrtc/webrtcvideoengine.h b/talk/media/webrtc/webrtcvideoengine.h
index db091af..d1ace7d 100644
--- a/talk/media/webrtc/webrtcvideoengine.h
+++ b/talk/media/webrtc/webrtcvideoengine.h
@@ -331,8 +331,10 @@
   int GetLastEngineError() { return engine()->GetLastEngineError(); }
 
   // webrtc::Transport:
-  virtual int SendPacket(int channel, const void* data, int len) OVERRIDE;
-  virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE;
+  virtual int SendPacket(int channel, const void* data, size_t len) OVERRIDE;
+  virtual int SendRTCPPacket(int channel,
+                             const void* data,
+                             size_t len) OVERRIDE;
 
   bool ConferenceModeIsEnabled() const {
     return options_.conference_mode.GetWithDefaultIfUnset(false);
diff --git a/talk/media/webrtc/webrtcvideoframe.cc b/talk/media/webrtc/webrtcvideoframe.cc
index 9e4ea06..9dbf5a5 100644
--- a/talk/media/webrtc/webrtcvideoframe.cc
+++ b/talk/media/webrtc/webrtcvideoframe.cc
@@ -71,8 +71,8 @@
   // Make sure that |video_frame_| doesn't delete the buffer, as |owned_data_|
   // will release the buffer if this FrameBuffer owns it.
   uint8_t* new_memory = NULL;
-  uint32_t new_length = 0;
-  uint32_t new_size = 0;
+  size_t new_length = 0;
+  size_t new_size = 0;
   video_frame_.Swap(new_memory, new_length, new_size);
 }
 
@@ -84,8 +84,8 @@
 void WebRtcVideoFrame::FrameBuffer::Alias(uint8* data, size_t length) {
   owned_data_.reset();
   uint8_t* new_memory = reinterpret_cast<uint8_t*>(data);
-  uint32_t new_length = static_cast<uint32_t>(length);
-  uint32_t new_size = static_cast<uint32_t>(length);
+  size_t new_length = length;
+  size_t new_size = length;
   video_frame_.Swap(new_memory, new_length, new_size);
 }
 
diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc
index c335626..9f5d306 100644
--- a/talk/media/webrtc/webrtcvoiceengine.cc
+++ b/talk/media/webrtc/webrtcvoiceengine.cc
@@ -3154,7 +3154,7 @@
   engine()->voe()->network()->ReceivedRTPPacket(
       which_channel,
       packet->data(),
-      static_cast<unsigned int>(packet->length()),
+      packet->length(),
       webrtc::PacketTime(packet_time.timestamp, packet_time.not_before));
 }
 
@@ -3179,7 +3179,7 @@
       engine()->voe()->network()->ReceivedRTCPPacket(
           which_channel,
           packet->data(),
-          static_cast<unsigned int>(packet->length()));
+          packet->length());
 
       if (IsDefaultChannel(which_channel))
         has_sent_to_default_channel = true;
@@ -3199,7 +3199,7 @@
     engine()->voe()->network()->ReceivedRTCPPacket(
         iter->second->channel(),
         packet->data(),
-        static_cast<unsigned int>(packet->length()));
+        packet->length());
   }
 }
 
@@ -3730,7 +3730,7 @@
   return true;
 }
 
-int WebRtcSoundclipStream::Read(void *buf, int len) {
+int WebRtcSoundclipStream::Read(void *buf, size_t len) {
   size_t res = 0;
   mem_.Read(buf, len, &res, NULL);
   return static_cast<int>(res);
diff --git a/talk/media/webrtc/webrtcvoiceengine.h b/talk/media/webrtc/webrtcvoiceengine.h
index 67fadc5..6dc1f25 100644
--- a/talk/media/webrtc/webrtcvoiceengine.h
+++ b/talk/media/webrtc/webrtcvoiceengine.h
@@ -69,7 +69,7 @@
   }
   void set_loop(bool loop) { loop_ = loop; }
 
-  virtual int Read(void* buf, int len) OVERRIDE;
+  virtual int Read(void* buf, size_t len) OVERRIDE;
   virtual int Rewind() OVERRIDE;
 
  private:
@@ -80,7 +80,7 @@
 // WebRtcMonitorStream is used to monitor a stream coming from WebRtc.
 // For now we just dump the data.
 class WebRtcMonitorStream : public webrtc::OutStream {
-  virtual bool Write(const void *buf, int len) OVERRIDE {
+  virtual bool Write(const void *buf, size_t len) OVERRIDE {
     return true;
   }
 };
@@ -315,17 +315,16 @@
 
  protected:
   // implements Transport interface
-  virtual int SendPacket(int channel, const void *data, int len) OVERRIDE {
+  virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE {
     rtc::Buffer packet(data, len, kMaxRtpPacketLen);
-    if (!T::SendPacket(&packet)) {
-      return -1;
-    }
-    return len;
+    return T::SendPacket(&packet) ? static_cast<int>(len) : -1;
   }
 
-  virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE {
+  virtual int SendRTCPPacket(int channel,
+                             const void* data,
+                             size_t len) OVERRIDE {
     rtc::Buffer packet(data, len, kMaxRtpPacketLen);
-    return T::SendRtcp(&packet) ? len : -1;
+    return T::SendRtcp(&packet) ? static_cast<int>(len) : -1;
   }
 
  private:
diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn
index 1c2527a..5ded359 100644
--- a/webrtc/base/BUILD.gn
+++ b/webrtc/base/BUILD.gn
@@ -184,6 +184,7 @@
     "firewallsocketserver.h",
     "flags.cc",
     "flags.h",
+    "format_macros.h",
     "gunit_prod.h",
     "helpers.cc",
     "helpers.h",
diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp
index 2fd64ba..380eee6 100644
--- a/webrtc/base/base.gyp
+++ b/webrtc/base/base.gyp
@@ -127,6 +127,7 @@
         'firewallsocketserver.h',
         'flags.cc',
         'flags.h',
+        'format_macros.h',
         'gunit_prod.h',
         'helpers.cc',
         'helpers.h',
diff --git a/webrtc/base/format_macros.h b/webrtc/base/format_macros.h
new file mode 100644
index 0000000..5d7dcc3
--- /dev/null
+++ b/webrtc/base/format_macros.h
@@ -0,0 +1,94 @@
+/*
+ *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_BASE_FORMAT_MACROS_H_
+#define WEBRTC_BASE_FORMAT_MACROS_H_
+
+// This file defines the format macros for some integer types and is derived
+// from Chromium's base/format_macros.h.
+
+// To print a 64-bit value in a portable way:
+//   int64_t value;
+//   printf("xyz:%" PRId64, value);
+// The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
+//
+// To print a size_t value in a portable way:
+//   size_t size;
+//   printf("xyz: %" PRIuS, size);
+// The "u" in the macro corresponds to %u, and S is for "size".
+
+#include "webrtc/typedefs.h"
+
+#if defined(WEBRTC_POSIX)
+
+#if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
+#error "inttypes.h has already been included before this header file, but "
+#error "without __STDC_FORMAT_MACROS defined."
+#endif
+
+#if !defined(__STDC_FORMAT_MACROS)
+#define __STDC_FORMAT_MACROS
+#endif
+
+#include <inttypes.h>
+
+#if !defined(PRIuS)
+#define PRIuS "zu"
+#endif
+
+// The size of NSInteger and NSUInteger varies between 32-bit and 64-bit
+// architectures and Apple does not provides standard format macros and
+// recommends casting. This has many drawbacks, so instead define macros
+// for formatting those types.
+#if defined(WEBRTC_MAC)
+#if defined(WEBRTC_ARCH_64_BITS)
+#if !defined(PRIdNS)
+#define PRIdNS "ld"
+#endif
+#if !defined(PRIuNS)
+#define PRIuNS "lu"
+#endif
+#if !defined(PRIxNS)
+#define PRIxNS "lx"
+#endif
+#else  // defined(WEBRTC_ARCH_64_BITS)
+#if !defined(PRIdNS)
+#define PRIdNS "d"
+#endif
+#if !defined(PRIuNS)
+#define PRIuNS "u"
+#endif
+#if !defined(PRIxNS)
+#define PRIxNS "x"
+#endif
+#endif
+#endif  // defined(WEBRTC_MAC)
+
+#else  // WEBRTC_WIN
+
+#if !defined(PRId64)
+#define PRId64 "I64d"
+#endif
+
+#if !defined(PRIu64)
+#define PRIu64 "I64u"
+#endif
+
+#if !defined(PRIx64)
+#define PRIx64 "I64x"
+#endif
+
+#if !defined(PRIuS)
+#define PRIuS "Iu"
+#endif
+
+#endif
+
+#endif  // WEBRTC_BASE_FORMAT_MACROS_H_
diff --git a/webrtc/common_types.h b/webrtc/common_types.h
index 0b4af26..aa6f319 100644
--- a/webrtc/common_types.h
+++ b/webrtc/common_types.h
@@ -56,7 +56,7 @@
 class InStream
 {
 public:
-    virtual int Read(void *buf,int len) = 0;
+    virtual int Read(void *buf, size_t len) = 0;
     virtual int Rewind() {return -1;}
     virtual ~InStream() {}
 protected:
@@ -66,7 +66,7 @@
 class OutStream
 {
 public:
-    virtual bool Write(const void *buf,int len) = 0;
+    virtual bool Write(const void *buf, size_t len) = 0;
     virtual int Rewind() {return -1;}
     virtual ~OutStream() {}
 protected:
@@ -166,8 +166,8 @@
 class Transport
 {
 public:
-    virtual int SendPacket(int channel, const void *data, int len) = 0;
-    virtual int SendRTCPPacket(int channel, const void *data, int len) = 0;
+    virtual int SendPacket(int channel, const void *data, size_t len) = 0;
+    virtual int SendRTCPPacket(int channel, const void *data, size_t len) = 0;
 
 protected:
     virtual ~Transport() {}
@@ -240,9 +240,9 @@
      fec_packets(0) {}
 
   // TODO(pbos): Rename bytes -> media_bytes.
-  uint32_t bytes;  // Payload bytes, excluding RTP headers and padding.
-  uint32_t header_bytes;  // Number of bytes used by RTP headers.
-  uint32_t padding_bytes;  // Number of padding bytes.
+  size_t bytes;  // Payload bytes, excluding RTP headers and padding.
+  size_t header_bytes;  // Number of bytes used by RTP headers.
+  size_t padding_bytes;  // Number of padding bytes.
   uint32_t packets;  // Number of packets.
   uint32_t retransmitted_packets;  // Number of retransmitted packets.
   uint32_t fec_packets;  // Number of redundancy packets.
@@ -828,8 +828,8 @@
   uint32_t ssrc;
   uint8_t numCSRCs;
   uint32_t arrOfCSRCs[kRtpCsrcSize];
-  uint8_t paddingLength;
-  uint16_t headerLength;
+  size_t paddingLength;
+  size_t headerLength;
   int payload_type_frequency;
   RTPHeaderExtension extension;
 };
diff --git a/webrtc/common_video/libyuv/include/webrtc_libyuv.h b/webrtc/common_video/libyuv/include/webrtc_libyuv.h
index 70d8e2a..8f6e031 100644
--- a/webrtc/common_video/libyuv/include/webrtc_libyuv.h
+++ b/webrtc/common_video/libyuv/include/webrtc_libyuv.h
@@ -81,8 +81,8 @@
 //   - width        :frame width in pixels.
 //   - height       :frame height in pixels.
 // Return value:    :The required size in bytes to accommodate the specified
-//                   video frame or -1 in case of an error .
-int CalcBufferSize(VideoType type, int width, int height);
+//                   video frame.
+size_t CalcBufferSize(VideoType type, int width, int height);
 
 // TODO(mikhal): Add unit test for these two functions and determine location.
 // Print I420VideoFrame to file
@@ -101,7 +101,7 @@
 //   - buffer      : Pointer to buffer
 // Return value: length of buffer if OK, < 0 otherwise.
 int ExtractBuffer(const I420VideoFrame& input_frame,
-                  int size, uint8_t* buffer);
+                  size_t size, uint8_t* buffer);
 // Convert To I420
 // Input:
 //   - src_video_type   : Type of input video.
@@ -119,7 +119,7 @@
                   const uint8_t* src_frame,
                   int crop_x, int crop_y,
                   int src_width, int src_height,
-                  int sample_size,
+                  size_t sample_size,
                   VideoRotationMode rotation,
                   I420VideoFrame* dst_frame);
 
diff --git a/webrtc/common_video/libyuv/libyuv_unittest.cc b/webrtc/common_video/libyuv/libyuv_unittest.cc
index 0abe7f3..c9c3b1c 100644
--- a/webrtc/common_video/libyuv/libyuv_unittest.cc
+++ b/webrtc/common_video/libyuv/libyuv_unittest.cc
@@ -89,7 +89,7 @@
   const int height_;
   const int size_y_;
   const int size_uv_;
-  const int frame_length_;
+  const size_t frame_length_;
 };
 
 TestLibYuv::TestLibYuv()
@@ -110,8 +110,8 @@
   ASSERT_TRUE(source_file_ != NULL) << "Cannot read file: "<<
                                        input_file_name << "\n";
 
-  EXPECT_EQ(fread(orig_buffer_.get(), 1, frame_length_, source_file_),
-            static_cast<unsigned int>(frame_length_));
+  EXPECT_EQ(frame_length_,
+            fread(orig_buffer_.get(), 1, frame_length_, source_file_));
   EXPECT_EQ(0, orig_frame_.CreateFrame(size_y_, orig_buffer_.get(),
                                        size_uv_, orig_buffer_.get() + size_y_,
                                        size_uv_, orig_buffer_.get() +
@@ -206,8 +206,8 @@
                          width_, height_,
                          width_, (width_ + 1) / 2, (width_ + 1) / 2);
   EXPECT_EQ(0, ConvertFromYV12(yv12_frame, kI420, 0, res_i420_buffer.get()));
-  if (fwrite(res_i420_buffer.get(), 1, frame_length_,
-             output_file) != static_cast<unsigned int>(frame_length_)) {
+  if (fwrite(res_i420_buffer.get(), 1, frame_length_, output_file) !=
+      frame_length_) {
     return;
   }
 
diff --git a/webrtc/common_video/libyuv/scaler_unittest.cc b/webrtc/common_video/libyuv/scaler_unittest.cc
index f186d82..a3fbc48 100644
--- a/webrtc/common_video/libyuv/scaler_unittest.cc
+++ b/webrtc/common_video/libyuv/scaler_unittest.cc
@@ -44,7 +44,7 @@
   const int half_height_;
   const int size_y_;
   const int size_uv_;
-  const int frame_length_;
+  const size_t frame_length_;
 };
 
 TestScaler::TestScaler()
@@ -392,7 +392,7 @@
   rewind(input_file);
   rewind(output_file);
 
-  int required_size = CalcBufferSize(kI420, width, height);
+  size_t required_size = CalcBufferSize(kI420, width, height);
   uint8_t* input_buffer = new uint8_t[required_size];
   uint8_t* output_buffer = new uint8_t[required_size];
 
@@ -400,12 +400,10 @@
   double avg_psnr = 0;
   I420VideoFrame in_frame, out_frame;
   while (feof(input_file) == 0) {
-    if ((size_t)required_size !=
-        fread(input_buffer, 1, required_size, input_file)) {
+    if (fread(input_buffer, 1, required_size, input_file) != required_size) {
       break;
     }
-    if ((size_t)required_size !=
-        fread(output_buffer, 1, required_size, output_file)) {
+    if (fread(output_buffer, 1, required_size, output_file) != required_size) {
       break;
     }
     frame_count++;
@@ -441,15 +439,15 @@
   int64_t start_clock, total_clock;
   total_clock = 0;
   int frame_count = 0;
-  int src_required_size = CalcBufferSize(kI420, src_width, src_height);
+  size_t src_required_size = CalcBufferSize(kI420, src_width, src_height);
   scoped_ptr<uint8_t[]> frame_buffer(new uint8_t[src_required_size]);
   int size_y = src_width * src_height;
   int size_uv = ((src_width + 1) / 2) * ((src_height + 1) / 2);
 
   // Running through entire sequence.
   while (feof(source_file) == 0) {
-    if ((size_t)src_required_size !=
-      fread(frame_buffer.get(), 1, src_required_size, source_file))
+    if (fread(frame_buffer.get(), 1, src_required_size, source_file) !=
+        src_required_size)
       break;
 
     input_frame.CreateFrame(size_y, frame_buffer.get(),
diff --git a/webrtc/common_video/libyuv/webrtc_libyuv.cc b/webrtc/common_video/libyuv/webrtc_libyuv.cc
index 0094525..2c509b2 100644
--- a/webrtc/common_video/libyuv/webrtc_libyuv.cc
+++ b/webrtc/common_video/libyuv/webrtc_libyuv.cc
@@ -66,8 +66,10 @@
   *stride_uv = AlignInt((width + 1) / 2, k16ByteAlignment);
 }
 
-int CalcBufferSize(VideoType type, int width, int height) {
-  int buffer_size = 0;
+size_t CalcBufferSize(VideoType type, int width, int height) {
+  assert(width >= 0);
+  assert(height >= 0);
+  size_t buffer_size = 0;
   switch (type) {
     case kI420:
     case kNV12:
@@ -95,7 +97,7 @@
       break;
     default:
       assert(false);
-      return -1;
+      break;
   }
   return buffer_size;
 }
@@ -122,11 +124,12 @@
 }
 
 int ExtractBuffer(const I420VideoFrame& input_frame,
-                  int size, uint8_t* buffer) {
+                  size_t size, uint8_t* buffer) {
   assert(buffer);
   if (input_frame.IsZeroSize())
     return -1;
-  int length = CalcBufferSize(kI420, input_frame.width(), input_frame.height());
+  size_t length =
+      CalcBufferSize(kI420, input_frame.width(), input_frame.height());
   if (size < length) {
      return -1;
   }
@@ -147,7 +150,7 @@
       plane_ptr += input_frame.stride(static_cast<PlaneType>(plane));
     }
   }
-  return length;
+  return static_cast<int>(length);
 }
 
 
@@ -230,7 +233,7 @@
                   const uint8_t* src_frame,
                   int crop_x, int crop_y,
                   int src_width, int src_height,
-                  int sample_size,
+                  size_t sample_size,
                   VideoRotationMode rotation,
                   I420VideoFrame* dst_frame) {
   int dst_width = dst_frame->width();
diff --git a/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h b/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h
index d90a269..b016f40 100644
--- a/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h
+++ b/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h
@@ -12,6 +12,7 @@
 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_
 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INTERFACE_WEBRTC_CNG_H_
 
+#include <stddef.h>
 #include "webrtc/typedefs.h"
 
 #ifdef __cplusplus
@@ -120,7 +121,7 @@
  *                      -1 - Error
  */
 int16_t WebRtcCng_UpdateSid(CNG_dec_inst* cng_inst, uint8_t* SID,
-                            int16_t length);
+                            size_t length);
 
 /****************************************************************************
  * WebRtcCng_Generate(...)
diff --git a/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c b/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c
index 28bfaae..614a3df 100644
--- a/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c
+++ b/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c
@@ -411,7 +411,7 @@
  *                      -1 - Error
  */
 int16_t WebRtcCng_UpdateSid(CNG_dec_inst* cng_inst, uint8_t* SID,
-                            int16_t length) {
+                            size_t length) {
 
   WebRtcCngDecInst_t* inst = (WebRtcCngDecInst_t*) cng_inst;
   int16_t refCs[WEBRTC_CNG_MAX_LPC_ORDER];
@@ -427,7 +427,7 @@
   if (length > (WEBRTC_CNG_MAX_LPC_ORDER + 1))
     length = WEBRTC_CNG_MAX_LPC_ORDER + 1;
 
-  inst->dec_order = length - 1;
+  inst->dec_order = (int16_t)length - 1;
 
   if (SID[0] > 93)
     SID[0] = 93;
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc b/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc
index 7e41328..08ece69 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receive_test.cc
@@ -113,10 +113,9 @@
     header.header = packet->header();
     header.frameType = kAudioFrameSpeech;
     memset(&header.type.Audio, 0, sizeof(RTPAudioHeader));
-    EXPECT_TRUE(
-        acm_->InsertPacket(packet->payload(),
-                           static_cast<int32_t>(packet->payload_length_bytes()),
-                           header))
+    EXPECT_TRUE(acm_->InsertPacket(packet->payload(),
+                                   packet->payload_length_bytes(),
+                                   header))
         << "Failure when inserting packet:" << std::endl
         << "  PT = " << static_cast<int>(header.header.payloadType) << std::endl
         << "  TS = " << header.header.timestamp << std::endl
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index 0744754..bbe5a16 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -261,7 +261,7 @@
 
 int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
                               const uint8_t* incoming_payload,
-                              int length_payload) {
+                              size_t length_payload) {
   uint32_t receive_timestamp = 0;
   InitialDelayManager::PacketType packet_type =
       InitialDelayManager::kUndefinedPacket;
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
index 6d31b9a..057cb5a 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.h
@@ -67,7 +67,7 @@
   //
   int InsertPacket(const WebRtcRTPHeader& rtp_header,
                    const uint8_t* incoming_payload,
-                   int length_payload);
+                   size_t length_payload);
 
   //
   // Asks NetEq for 10 milliseconds of decoded audio.
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc
index 9cfef3a..ff43899 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc
@@ -115,12 +115,12 @@
     }
   }
 
-  virtual int SendData(
+  virtual int32_t SendData(
       FrameType frame_type,
       uint8_t payload_type,
       uint32_t timestamp,
       const uint8_t* payload_data,
-      uint16_t payload_len_bytes,
+      size_t payload_len_bytes,
       const RTPFragmentationHeader* fragmentation) OVERRIDE {
     if (frame_type == kFrameEmpty)
       return 0;
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc
index ef890ec..8c37c96 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc
@@ -124,7 +124,7 @@
       uint8_t payload_type,
       uint32_t timestamp,
       const uint8_t* payload_data,
-      uint16_t payload_len_bytes,
+      size_t payload_len_bytes,
       const RTPFragmentationHeader* fragmentation) OVERRIDE {
     if (frame_type == kFrameEmpty)
       return 0;
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc b/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc
index ec3c254..d2ecb16 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test.cc
@@ -94,7 +94,7 @@
                               uint8_t payload_type,
                               uint32_t timestamp,
                               const uint8_t* payload_data,
-                              uint16_t payload_len_bytes,
+                              size_t payload_len_bytes,
                               const RTPFragmentationHeader* fragmentation) {
   // Store the packet locally.
   frame_type_ = frame_type;
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test.h b/webrtc/modules/audio_coding/main/acm2/acm_send_test.h
index 8bc0cde..ac20cc7 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_send_test.h
+++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test.h
@@ -49,7 +49,7 @@
       uint8_t payload_type,
       uint32_t timestamp,
       const uint8_t* payload_data,
-      uint16_t payload_len_bytes,
+      size_t payload_len_bytes,
       const RTPFragmentationHeader* fragmentation) OVERRIDE;
 
  private:
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc
index 2f5178e..42dc628 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.cc
@@ -98,7 +98,7 @@
     uint8_t payload_type,
     uint32_t timestamp,
     const uint8_t* payload_data,
-    uint16_t payload_len_bytes,
+    size_t payload_len_bytes,
     const RTPFragmentationHeader* fragmentation) {
   // Store the packet locally.
   frame_type_ = frame_type;
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h
index ff229a0..e990284 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h
+++ b/webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h
@@ -51,7 +51,7 @@
       uint8_t payload_type,
       uint32_t timestamp,
       const uint8_t* payload_data,
-      uint16_t payload_len_bytes,
+      size_t payload_len_bytes,
       const RTPFragmentationHeader* fragmentation) OVERRIDE;
 
  private:
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 bee1f66..458e5c8 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
@@ -314,7 +314,7 @@
 int AudioCodingModuleImpl::ProcessDualStream() {
   uint8_t stream[kMaxNumFragmentationVectors * MAX_PAYLOAD_SIZE_BYTE];
   uint32_t current_timestamp;
-  int16_t length_bytes = 0;
+  size_t length_bytes = 0;
   RTPFragmentationHeader my_fragmentation;
 
   uint8_t my_red_payload_type;
@@ -336,8 +336,7 @@
       // Nothing to send.
       return 0;
     }
-    int len_bytes_previous_secondary = static_cast<int>(
-        fragmentation_.fragmentationLength[2]);
+    size_t len_bytes_previous_secondary = fragmentation_.fragmentationLength[2];
     assert(len_bytes_previous_secondary <= MAX_PAYLOAD_SIZE_BYTE);
     bool has_previous_payload = len_bytes_previous_secondary > 0;
 
@@ -1689,13 +1688,8 @@
 
 // Incoming packet from network parsed and ready for decode.
 int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload,
-                                          const int payload_length,
+                                          const size_t payload_length,
                                           const WebRtcRTPHeader& rtp_header) {
-  if (payload_length < 0) {
-    WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
-                 "IncomingPacket() Error, payload-length cannot be negative");
-    return -1;
-  }
   int last_audio_pltype = receiver_.last_audio_payload_type();
   if (receiver_.InsertPacket(rtp_header, incoming_payload, payload_length) <
       0) {
@@ -1797,16 +1791,9 @@
 
 // TODO(tlegrand): Modify this function to work for stereo, and add tests.
 int AudioCodingModuleImpl::IncomingPayload(const uint8_t* incoming_payload,
-                                           int payload_length,
+                                           size_t payload_length,
                                            uint8_t payload_type,
                                            uint32_t timestamp) {
-  if (payload_length < 0) {
-    // Log error in trace file.
-    WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
-                 "IncomingPacket() Error, payload-length cannot be negative");
-    return -1;
-  }
-
   // We are not acquiring any lock when interacting with |aux_rtp_header_| no
   // other method uses this member variable.
   if (aux_rtp_header_ == NULL) {
@@ -1960,7 +1947,7 @@
 }
 
 void AudioCodingModuleImpl::ResetFragmentation(int vector_size) {
-  for (int n = 0; n < kMaxNumFragmentationVectors; n++) {
+  for (size_t n = 0; n < kMaxNumFragmentationVectors; n++) {
     fragmentation_.fragmentationOffset[n] = n * MAX_PAYLOAD_SIZE_BYTE;
   }
   memset(fragmentation_.fragmentationLength, 0, kMaxNumFragmentationVectors *
@@ -2116,14 +2103,14 @@
 }
 
 bool AudioCodingImpl::InsertPacket(const uint8_t* incoming_payload,
-                                   int32_t payload_len_bytes,
+                                   size_t payload_len_bytes,
                                    const WebRtcRTPHeader& rtp_info) {
   return acm_old_->IncomingPacket(
              incoming_payload, payload_len_bytes, rtp_info) == 0;
 }
 
 bool AudioCodingImpl::InsertPayload(const uint8_t* incoming_payload,
-                                    int32_t payload_len_byte,
+                                    size_t payload_len_byte,
                                     uint8_t payload_type,
                                     uint32_t timestamp) {
   FATAL() << "Not implemented yet.";
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
index b8d128f..949ce33 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h
@@ -156,13 +156,13 @@
 
   // Incoming packet from network parsed and ready for decode.
   virtual int IncomingPacket(const uint8_t* incoming_payload,
-                             int payload_length,
+                             const size_t payload_length,
                              const WebRtcRTPHeader& rtp_info) OVERRIDE;
 
   // Incoming payloads, without rtp-info, the rtp-info will be created in ACM.
   // One usage for this API is when pre-encoded files are pushed in ACM.
   virtual int IncomingPayload(const uint8_t* incoming_payload,
-                              int payload_length,
+                              const size_t payload_length,
                               uint8_t payload_type,
                               uint32_t timestamp) OVERRIDE;
 
@@ -423,11 +423,11 @@
                                     uint8_t payload_type) OVERRIDE;
 
   virtual bool InsertPacket(const uint8_t* incoming_payload,
-                            int32_t payload_len_bytes,
+                            size_t payload_len_bytes,
                             const WebRtcRTPHeader& rtp_info) OVERRIDE;
 
   virtual bool InsertPayload(const uint8_t* incoming_payload,
-                             int32_t payload_len_byte,
+                             size_t payload_len_byte,
                              uint8_t payload_type,
                              uint32_t timestamp) OVERRIDE;
 
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
index 828b772..b64c74d 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
@@ -42,7 +42,7 @@
 const int kNumSamples10ms = kSampleRateHz / 100;
 const int kFrameSizeMs = 10;  // Multiple of 10.
 const int kFrameSizeSamples = kFrameSizeMs / 10 * kNumSamples10ms;
-const int kPayloadSizeBytes = kFrameSizeSamples * sizeof(int16_t);
+const size_t kPayloadSizeBytes = kFrameSizeSamples * sizeof(int16_t);
 const uint8_t kPayloadType = 111;
 
 class RtpUtility {
@@ -87,7 +87,7 @@
       uint8_t payload_type,
       uint32_t timestamp,
       const uint8_t* payload_data,
-      uint16_t payload_len_bytes,
+      size_t payload_len_bytes,
       const RTPFragmentationHeader* fragmentation) OVERRIDE {
     CriticalSectionScoped lock(crit_sect_.get());
     ++num_calls_;
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
index d9ed32c..e887317 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
@@ -87,7 +87,7 @@
       uint8_t payload_type,
       uint32_t timestamp,
       const uint8_t* payload_data,
-      uint16_t payload_len_bytes,
+      size_t payload_len_bytes,
       const RTPFragmentationHeader* fragmentation) OVERRIDE {
     CriticalSectionScoped lock(crit_sect_.get());
     ++num_calls_;
diff --git a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
index 8d73285..8dd5cdc 100644
--- a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
+++ b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
@@ -36,13 +36,12 @@
  public:
   virtual ~AudioPacketizationCallback() {}
 
-  virtual int32_t SendData(
-      FrameType frame_type,
-      uint8_t payload_type,
-      uint32_t timestamp,
-      const uint8_t* payload_data,
-      uint16_t payload_len_bytes,
-      const RTPFragmentationHeader* fragmentation) = 0;
+  virtual int32_t SendData(FrameType frame_type,
+                           uint8_t payload_type,
+                           uint32_t timestamp,
+                           const uint8_t* payload_data,
+                           size_t payload_len_bytes,
+                           const RTPFragmentationHeader* fragmentation) = 0;
 };
 
 // Callback class used for inband Dtmf detection
@@ -668,8 +667,8 @@
   //    0 if payload is successfully pushed in.
   //
   virtual int32_t IncomingPacket(const uint8_t* incoming_payload,
-                                       const int32_t payload_len_bytes,
-                                       const WebRtcRTPHeader& rtp_info) = 0;
+                                 const size_t payload_len_bytes,
+                                 const WebRtcRTPHeader& rtp_info) = 0;
 
   ///////////////////////////////////////////////////////////////////////////
   // int32_t IncomingPayload()
@@ -696,9 +695,9 @@
   //    0 if payload is successfully pushed in.
   //
   virtual int32_t IncomingPayload(const uint8_t* incoming_payload,
-                                        const int32_t payload_len_byte,
-                                        const uint8_t payload_type,
-                                        const uint32_t timestamp = 0) = 0;
+                                  const size_t payload_len_byte,
+                                  const uint8_t payload_type,
+                                  const uint32_t timestamp = 0) = 0;
 
   ///////////////////////////////////////////////////////////////////////////
   // int SetMinimumPlayoutDelay()
@@ -1090,12 +1089,12 @@
   // |incoming_payload| contains the RTP payload after the RTP header. Return
   // true if successful, false if not.
   virtual bool InsertPacket(const uint8_t* incoming_payload,
-                            int32_t payload_len_bytes,
+                            size_t payload_len_bytes,
                             const WebRtcRTPHeader& rtp_info) = 0;
 
   // TODO(henrik.lundin): Remove this method?
   virtual bool InsertPayload(const uint8_t* incoming_payload,
-                             int32_t payload_len_byte,
+                             size_t payload_len_byte,
                              uint8_t payload_type,
                              uint32_t timestamp) = 0;
 
diff --git a/webrtc/modules/audio_coding/main/test/Channel.cc b/webrtc/modules/audio_coding/main/test/Channel.cc
index 20ecf3a..aa9e6cd 100644
--- a/webrtc/modules/audio_coding/main/test/Channel.cc
+++ b/webrtc/modules/audio_coding/main/test/Channel.cc
@@ -13,18 +13,21 @@
 #include <assert.h>
 #include <iostream>
 
+#include "webrtc/base/format_macros.h"
 #include "webrtc/system_wrappers/interface/tick_util.h"
 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
 
 namespace webrtc {
 
-int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType,
-                          const uint32_t timeStamp, const uint8_t* payloadData,
-                          const uint16_t payloadSize,
+int32_t Channel::SendData(FrameType frameType,
+                          uint8_t payloadType,
+                          uint32_t timeStamp,
+                          const uint8_t* payloadData,
+                          size_t payloadSize,
                           const RTPFragmentationHeader* fragmentation) {
   WebRtcRTPHeader rtpInfo;
   int32_t status;
-  uint16_t payloadDataSize = payloadSize;
+  size_t payloadDataSize = payloadSize;
 
   rtpInfo.header.markerBit = false;
   rtpInfo.header.ssrc = 0;
@@ -52,8 +55,8 @@
         (fragmentation->fragmentationVectorSize == 2)) {
       // only 0x80 if we have multiple blocks
       _payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1];
-      uint32_t REDheader = (((uint32_t) fragmentation->fragmentationTimeDiff[1])
-          << 10) + fragmentation->fragmentationLength[1];
+      size_t REDheader = (fragmentation->fragmentationTimeDiff[1] << 10) +
+          fragmentation->fragmentationLength[1];
       _payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF);
       _payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF);
       _payloadData[3] = uint8_t(REDheader & 0x000000FF);
@@ -72,7 +75,7 @@
       // single block (newest one)
       memcpy(_payloadData, payloadData + fragmentation->fragmentationOffset[0],
              fragmentation->fragmentationLength[0]);
-      payloadDataSize = uint16_t(fragmentation->fragmentationLength[0]);
+      payloadDataSize = fragmentation->fragmentationLength[0];
       rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0];
     }
   } else {
@@ -121,7 +124,7 @@
 }
 
 // TODO(turajs): rewite this method.
-void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize) {
+void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
   int n;
   if ((rtpInfo.header.payloadType != _lastPayloadType)
       && (_lastPayloadType != -1)) {
@@ -371,7 +374,7 @@
            payloadStats.frameSizeStats[k].frameSizeSample);
     printf("Average Rate.................. %.0f bits/sec\n",
            payloadStats.frameSizeStats[k].rateBitPerSec);
-    printf("Maximum Payload-Size.......... %d Bytes\n",
+    printf("Maximum Payload-Size.......... %" PRIuS " Bytes\n",
            payloadStats.frameSizeStats[k].maxPayloadLen);
     printf(
         "Maximum Instantaneous Rate.... %.0f bits/sec\n",
diff --git a/webrtc/modules/audio_coding/main/test/Channel.h b/webrtc/modules/audio_coding/main/test/Channel.h
index cdb99c0..4ab32b9 100644
--- a/webrtc/modules/audio_coding/main/test/Channel.h
+++ b/webrtc/modules/audio_coding/main/test/Channel.h
@@ -27,7 +27,7 @@
 // TODO(turajs): Write constructor for this structure.
 struct ACMTestFrameSizeStats {
   uint16_t frameSizeSample;
-  int16_t maxPayloadLen;
+  size_t maxPayloadLen;
   uint32_t numPackets;
   uint64_t totalPayloadLenByte;
   uint64_t totalEncodedSamples;
@@ -39,7 +39,7 @@
 struct ACMTestPayloadStats {
   bool newPacket;
   int16_t payloadType;
-  int16_t lastPayloadLenByte;
+  size_t lastPayloadLenByte;
   uint32_t lastTimestamp;
   ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
 };
@@ -51,9 +51,11 @@
   ~Channel();
 
   virtual int32_t SendData(
-      const FrameType frameType, const uint8_t payloadType,
-      const uint32_t timeStamp, const uint8_t* payloadData,
-      const uint16_t payloadSize,
+      FrameType frameType,
+      uint8_t payloadType,
+      uint32_t timeStamp,
+      const uint8_t* payloadData,
+      size_t payloadSize,
       const RTPFragmentationHeader* fragmentation) OVERRIDE;
 
   void RegisterReceiverACM(AudioCodingModule *acm);
@@ -93,7 +95,7 @@
   }
 
  private:
-  void CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize);
+  void CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize);
 
   AudioCodingModule* _receiverACM;
   uint16_t _seqNo;
diff --git a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc
index 66fd220..27f5500 100644
--- a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc
+++ b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc
@@ -37,7 +37,7 @@
 int32_t TestPacketization::SendData(
     const FrameType /* frameType */, const uint8_t payloadType,
     const uint32_t timeStamp, const uint8_t* payloadData,
-    const uint16_t payloadSize,
+    const size_t payloadSize,
     const RTPFragmentationHeader* /* fragmentation */) {
   _rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize,
                     _frequency);
diff --git a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h
index f6b5553..4ee4fa2 100644
--- a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h
+++ b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h
@@ -30,9 +30,11 @@
   TestPacketization(RTPStream *rtpStream, uint16_t frequency);
   ~TestPacketization();
   virtual int32_t SendData(
-      const FrameType frameType, const uint8_t payloadType,
-      const uint32_t timeStamp, const uint8_t* payloadData,
-      const uint16_t payloadSize,
+      const FrameType frameType,
+      const uint8_t payloadType,
+      const uint32_t timeStamp,
+      const uint8_t* payloadData,
+      const size_t payloadSize,
       const RTPFragmentationHeader* fragmentation) OVERRIDE;
 
  private:
@@ -92,8 +94,8 @@
   uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD];
   RTPStream* _rtpStream;
   WebRtcRTPHeader _rtpInfo;
-  uint16_t _realPayloadSizeBytes;
-  uint16_t _payloadSizeBytes;
+  size_t _realPayloadSizeBytes;
+  size_t _payloadSizeBytes;
   uint32_t _nextTime;
 };
 
diff --git a/webrtc/modules/audio_coding/main/test/RTPFile.cc b/webrtc/modules/audio_coding/main/test/RTPFile.cc
index b7f587b..6f0c74e 100644
--- a/webrtc/modules/audio_coding/main/test/RTPFile.cc
+++ b/webrtc/modules/audio_coding/main/test/RTPFile.cc
@@ -11,6 +11,7 @@
 #include "RTPFile.h"
 
 #include <stdlib.h>
+#include <limits>
 
 #ifdef WIN32
 #   include <Winsock2.h>
@@ -60,7 +61,7 @@
 }
 
 RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
-                     const uint8_t* payloadData, uint16_t payloadSize,
+                     const uint8_t* payloadData, size_t payloadSize,
                      uint32_t frequency)
     : payloadType(payloadType),
       timeStamp(timeStamp),
@@ -87,7 +88,7 @@
 
 void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp,
                       const int16_t seqNo, const uint8_t* payloadData,
-                      const uint16_t payloadSize, uint32_t frequency) {
+                      const size_t payloadSize, uint32_t frequency) {
   RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData,
                                     payloadSize, frequency);
   _queueRWLock->AcquireLockExclusive();
@@ -95,8 +96,8 @@
   _queueRWLock->ReleaseLockExclusive();
 }
 
-uint16_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
-                         uint16_t payloadSize, uint32_t* offset) {
+size_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
+                       size_t payloadSize, uint32_t* offset) {
   _queueRWLock->AcquireLockShared();
   RTPPacket *packet = _rtpQueue.front();
   _rtpQueue.pop();
@@ -143,21 +144,11 @@
   fprintf(_rtpFile, "#!RTPencode%s\n", "1.0");
   uint32_t dummy_variable = 0;
   // should be converted to network endian format, but does not matter when 0
-  if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
-    return;
-  }
-  if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
-    return;
-  }
-  if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
-    return;
-  }
-  if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) {
-    return;
-  }
-  if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) {
-    return;
-  }
+  EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile));
+  EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile));
+  EXPECT_EQ(1u, fwrite(&dummy_variable, 4, 1, _rtpFile));
+  EXPECT_EQ(1u, fwrite(&dummy_variable, 2, 1, _rtpFile));
+  EXPECT_EQ(1u, fwrite(&dummy_variable, 2, 1, _rtpFile));
   fflush(_rtpFile);
 }
 
@@ -180,35 +171,26 @@
 
 void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp,
                     const int16_t seqNo, const uint8_t* payloadData,
-                    const uint16_t payloadSize, uint32_t frequency) {
+                    const size_t payloadSize, uint32_t frequency) {
   /* write RTP packet to file */
   uint8_t rtpHeader[12];
   MakeRTPheader(rtpHeader, payloadType, seqNo, timeStamp, 0);
-  uint16_t lengthBytes = htons(12 + payloadSize + 8);
-  uint16_t plen = htons(12 + payloadSize);
+  ASSERT_LE(12 + payloadSize + 8, std::numeric_limits<u_short>::max());
+  uint16_t lengthBytes = htons(static_cast<u_short>(12 + payloadSize + 8));
+  uint16_t plen = htons(static_cast<u_short>(12 + payloadSize));
   uint32_t offsetMs;
 
   offsetMs = (timeStamp / (frequency / 1000));
   offsetMs = htonl(offsetMs);
-  if (fwrite(&lengthBytes, 2, 1, _rtpFile) != 1) {
-    return;
-  }
-  if (fwrite(&plen, 2, 1, _rtpFile) != 1) {
-    return;
-  }
-  if (fwrite(&offsetMs, 4, 1, _rtpFile) != 1) {
-    return;
-  }
-  if (fwrite(rtpHeader, 12, 1, _rtpFile) != 1) {
-    return;
-  }
-  if (fwrite(payloadData, 1, payloadSize, _rtpFile) != payloadSize) {
-    return;
-  }
+  EXPECT_EQ(1u, fwrite(&lengthBytes, 2, 1, _rtpFile));
+  EXPECT_EQ(1u, fwrite(&plen, 2, 1, _rtpFile));
+  EXPECT_EQ(1u, fwrite(&offsetMs, 4, 1, _rtpFile));
+  EXPECT_EQ(1u, fwrite(&rtpHeader, 12, 1, _rtpFile));
+  EXPECT_EQ(payloadSize, fwrite(payloadData, 1, payloadSize, _rtpFile));
 }
 
-uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
-                       uint16_t payloadSize, uint32_t* offset) {
+size_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
+                     size_t payloadSize, uint32_t* offset) {
   uint16_t lengthBytes;
   uint16_t plen;
   uint8_t rtpHeader[12];
@@ -237,7 +219,7 @@
   if (lengthBytes < 20) {
     return 0;
   }
-  if (payloadSize < (lengthBytes - 20)) {
+  if (payloadSize < static_cast<size_t>((lengthBytes - 20))) {
     return 0;
   }
   lengthBytes -= 20;
diff --git a/webrtc/modules/audio_coding/main/test/RTPFile.h b/webrtc/modules/audio_coding/main/test/RTPFile.h
index 460553b..9a2d43a 100644
--- a/webrtc/modules/audio_coding/main/test/RTPFile.h
+++ b/webrtc/modules/audio_coding/main/test/RTPFile.h
@@ -28,12 +28,12 @@
 
   virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
                      const int16_t seqNo, const uint8_t* payloadData,
-                     const uint16_t payloadSize, uint32_t frequency) = 0;
+                     const size_t payloadSize, uint32_t frequency) = 0;
 
   // Returns the packet's payload size. Zero should be treated as an
   // end-of-stream (in the case that EndOfFile() is true) or an error.
-  virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
-                        uint16_t payloadSize, uint32_t* offset) = 0;
+  virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
+                      size_t payloadSize, uint32_t* offset) = 0;
   virtual bool EndOfFile() const = 0;
 
  protected:
@@ -46,7 +46,7 @@
 class RTPPacket {
  public:
   RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
-            const uint8_t* payloadData, uint16_t payloadSize,
+            const uint8_t* payloadData, size_t payloadSize,
             uint32_t frequency);
 
   ~RTPPacket();
@@ -55,7 +55,7 @@
   uint32_t timeStamp;
   int16_t seqNo;
   uint8_t* payloadData;
-  uint16_t payloadSize;
+  size_t payloadSize;
   uint32_t frequency;
 };
 
@@ -67,10 +67,10 @@
 
   virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
                      const int16_t seqNo, const uint8_t* payloadData,
-                     const uint16_t payloadSize, uint32_t frequency) OVERRIDE;
+                     const size_t payloadSize, uint32_t frequency) OVERRIDE;
 
-  virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
-                        uint16_t payloadSize, uint32_t* offset) OVERRIDE;
+  virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
+                      size_t payloadSize, uint32_t* offset) OVERRIDE;
 
   virtual bool EndOfFile() const OVERRIDE;
 
@@ -99,10 +99,10 @@
 
   virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
                      const int16_t seqNo, const uint8_t* payloadData,
-                     const uint16_t payloadSize, uint32_t frequency) OVERRIDE;
+                     const size_t payloadSize, uint32_t frequency) OVERRIDE;
 
-  virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
-                        uint16_t payloadSize, uint32_t* offset) OVERRIDE;
+  virtual size_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
+                      size_t payloadSize, uint32_t* offset) OVERRIDE;
 
   virtual bool EndOfFile() const OVERRIDE {
     return _rtpEOF;
diff --git a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc
index 9b7667b..cd5a94e 100644
--- a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc
+++ b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc
@@ -10,7 +10,8 @@
 
 #include "webrtc/modules/audio_coding/main/test/TestAllCodecs.h"
 
-#include <stdio.h>
+#include <cstdio>
+#include <limits>
 #include <string>
 
 #include "testing/gtest/include/gtest/gtest.h"
@@ -32,6 +33,10 @@
 // The test loops through all available mono codecs, encode at "a" sends over
 // the channel, and decodes at "b".
 
+namespace {
+const size_t kVariableSize = std::numeric_limits<size_t>::max();
+}
+
 namespace webrtc {
 
 // Class for simulating packet handling.
@@ -54,7 +59,7 @@
 
 int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type,
                            uint32_t timestamp, const uint8_t* payload_data,
-                           uint16_t payload_size,
+                           size_t payload_size,
                            const RTPFragmentationHeader* fragmentation) {
   WebRtcRTPHeader rtp_info;
   int32_t status;
@@ -87,7 +92,7 @@
   return status;
 }
 
-uint16_t TestPack::payload_size() {
+size_t TestPack::payload_size() {
   return payload_size_;
 }
 
@@ -459,13 +464,13 @@
   test_count_++;
   OpenOutFile(test_count_);
   char codec_isac[] = "ISAC";
-  RegisterSendCodec('A', codec_isac, 16000, -1, 480, -1);
+  RegisterSendCodec('A', codec_isac, 16000, -1, 480, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_isac, 16000, -1, 960, -1);
+  RegisterSendCodec('A', codec_isac, 16000, -1, 960, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_isac, 16000, 15000, 480, -1);
+  RegisterSendCodec('A', codec_isac, 16000, 15000, 480, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_isac, 16000, 32000, 960, -1);
+  RegisterSendCodec('A', codec_isac, 16000, 32000, 960, kVariableSize);
   Run(channel_a_to_b_);
   outfile_b_.Close();
 #endif
@@ -475,13 +480,13 @@
   }
   test_count_++;
   OpenOutFile(test_count_);
-  RegisterSendCodec('A', codec_isac, 32000, -1, 960, -1);
+  RegisterSendCodec('A', codec_isac, 32000, -1, 960, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_isac, 32000, 56000, 960, -1);
+  RegisterSendCodec('A', codec_isac, 32000, 56000, 960, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_isac, 32000, 37000, 960, -1);
+  RegisterSendCodec('A', codec_isac, 32000, 37000, 960, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_isac, 32000, 32000, 960, -1);
+  RegisterSendCodec('A', codec_isac, 32000, 32000, 960, kVariableSize);
   Run(channel_a_to_b_);
   outfile_b_.Close();
 #endif
@@ -611,19 +616,19 @@
   test_count_++;
   OpenOutFile(test_count_);
   char codec_opus[] = "OPUS";
-  RegisterSendCodec('A', codec_opus, 48000, 6000, 480, -1);
+  RegisterSendCodec('A', codec_opus, 48000, 6000, 480, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, -1);
+  RegisterSendCodec('A', codec_opus, 48000, 20000, 480*2, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, -1);
+  RegisterSendCodec('A', codec_opus, 48000, 32000, 480*4, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_opus, 48000, 48000, 480, -1);
+  RegisterSendCodec('A', codec_opus, 48000, 48000, 480, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, -1);
+  RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, -1);
+  RegisterSendCodec('A', codec_opus, 48000, 96000, 480*6, kVariableSize);
   Run(channel_a_to_b_);
-  RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, -1);
+  RegisterSendCodec('A', codec_opus, 48000, 500000, 480*2, kVariableSize);
   Run(channel_a_to_b_);
   outfile_b_.Close();
 #endif
@@ -686,10 +691,11 @@
 //         packet_size      - packet size in samples
 //         extra_byte       - if extra bytes needed compared to the bitrate
 //                            used when registering, can be an internal header
-//                            set to -1 if the codec is a variable rate codec
+//                            set to kVariableSize if the codec is a variable
+//                            rate codec
 void TestAllCodecs::RegisterSendCodec(char side, char* codec_name,
                                       int32_t sampling_freq_hz, int rate,
-                                      int packet_size, int extra_byte) {
+                                      int packet_size, size_t extra_byte) {
   if (test_mode_ != 0) {
     // Print out codec and settings.
     printf("codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name,
@@ -711,14 +717,14 @@
 
   // Store the expected packet size in bytes, used to validate the received
   // packet. If variable rate codec (extra_byte == -1), set to -1.
-  if (extra_byte != -1) {
+  if (extra_byte != kVariableSize) {
     // Add 0.875 to always round up to a whole byte
-    packet_size_bytes_ = static_cast<int>(static_cast<float>(packet_size
-        * rate) / static_cast<float>(sampling_freq_hz * 8) + 0.875)
-        + extra_byte;
+    packet_size_bytes_ = static_cast<size_t>(
+        static_cast<float>(packet_size * rate) /
+        static_cast<float>(sampling_freq_hz * 8) + 0.875) + extra_byte;
   } else {
     // Packets will have a variable size.
-    packet_size_bytes_ = -1;
+    packet_size_bytes_ = kVariableSize;
   }
 
   // Set pointer to the ACM where to register the codec.
@@ -751,7 +757,7 @@
   AudioFrame audio_frame;
 
   int32_t out_freq_hz = outfile_b_.SamplingFrequency();
-  uint16_t receive_size;
+  size_t receive_size;
   uint32_t timestamp_diff;
   channel->reset_payload_size();
   int error_count = 0;
@@ -768,8 +774,8 @@
     // Verify that the received packet size matches the settings.
     receive_size = channel->payload_size();
     if (receive_size) {
-      if ((static_cast<int>(receive_size) != packet_size_bytes_) &&
-          (packet_size_bytes_ > -1)) {
+      if ((receive_size != packet_size_bytes_) &&
+          (packet_size_bytes_ != kVariableSize)) {
         error_count++;
       }
 
diff --git a/webrtc/modules/audio_coding/main/test/TestAllCodecs.h b/webrtc/modules/audio_coding/main/test/TestAllCodecs.h
index 2fbf9ef..42d65a1 100644
--- a/webrtc/modules/audio_coding/main/test/TestAllCodecs.h
+++ b/webrtc/modules/audio_coding/main/test/TestAllCodecs.h
@@ -29,12 +29,14 @@
   void RegisterReceiverACM(AudioCodingModule* acm);
 
   virtual int32_t SendData(
-      FrameType frame_type, uint8_t payload_type,
-      uint32_t timestamp, const uint8_t* payload_data,
-      uint16_t payload_size,
+      FrameType frame_type,
+      uint8_t payload_type,
+      uint32_t timestamp,
+      const uint8_t* payload_data,
+      size_t payload_size,
       const RTPFragmentationHeader* fragmentation) OVERRIDE;
 
-  uint16_t payload_size();
+  size_t payload_size();
   uint32_t timestamp_diff();
   void reset_payload_size();
 
@@ -45,7 +47,7 @@
   uint32_t timestamp_diff_;
   uint32_t last_in_timestamp_;
   uint64_t total_bytes_;
-  uint16_t payload_size_;
+  size_t payload_size_;
 };
 
 class TestAllCodecs : public ACMTest {
@@ -61,7 +63,7 @@
   // This is useful for codecs which support several sampling frequency.
   // Note! Only mono mode is tested in this test.
   void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz,
-                         int rate, int packet_size, int extra_byte);
+                         int rate, int packet_size, size_t extra_byte);
 
   void Run(TestPack* channel);
   void OpenOutFile(int test_number);
@@ -75,7 +77,7 @@
   PCMFile outfile_b_;
   int test_count_;
   int packet_size_samples_;
-  int packet_size_bytes_;
+  size_t packet_size_bytes_;
 };
 
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/main/test/TestStereo.cc b/webrtc/modules/audio_coding/main/test/TestStereo.cc
index 9c22548..86a75e5 100644
--- a/webrtc/modules/audio_coding/main/test/TestStereo.cc
+++ b/webrtc/modules/audio_coding/main/test/TestStereo.cc
@@ -48,7 +48,7 @@
                                  const uint8_t payload_type,
                                  const uint32_t timestamp,
                                  const uint8_t* payload_data,
-                                 const uint16_t payload_size,
+                                 const size_t payload_size,
                                  const RTPFragmentationHeader* fragmentation) {
   WebRtcRTPHeader rtp_info;
   int32_t status = 0;
@@ -114,18 +114,26 @@
       test_cntr_(0),
       pack_size_samp_(0),
       pack_size_bytes_(0),
-      counter_(0),
-      g722_pltype_(0),
-      l16_8khz_pltype_(-1),
-      l16_16khz_pltype_(-1),
-      l16_32khz_pltype_(-1),
-      pcma_pltype_(-1),
-      pcmu_pltype_(-1),
-      celt_pltype_(-1),
-      opus_pltype_(-1),
-      cn_8khz_pltype_(-1),
-      cn_16khz_pltype_(-1),
-      cn_32khz_pltype_(-1) {
+      counter_(0)
+#ifdef WEBRTC_CODEC_G722
+      , g722_pltype_(0)
+#endif
+#ifdef WEBRTC_CODEC_PCM16
+      , l16_8khz_pltype_(-1)
+      , l16_16khz_pltype_(-1)
+      , l16_32khz_pltype_(-1)
+#endif
+#ifdef PCMA_AND_PCMU
+      , pcma_pltype_(-1)
+      , pcmu_pltype_(-1)
+#endif
+#ifdef WEBRTC_CODEC_CELT
+      , celt_pltype_(-1)
+#endif
+#ifdef WEBRTC_CODEC_OPUS
+      , opus_pltype_(-1)
+#endif
+      {
   // test_mode = 0 for silent test (auto test)
   test_mode_ = test_mode;
 }
@@ -302,7 +310,6 @@
   Run(channel_a2b_, audio_channels, codec_channels);
   out_file_.Close();
 #endif
-#define PCMA_AND_PCMU
 #ifdef PCMA_AND_PCMU
   if (test_mode_ != 0) {
     printf("===========================================================\n");
diff --git a/webrtc/modules/audio_coding/main/test/TestStereo.h b/webrtc/modules/audio_coding/main/test/TestStereo.h
index 8aefa7f..0eb0e52 100644
--- a/webrtc/modules/audio_coding/main/test/TestStereo.h
+++ b/webrtc/modules/audio_coding/main/test/TestStereo.h
@@ -18,6 +18,8 @@
 #include "webrtc/modules/audio_coding/main/test/Channel.h"
 #include "webrtc/modules/audio_coding/main/test/PCMFile.h"
 
+#define PCMA_AND_PCMU
+
 namespace webrtc {
 
 enum StereoMonoMode {
@@ -38,7 +40,7 @@
       const uint8_t payload_type,
       const uint32_t timestamp,
       const uint8_t* payload_data,
-      const uint16_t payload_size,
+      const size_t payload_size,
       const RTPFragmentationHeader* fragmentation) OVERRIDE;
 
   uint16_t payload_size();
@@ -78,11 +80,6 @@
   void OpenOutFile(int16_t test_number);
   void DisplaySendReceiveCodec();
 
-  int32_t SendData(const FrameType frame_type, const uint8_t payload_type,
-                   const uint32_t timestamp, const uint8_t* payload_data,
-                   const uint16_t payload_size,
-                   const RTPFragmentationHeader* fragmentation);
-
   int test_mode_;
 
   scoped_ptr<AudioCodingModule> acm_a_;
@@ -100,17 +97,24 @@
   char* send_codec_name_;
 
   // Payload types for stereo codecs and CNG
+#ifdef WEBRTC_CODEC_G722
   int g722_pltype_;
+#endif
+#ifdef WEBRTC_CODEC_PCM16
   int l16_8khz_pltype_;
   int l16_16khz_pltype_;
   int l16_32khz_pltype_;
+#endif
+#ifdef PCMA_AND_PCMU
   int pcma_pltype_;
   int pcmu_pltype_;
+#endif
+#ifdef WEBRTC_CODEC_CELT
   int celt_pltype_;
+#endif
+#ifdef WEBRTC_CODEC_OPUS
   int opus_pltype_;
-  int cn_8khz_pltype_;
-  int cn_16khz_pltype_;
-  int cn_32khz_pltype_;
+#endif
 };
 
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc b/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc
index 7cd2466..9b960af 100644
--- a/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc
+++ b/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc
@@ -36,9 +36,11 @@
   void ApiTest();
 
   virtual int32_t SendData(
-      FrameType frameType, uint8_t payload_type,
-      uint32_t timestamp, const uint8_t* payload_data,
-      uint16_t payload_size,
+      FrameType frameType,
+      uint8_t payload_type,
+      uint32_t timestamp,
+      const uint8_t* payload_data,
+      size_t payload_size,
       const RTPFragmentationHeader* fragmentation) OVERRIDE;
 
   void Perform(bool start_in_sync, int num_channels_input);
@@ -49,9 +51,9 @@
   void PopulateCodecInstances(int frame_size_primary_ms,
                               int num_channels_primary, int sampling_rate);
 
-  void Validate(bool start_in_sync, int tolerance);
+  void Validate(bool start_in_sync, size_t tolerance);
   bool EqualTimestamp(int stream, int position);
-  int EqualPayloadLength(int stream, int position);
+  size_t EqualPayloadLength(int stream, int position);
   bool EqualPayloadData(int stream, int position);
 
   static const int kMaxNumStoredPayloads = 2;
@@ -77,8 +79,8 @@
   uint32_t timestamp_ref_[kMaxNumStreams][kMaxNumStoredPayloads];
   uint32_t timestamp_dual_[kMaxNumStreams][kMaxNumStoredPayloads];
 
-  int payload_len_ref_[kMaxNumStreams][kMaxNumStoredPayloads];
-  int payload_len_dual_[kMaxNumStreams][kMaxNumStoredPayloads];
+  size_t payload_len_ref_[kMaxNumStreams][kMaxNumStoredPayloads];
+  size_t payload_len_dual_[kMaxNumStreams][kMaxNumStoredPayloads];
 
   uint8_t payload_data_ref_[kMaxNumStreams][MAX_PAYLOAD_SIZE_BYTE
       * kMaxNumStoredPayloads];
@@ -174,7 +176,7 @@
   pcm_file.ReadStereo(num_channels_input == 2);
   AudioFrame audio_frame;
 
-  int tolerance = 0;
+  size_t tolerance = 0;
   if (num_channels_input == 2 && primary_encoder_.channels == 2
       && secondary_encoder_.channels == 1) {
     tolerance = 12;
@@ -253,10 +255,10 @@
   return true;
 }
 
-int DualStreamTest::EqualPayloadLength(int stream_index, int position) {
-  return abs(
-      payload_len_dual_[stream_index][position]
-          - payload_len_ref_[stream_index][position]);
+size_t DualStreamTest::EqualPayloadLength(int stream_index, int position) {
+  size_t dual = payload_len_dual_[stream_index][position];
+  size_t ref = payload_len_ref_[stream_index][position];
+  return (dual > ref) ? (dual - ref) : (ref - dual);
 }
 
 bool DualStreamTest::EqualPayloadData(int stream_index, int position) {
@@ -264,7 +266,7 @@
       payload_len_dual_[stream_index][position]
           == payload_len_ref_[stream_index][position]);
   int offset = position * MAX_PAYLOAD_SIZE_BYTE;
-  for (int n = 0; n < payload_len_dual_[stream_index][position]; n++) {
+  for (size_t n = 0; n < payload_len_dual_[stream_index][position]; n++) {
     if (payload_data_dual_[stream_index][offset + n]
         != payload_data_ref_[stream_index][offset + n]) {
       return false;
@@ -273,9 +275,9 @@
   return true;
 }
 
-void DualStreamTest::Validate(bool start_in_sync, int tolerance) {
+void DualStreamTest::Validate(bool start_in_sync, size_t tolerance) {
   for (int stream_index = 0; stream_index < kMaxNumStreams; stream_index++) {
-    int my_tolerance = stream_index == kPrimary ? 0 : tolerance;
+    size_t my_tolerance = stream_index == kPrimary ? 0 : tolerance;
     for (int position = 0; position < kMaxNumStoredPayloads; position++) {
       if (payload_ref_is_stored_[stream_index][position] == 1
           && payload_dual_is_stored_[stream_index][position] == 1) {
@@ -296,7 +298,7 @@
 int32_t DualStreamTest::SendData(FrameType frameType, uint8_t payload_type,
                                  uint32_t timestamp,
                                  const uint8_t* payload_data,
-                                 uint16_t payload_size,
+                                 size_t payload_size,
                                  const RTPFragmentationHeader* fragmentation) {
   int position;
   int stream_index;
diff --git a/webrtc/modules/audio_coding/main/test/target_delay_unittest.cc b/webrtc/modules/audio_coding/main/test/target_delay_unittest.cc
index 02b8467..a902499 100644
--- a/webrtc/modules/audio_coding/main/test/target_delay_unittest.cc
+++ b/webrtc/modules/audio_coding/main/test/target_delay_unittest.cc
@@ -46,7 +46,7 @@
 
     int16_t audio[kFrameSizeSamples];
     const int kRange = 0x7FF;  // 2047, easy for masking.
-    for (int n = 0; n < kFrameSizeSamples; ++n)
+    for (size_t n = 0; n < kFrameSizeSamples; ++n)
       audio[n] = (rand() & kRange) - kRange / 2;
     WebRtcPcm16b_Encode(audio, kFrameSizeSamples, payload_);
   }
@@ -133,7 +133,7 @@
  private:
   static const int kSampleRateHz = 16000;
   static const int kNum10msPerFrame = 2;
-  static const int kFrameSizeSamples = 320;  // 20 ms @ 16 kHz.
+  static const size_t kFrameSizeSamples = 320;  // 20 ms @ 16 kHz.
   // payload-len = frame-samples * 2 bytes/sample.
   static const int kPayloadLenBytes = 320 * 2;
   // Inter-arrival time in number of packets in a jittery channel. One is no
diff --git a/webrtc/modules/audio_coding/neteq/dtmf_buffer.cc b/webrtc/modules/audio_coding/neteq/dtmf_buffer.cc
index 91debee..b07d561 100644
--- a/webrtc/modules/audio_coding/neteq/dtmf_buffer.cc
+++ b/webrtc/modules/audio_coding/neteq/dtmf_buffer.cc
@@ -55,7 +55,7 @@
 //
 int DtmfBuffer::ParseEvent(uint32_t rtp_timestamp,
                            const uint8_t* payload,
-                           int payload_length_bytes,
+                           size_t payload_length_bytes,
                            DtmfEvent* event) {
   if (!payload || !event) {
     return kInvalidPointer;
diff --git a/webrtc/modules/audio_coding/neteq/dtmf_buffer.h b/webrtc/modules/audio_coding/neteq/dtmf_buffer.h
index 5dd31c2..5da3a16 100644
--- a/webrtc/modules/audio_coding/neteq/dtmf_buffer.h
+++ b/webrtc/modules/audio_coding/neteq/dtmf_buffer.h
@@ -69,7 +69,7 @@
   // |rtp_timestamp| is simply copied into the struct.
   static int ParseEvent(uint32_t rtp_timestamp,
                         const uint8_t* payload,
-                        int payload_length_bytes,
+                        size_t payload_length_bytes,
                         DtmfEvent* event);
 
   // Inserts |event| into the buffer. The method looks for a matching event and
diff --git a/webrtc/modules/audio_coding/neteq/interface/neteq.h b/webrtc/modules/audio_coding/neteq/interface/neteq.h
index 560e77b..b630e86 100644
--- a/webrtc/modules/audio_coding/neteq/interface/neteq.h
+++ b/webrtc/modules/audio_coding/neteq/interface/neteq.h
@@ -132,7 +132,7 @@
   // Returns 0 on success, -1 on failure.
   virtual int InsertPacket(const WebRtcRTPHeader& rtp_header,
                            const uint8_t* payload,
-                           int length_bytes,
+                           size_t length_bytes,
                            uint32_t receive_timestamp) = 0;
 
   // Inserts a sync-packet into packet queue. Sync-packets are decoded to
diff --git a/webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h b/webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h
index 09fa4e1..9fa05e9 100644
--- a/webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h
+++ b/webrtc/modules/audio_coding/neteq/mock/mock_payload_splitter.h
@@ -28,11 +28,11 @@
   MOCK_METHOD2(SplitAudio,
       int(PacketList* packet_list, const DecoderDatabase& decoder_database));
   MOCK_METHOD4(SplitBySamples,
-      void(const Packet* packet, int bytes_per_ms, int timestamps_per_ms,
-           PacketList* new_packets));
+      void(const Packet* packet, size_t bytes_per_ms,
+           uint32_t timestamps_per_ms, PacketList* new_packets));
   MOCK_METHOD4(SplitByFrames,
-      int(const Packet* packet, int bytes_per_frame, int timestamps_per_frame,
-          PacketList* new_packets));
+      int(const Packet* packet, size_t bytes_per_frame,
+          uint32_t timestamps_per_frame, PacketList* new_packets));
 };
 
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc
index d41bc54..ae2d1ae 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_external_decoder_unittest.cc
@@ -203,7 +203,7 @@
   int sample_rate_hz_;
   int samples_per_ms_;
   const int frame_size_ms_;
-  int frame_size_samples_;
+  size_t frame_size_samples_;
   int output_size_samples_;
   NetEq* neteq_external_;
   NetEq* neteq_;
@@ -214,7 +214,7 @@
   int16_t output_[kMaxBlockSize];
   int16_t output_external_[kMaxBlockSize];
   WebRtcRTPHeader rtp_header_;
-  int payload_size_bytes_;
+  size_t payload_size_bytes_;
   int last_send_time_;
   int last_arrival_time_;
   scoped_ptr<test::InputAudioFile> input_file_;
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index 7e8af3c..958eb76 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -117,7 +117,7 @@
 
 int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header,
                             const uint8_t* payload,
-                            int length_bytes,
+                            size_t length_bytes,
                             uint32_t receive_timestamp) {
   CriticalSectionScoped lock(crit_sect_.get());
   LOG(LS_VERBOSE) << "InsertPacket: ts=" << rtp_header.header.timestamp <<
@@ -399,7 +399,7 @@
 
 int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
                                     const uint8_t* payload,
-                                    int length_bytes,
+                                    size_t length_bytes,
                                     uint32_t receive_timestamp,
                                     bool is_sync_packet) {
   if (!payload) {
@@ -1241,7 +1241,7 @@
     assert(*operation == kNormal || *operation == kAccelerate ||
            *operation == kMerge || *operation == kPreemptiveExpand);
     packet_list->pop_front();
-    int payload_length = packet->payload_length;
+    size_t payload_length = packet->payload_length;
     int16_t decode_length;
     if (packet->sync_packet) {
       // Decode to silence with the same frame size as the last decode.
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.h b/webrtc/modules/audio_coding/neteq/neteq_impl.h
index 348f483..fa96512 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.h
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.h
@@ -81,7 +81,7 @@
   // Returns 0 on success, -1 on failure.
   virtual int InsertPacket(const WebRtcRTPHeader& rtp_header,
                            const uint8_t* payload,
-                           int length_bytes,
+                           size_t length_bytes,
                            uint32_t receive_timestamp) OVERRIDE;
 
   // Inserts a sync-packet into packet queue. Sync-packets are decoded to
@@ -210,7 +210,7 @@
   // TODO(hlundin): Merge this with InsertPacket above?
   int InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
                            const uint8_t* payload,
-                           int length_bytes,
+                           size_t length_bytes,
                            uint32_t receive_timestamp,
                            bool is_sync_packet)
       EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc
index 56ea425..89a4d42 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc
@@ -253,7 +253,7 @@
 
 TEST_F(NetEqImplTest, InsertPacket) {
   CreateInstance();
-  const int kPayloadLength = 100;
+  const size_t kPayloadLength = 100;
   const uint8_t kPayloadType = 0;
   const uint16_t kFirstSequenceNumber = 0x1234;
   const uint32_t kFirstTimestamp = 0x12345678;
diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc
index 7ed9a87..0ee1d06 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc
@@ -192,7 +192,7 @@
   static const int kBlockSize8kHz = kTimeStepMs * 8;
   static const int kBlockSize16kHz = kTimeStepMs * 16;
   static const int kBlockSize32kHz = kTimeStepMs * 32;
-  static const int kMaxBlockSize = kBlockSize32kHz;
+  static const size_t kMaxBlockSize = kBlockSize32kHz;
   static const int kInitSampleRateHz = 8000;
 
   NetEqDecodingTest();
@@ -213,7 +213,7 @@
                           int timestamp,
                           WebRtcRTPHeader* rtp_info,
                           uint8_t* payload,
-                          int* payload_len);
+                          size_t* payload_len);
 
   void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp,
                 const std::set<uint16_t>& drop_seq_numbers,
@@ -244,7 +244,7 @@
 const int NetEqDecodingTest::kBlockSize8kHz;
 const int NetEqDecodingTest::kBlockSize16kHz;
 const int NetEqDecodingTest::kBlockSize32kHz;
-const int NetEqDecodingTest::kMaxBlockSize;
+const size_t NetEqDecodingTest::kMaxBlockSize;
 const int NetEqDecodingTest::kInitSampleRateHz;
 
 NetEqDecodingTest::NetEqDecodingTest()
@@ -396,7 +396,7 @@
                                     int timestamp,
                                     WebRtcRTPHeader* rtp_info,
                                     uint8_t* payload,
-                                    int* payload_len) {
+                                    size_t* payload_len) {
   rtp_info->header.sequenceNumber = frame_index;
   rtp_info->header.timestamp = timestamp;
   rtp_info->header.ssrc = 0x1234;  // Just an arbitrary SSRC.
@@ -448,8 +448,8 @@
 TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) {
   // Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio.
   size_t num_frames = 30;
-  const int kSamples = 10 * 16;
-  const int kPayloadBytes = kSamples * 2;
+  const size_t kSamples = 10 * 16;
+  const size_t kPayloadBytes = kSamples * 2;
   for (size_t i = 0; i < num_frames; ++i) {
     uint16_t payload[kSamples] = {0};
     WebRtcRTPHeader rtp_info;
@@ -518,8 +518,8 @@
 TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) {
   const int kNumFrames = 3000;  // Needed for convergence.
   int frame_index = 0;
-  const int kSamples = 10 * 16;
-  const int kPayloadBytes = kSamples * 2;
+  const size_t kSamples = 10 * 16;
+  const size_t kPayloadBytes = kSamples * 2;
   while (frame_index < kNumFrames) {
     // Insert one packet each time, except every 10th time where we insert two
     // packets at once. This will create a negative clock-drift of approx. 10%.
@@ -549,8 +549,8 @@
 TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) {
   const int kNumFrames = 5000;  // Needed for convergence.
   int frame_index = 0;
-  const int kSamples = 10 * 16;
-  const int kPayloadBytes = kSamples * 2;
+  const size_t kSamples = 10 * 16;
+  const size_t kPayloadBytes = kSamples * 2;
   for (int i = 0; i < kNumFrames; ++i) {
     // Insert one packet each time, except every 10th time where we don't insert
     // any packet. This will create a positive clock-drift of approx. 11%.
@@ -585,8 +585,8 @@
   uint16_t seq_no = 0;
   uint32_t timestamp = 0;
   const int kFrameSizeMs = 30;
-  const int kSamples = kFrameSizeMs * 16;
-  const int kPayloadBytes = kSamples * 2;
+  const size_t kSamples = kFrameSizeMs * 16;
+  const size_t kPayloadBytes = kSamples * 2;
   double next_input_time_ms = 0.0;
   double t_ms;
   int out_len;
@@ -625,7 +625,7 @@
     while (next_input_time_ms <= t_ms) {
       // Insert one CNG frame each 100 ms.
       uint8_t payload[kPayloadBytes];
-      int payload_len;
+      size_t payload_len;
       WebRtcRTPHeader rtp_info;
       PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
       ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
@@ -672,7 +672,7 @@
       }
       // Insert one CNG frame each 100 ms.
       uint8_t payload[kPayloadBytes];
-      int payload_len;
+      size_t payload_len;
       WebRtcRTPHeader rtp_info;
       PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
       ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
@@ -797,7 +797,7 @@
 }
 
 TEST_F(NetEqDecodingTest, UnknownPayloadType) {
-  const int kPayloadBytes = 100;
+  const size_t kPayloadBytes = 100;
   uint8_t payload[kPayloadBytes] = {0};
   WebRtcRTPHeader rtp_info;
   PopulateRtpInfo(0, 0, &rtp_info);
@@ -808,7 +808,7 @@
 }
 
 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) {
-  const int kPayloadBytes = 100;
+  const size_t kPayloadBytes = 100;
   uint8_t payload[kPayloadBytes] = {0};
   WebRtcRTPHeader rtp_info;
   PopulateRtpInfo(0, 0, &rtp_info);
@@ -817,7 +817,7 @@
   NetEqOutputType type;
   // Set all of |out_data_| to 1, and verify that it was set to 0 by the call
   // to GetAudio.
-  for (int i = 0; i < kMaxBlockSize; ++i) {
+  for (size_t i = 0; i < kMaxBlockSize; ++i) {
     out_data_[i] = 1;
   }
   int num_channels;
@@ -838,7 +838,7 @@
     SCOPED_TRACE(ss.str());  // Print out the parameter values on failure.
     EXPECT_EQ(0, out_data_[i]);
   }
-  for (int i = kExpectedOutputLength; i < kMaxBlockSize; ++i) {
+  for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) {
     std::ostringstream ss;
     ss << "i = " << i;
     SCOPED_TRACE(ss.str());  // Print out the parameter values on failure.
@@ -850,7 +850,7 @@
   NetEqOutputType type;
   // Set all of |out_data_| to 1, and verify that it was set to 0 by the call
   // to GetAudio.
-  for (int i = 0; i < kMaxBlockSize; ++i) {
+  for (size_t i = 0; i < kMaxBlockSize; ++i) {
     out_data_[i] = 1;
   }
   int num_channels;
@@ -875,7 +875,7 @@
                              bool should_be_faded) = 0;
 
   void CheckBgn(int sampling_rate_hz) {
-    int expected_samples_per_channel = 0;
+    int16_t expected_samples_per_channel = 0;
     uint8_t payload_type = 0xFF;  // Invalid.
     if (sampling_rate_hz == 8000) {
       expected_samples_per_channel = kBlockSize8kHz;
@@ -899,7 +899,7 @@
     ASSERT_TRUE(input.Init(
         webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
         10 * sampling_rate_hz,  // Max 10 seconds loop length.
-        expected_samples_per_channel));
+        static_cast<size_t>(expected_samples_per_channel)));
 
     // Payload of 10 ms of PCM16 32 kHz.
     uint8_t payload[kBlockSize32kHz * sizeof(int16_t)];
@@ -912,7 +912,7 @@
 
     uint32_t receive_timestamp = 0;
     for (int n = 0; n < 10; ++n) {  // Insert few packets and get audio.
-      int enc_len_bytes =
+      int16_t enc_len_bytes =
           WebRtcPcm16b_EncodeW16(input.GetNextBlock(),
                                  expected_samples_per_channel,
                                  reinterpret_cast<int16_t*>(payload));
@@ -921,8 +921,9 @@
       number_channels = 0;
       samples_per_channel = 0;
       ASSERT_EQ(0,
-                neteq_->InsertPacket(
-                    rtp_info, payload, enc_len_bytes, receive_timestamp));
+                neteq_->InsertPacket(rtp_info, payload,
+                                     static_cast<size_t>(enc_len_bytes),
+                                     receive_timestamp));
       ASSERT_EQ(0,
                 neteq_->GetAudio(kBlockSize32kHz,
                                  output,
@@ -1074,7 +1075,7 @@
   EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
 
   // Payload length of 10 ms PCM16 16 kHz.
-  const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
+  const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
   uint8_t payload[kPayloadBytes] = {0};
   ASSERT_EQ(0, neteq_->InsertPacket(
       rtp_info, payload, kPayloadBytes, receive_timestamp));
@@ -1125,11 +1126,11 @@
 TEST_F(NetEqDecodingTest, SyncPacketDecode) {
   WebRtcRTPHeader rtp_info;
   PopulateRtpInfo(0, 0, &rtp_info);
-  const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
+  const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
   uint8_t payload[kPayloadBytes];
   int16_t decoded[kBlockSize16kHz];
   int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1;
-  for (int n = 0; n < kPayloadBytes; ++n) {
+  for (size_t n = 0; n < kPayloadBytes; ++n) {
     payload[n] = (rand() & 0xF0) + 1;  // Non-zero random sequence.
   }
   // Insert some packets which decode to noise. We are not interested in
@@ -1204,10 +1205,10 @@
 TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) {
   WebRtcRTPHeader rtp_info;
   PopulateRtpInfo(0, 0, &rtp_info);
-  const int kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
+  const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
   uint8_t payload[kPayloadBytes];
   int16_t decoded[kBlockSize16kHz];
-  for (int n = 0; n < kPayloadBytes; ++n) {
+  for (size_t n = 0; n < kPayloadBytes; ++n) {
     payload[n] = (rand() & 0xF0) + 1;  // Non-zero random sequence.
   }
   // Insert some packets which decode to noise. We are not interested in
@@ -1279,7 +1280,7 @@
   const int kBlocksPerFrame = 3;  // Number of 10 ms blocks per frame.
   const int kFrameSizeMs = kBlocksPerFrame * kTimeStepMs;
   const int kSamples = kBlockSize16kHz * kBlocksPerFrame;
-  const int kPayloadBytes = kSamples * sizeof(int16_t);
+  const size_t kPayloadBytes = kSamples * sizeof(int16_t);
   double next_input_time_ms = 0.0;
   int16_t decoded[kBlockSize16kHz];
   int num_channels;
@@ -1380,7 +1381,7 @@
   const int kFrameSizeMs = 10;
   const int kSampleRateKhz = 16;
   const int kSamples = kFrameSizeMs * kSampleRateKhz;
-  const int kPayloadBytes = kSamples * 2;
+  const size_t kPayloadBytes = kSamples * 2;
 
   const int algorithmic_delay_samples = std::max(
       algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8);
@@ -1409,7 +1410,7 @@
   // Insert same CNG packet twice.
   const int kCngPeriodMs = 100;
   const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz;
-  int payload_len;
+  size_t payload_len;
   PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
   // This is the first time this CNG packet is inserted.
   ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
diff --git a/webrtc/modules/audio_coding/neteq/packet.h b/webrtc/modules/audio_coding/neteq/packet.h
index 89ddda7..723ed8b 100644
--- a/webrtc/modules/audio_coding/neteq/packet.h
+++ b/webrtc/modules/audio_coding/neteq/packet.h
@@ -22,7 +22,7 @@
 struct Packet {
   RTPHeader header;
   uint8_t* payload;  // Datagram excluding RTP header and header extension.
-  int payload_length;
+  size_t payload_length;
   bool primary;  // Primary, i.e., not redundant payload.
   int waiting_time;
   bool sync_packet;
diff --git a/webrtc/modules/audio_coding/neteq/payload_splitter.cc b/webrtc/modules/audio_coding/neteq/payload_splitter.cc
index 1d61ef0..118556b 100644
--- a/webrtc/modules/audio_coding/neteq/payload_splitter.cc
+++ b/webrtc/modules/audio_coding/neteq/payload_splitter.cc
@@ -46,7 +46,7 @@
     //   +-+-+-+-+-+-+-+-+
 
     bool last_block = false;
-    int sum_length = 0;
+    size_t sum_length = 0;
     while (!last_block) {
       Packet* new_packet = new Packet;
       new_packet->header = red_packet->header;
@@ -82,7 +82,7 @@
     // |payload_ptr| now points at the first payload byte.
     PacketList::iterator new_it;
     for (new_it = new_packets.begin(); new_it != new_packets.end(); ++new_it) {
-      int payload_length = (*new_it)->payload_length;
+      size_t payload_length = (*new_it)->payload_length;
       if (payload_ptr + payload_length >
           red_packet->payload + red_packet->payload_length) {
         // The block lengths in the RED headers do not match the overall packet
@@ -291,11 +291,12 @@
         break;
       }
       case kDecoderILBC: {
-        int bytes_per_frame;
+        size_t bytes_per_frame;
         int timestamps_per_frame;
         if (packet->payload_length >= 950) {
           return kTooLargePayload;
-        } else if (packet->payload_length % 38 == 0) {
+        }
+        if (packet->payload_length % 38 == 0) {
           // 20 ms frames.
           bytes_per_frame = 38;
           timestamps_per_frame = 160;
@@ -345,28 +346,28 @@
 }
 
 void PayloadSplitter::SplitBySamples(const Packet* packet,
-                                     int bytes_per_ms,
-                                     int timestamps_per_ms,
+                                     size_t bytes_per_ms,
+                                     uint32_t timestamps_per_ms,
                                      PacketList* new_packets) {
   assert(packet);
   assert(new_packets);
 
-  int split_size_bytes = packet->payload_length;
+  size_t split_size_bytes = packet->payload_length;
 
   // Find a "chunk size" >= 20 ms and < 40 ms.
-  int min_chunk_size = bytes_per_ms * 20;
+  size_t min_chunk_size = bytes_per_ms * 20;
   // Reduce the split size by half as long as |split_size_bytes| is at least
   // twice the minimum chunk size (so that the resulting size is at least as
   // large as the minimum chunk size).
   while (split_size_bytes >= 2 * min_chunk_size) {
     split_size_bytes >>= 1;
   }
-  int timestamps_per_chunk =
-      split_size_bytes * timestamps_per_ms / bytes_per_ms;
+  uint32_t timestamps_per_chunk = static_cast<uint32_t>(
+      split_size_bytes * timestamps_per_ms / bytes_per_ms);
   uint32_t timestamp = packet->header.timestamp;
 
   uint8_t* payload_ptr = packet->payload;
-  int len = packet->payload_length;
+  size_t len = packet->payload_length;
   while (len >= (2 * split_size_bytes)) {
     Packet* new_packet = new Packet;
     new_packet->payload_length = split_size_bytes;
@@ -394,22 +395,21 @@
 }
 
 int PayloadSplitter::SplitByFrames(const Packet* packet,
-                                   int bytes_per_frame,
-                                   int timestamps_per_frame,
+                                   size_t bytes_per_frame,
+                                   uint32_t timestamps_per_frame,
                                    PacketList* new_packets) {
   if (packet->payload_length % bytes_per_frame != 0) {
     return kFrameSplitError;
   }
 
-  int num_frames = packet->payload_length / bytes_per_frame;
-  if (num_frames == 1) {
+  if (packet->payload_length == bytes_per_frame) {
     // Special case. Do not split the payload.
     return kNoSplit;
   }
 
   uint32_t timestamp = packet->header.timestamp;
   uint8_t* payload_ptr = packet->payload;
-  int len = packet->payload_length;
+  size_t len = packet->payload_length;
   while (len > 0) {
     assert(len >= bytes_per_frame);
     Packet* new_packet = new Packet;
diff --git a/webrtc/modules/audio_coding/neteq/payload_splitter.h b/webrtc/modules/audio_coding/neteq/payload_splitter.h
index a3dd77e..6023d4e 100644
--- a/webrtc/modules/audio_coding/neteq/payload_splitter.h
+++ b/webrtc/modules/audio_coding/neteq/payload_splitter.h
@@ -71,16 +71,16 @@
   // Splits the payload in |packet|. The payload is assumed to be from a
   // sample-based codec.
   virtual void SplitBySamples(const Packet* packet,
-                              int bytes_per_ms,
-                              int timestamps_per_ms,
+                              size_t bytes_per_ms,
+                              uint32_t timestamps_per_ms,
                               PacketList* new_packets);
 
   // Splits the payload in |packet|. The payload will be split into chunks of
   // size |bytes_per_frame|, corresponding to a |timestamps_per_frame|
   // RTP timestamps.
   virtual int SplitByFrames(const Packet* packet,
-                            int bytes_per_frame,
-                            int timestamps_per_frame,
+                            size_t bytes_per_frame,
+                            uint32_t timestamps_per_frame,
                             PacketList* new_packets);
 
   DISALLOW_COPY_AND_ASSIGN(PayloadSplitter);
diff --git a/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc b/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc
index cf29581..d397a07 100644
--- a/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/payload_splitter_unittest.cc
@@ -27,8 +27,8 @@
 namespace webrtc {
 
 static const int kRedPayloadType = 100;
-static const int kPayloadLength = 10;
-static const int kRedHeaderLength = 4;  // 4 bytes RED header.
+static const size_t kPayloadLength = 10;
+static const size_t kRedHeaderLength = 4;  // 4 bytes RED header.
 static const uint16_t kSequenceNumber = 0;
 static const uint32_t kBaseTimestamp = 0x12345678;
 
@@ -50,7 +50,7 @@
 // by the values in array |payload_types| (which must be of length
 // |num_payloads|). Each redundant payload is |timestamp_offset| samples
 // "behind" the the previous payload.
-Packet* CreateRedPayload(int num_payloads,
+Packet* CreateRedPayload(size_t num_payloads,
                          uint8_t* payload_types,
                          int timestamp_offset) {
   Packet* packet = new Packet;
@@ -61,7 +61,7 @@
       (num_payloads - 1) * (kPayloadLength + kRedHeaderLength);
   uint8_t* payload = new uint8_t[packet->payload_length];
   uint8_t* payload_ptr = payload;
-  for (int i = 0; i < num_payloads; ++i) {
+  for (size_t i = 0; i < num_payloads; ++i) {
     // Write the RED headers.
     if (i == num_payloads - 1) {
       // Special case for last payload.
@@ -82,9 +82,9 @@
     *payload_ptr = kPayloadLength & 0xFF;
     ++payload_ptr;
   }
-  for (int i = 0; i < num_payloads; ++i) {
+  for (size_t i = 0; i < num_payloads; ++i) {
     // Write |i| to all bytes in each payload.
-    memset(payload_ptr, i, kPayloadLength);
+    memset(payload_ptr, static_cast<int>(i), kPayloadLength);
     payload_ptr += kPayloadLength;
   }
   packet->payload = payload;
@@ -104,7 +104,7 @@
 // :                                                               |
 // |                                                               |
 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-Packet* CreateOpusFecPacket(uint8_t payload_type, int payload_length,
+Packet* CreateOpusFecPacket(uint8_t payload_type, size_t payload_length,
                             uint8_t payload_value) {
   Packet* packet = new Packet;
   packet->header.payloadType = payload_type;
@@ -120,7 +120,7 @@
 }
 
 // Create a packet with all payload bytes set to |payload_value|.
-Packet* CreatePacket(uint8_t payload_type, int payload_length,
+Packet* CreatePacket(uint8_t payload_type, size_t payload_length,
                      uint8_t payload_value) {
   Packet* packet = new Packet;
   packet->header.payloadType = payload_type;
@@ -135,7 +135,7 @@
 
 // Checks that |packet| has the attributes given in the remaining parameters.
 void VerifyPacket(const Packet* packet,
-                  int payload_length,
+                  size_t payload_length,
                   uint8_t payload_type,
                   uint16_t sequence_number,
                   uint32_t timestamp,
@@ -147,7 +147,7 @@
   EXPECT_EQ(timestamp, packet->header.timestamp);
   EXPECT_EQ(primary, packet->primary);
   ASSERT_FALSE(packet->payload == NULL);
-  for (int i = 0; i < packet->payload_length; ++i) {
+  for (size_t i = 0; i < packet->payload_length; ++i) {
     EXPECT_EQ(payload_value, packet->payload[i]);
   }
 }
@@ -295,7 +295,7 @@
 // found in the list (which is PCMu).
 TEST(RedPayloadSplitter, CheckRedPayloads) {
   PacketList packet_list;
-  for (int i = 0; i <= 3; ++i) {
+  for (uint8_t i = 0; i <= 3; ++i) {
     // Create packet with payload type |i|, payload length 10 bytes, all 0.
     Packet* packet = CreatePacket(i, 10, 0);
     packet_list.push_back(packet);
@@ -357,7 +357,7 @@
   // Set up packets with different RTP payload types. The actual values do not
   // matter, since we are mocking the decoder database anyway.
   PacketList packet_list;
-  for (int i = 0; i < 6; ++i) {
+  for (uint8_t i = 0; i < 6; ++i) {
     // Let the payload type be |i|, and the payload value 10 * |i|.
     packet_list.push_back(CreatePacket(i, kPayloadLength, 10 * i));
   }
@@ -415,7 +415,7 @@
 TEST(AudioPayloadSplitter, UnknownPayloadType) {
   PacketList packet_list;
   static const uint8_t kPayloadType = 17;  // Just a random number.
-  int kPayloadLengthBytes = 4711;  // Random number.
+  size_t kPayloadLengthBytes = 4711;  // Random number.
   packet_list.push_back(CreatePacket(kPayloadType, kPayloadLengthBytes, 0));
 
   MockDecoderDatabase decoder_database;
@@ -502,7 +502,7 @@
         break;
     }
   }
-  int bytes_per_ms_;
+  size_t bytes_per_ms_;
   int samples_per_ms_;
   NetEqDecoder decoder_type_;
 };
@@ -514,7 +514,7 @@
   for (int payload_size_ms = 10; payload_size_ms <= 60; payload_size_ms += 10) {
     // The payload values are set to be the same as the payload_size, so that
     // one can distinguish from which packet the split payloads come from.
-    int payload_size_bytes = payload_size_ms * bytes_per_ms_;
+    size_t payload_size_bytes = payload_size_ms * bytes_per_ms_;
     packet_list.push_back(CreatePacket(kPayloadType, payload_size_bytes,
                                        payload_size_ms));
   }
@@ -548,7 +548,7 @@
   PacketList::iterator it = packet_list.begin();
   int i = 0;
   while (it != packet_list.end()) {
-    int length_bytes = expected_size_ms[i] * bytes_per_ms_;
+    size_t length_bytes = expected_size_ms[i] * bytes_per_ms_;
     uint32_t expected_timestamp = kBaseTimestamp +
         expected_timestamp_offset_ms[i] * samples_per_ms_;
     VerifyPacket((*it), length_bytes, kPayloadType, kSequenceNumber,
@@ -583,7 +583,7 @@
   }
   size_t num_frames_;
   int frame_length_ms_;
-  int frame_length_bytes_;
+  size_t frame_length_bytes_;
 };
 
 // Test splitting sample-based payloads.
@@ -591,10 +591,10 @@
   PacketList packet_list;
   static const uint8_t kPayloadType = 17;  // Just a random number.
   const int frame_length_samples = frame_length_ms_ * 8;
-  int payload_length_bytes = frame_length_bytes_ * num_frames_;
+  size_t payload_length_bytes = frame_length_bytes_ * num_frames_;
   Packet* packet = CreatePacket(kPayloadType, payload_length_bytes, 0);
   // Fill payload with increasing integers {0, 1, 2, ...}.
-  for (int i = 0; i < packet->payload_length; ++i) {
+  for (size_t i = 0; i < packet->payload_length; ++i) {
     packet->payload[i] = static_cast<uint8_t>(i);
   }
   packet_list.push_back(packet);
@@ -624,7 +624,7 @@
     EXPECT_EQ(kSequenceNumber, packet->header.sequenceNumber);
     EXPECT_EQ(true, packet->primary);
     ASSERT_FALSE(packet->payload == NULL);
-    for (int i = 0; i < packet->payload_length; ++i) {
+    for (size_t i = 0; i < packet->payload_length; ++i) {
       EXPECT_EQ(payload_value, packet->payload[i]);
       ++payload_value;
     }
@@ -661,7 +661,7 @@
 TEST(IlbcPayloadSplitter, TooLargePayload) {
   PacketList packet_list;
   static const uint8_t kPayloadType = 17;  // Just a random number.
-  int kPayloadLengthBytes = 950;
+  size_t kPayloadLengthBytes = 950;
   Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0);
   packet_list.push_back(packet);
 
@@ -692,7 +692,7 @@
 TEST(IlbcPayloadSplitter, UnevenPayload) {
   PacketList packet_list;
   static const uint8_t kPayloadType = 17;  // Just a random number.
-  int kPayloadLengthBytes = 39;  // Not an even number of frames.
+  size_t kPayloadLengthBytes = 39;  // Not an even number of frames.
   Packet* packet = CreatePacket(kPayloadType, kPayloadLengthBytes, 0);
   packet_list.push_back(packet);
 
@@ -744,7 +744,7 @@
   packet = packet_list.front();
   EXPECT_EQ(0, packet->header.payloadType);
   EXPECT_EQ(kBaseTimestamp - 20 * 48, packet->header.timestamp);
-  EXPECT_EQ(10, packet->payload_length);
+  EXPECT_EQ(10U, packet->payload_length);
   EXPECT_FALSE(packet->primary);
   delete [] packet->payload;
   delete packet;
@@ -754,7 +754,7 @@
   packet = packet_list.front();
   EXPECT_EQ(0, packet->header.payloadType);
   EXPECT_EQ(kBaseTimestamp, packet->header.timestamp);
-  EXPECT_EQ(10, packet->payload_length);
+  EXPECT_EQ(10U, packet->payload_length);
   EXPECT_TRUE(packet->primary);
   delete [] packet->payload;
   delete packet;
diff --git a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc
index 7f94851..d4c2191 100644
--- a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc
+++ b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.cc
@@ -329,7 +329,7 @@
     }
 }
 
-int16_t NETEQTEST_RTPpacket::payloadLen()
+size_t NETEQTEST_RTPpacket::payloadLen()
 {
     parseHeader();
     return _payloadLen;
@@ -752,7 +752,7 @@
                                             int stride)
 {
     if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
-        || _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
+        || _payloadLen == 0 || slaveRtp->_memSize < _memSize)
     {
         return;
     }
@@ -761,7 +761,7 @@
     uint8_t *writeDataPtr = _payloadPtr;
     uint8_t *slaveData = slaveRtp->_payloadPtr;
 
-    while (readDataPtr - _payloadPtr < _payloadLen)
+    while (readDataPtr - _payloadPtr < static_cast<ptrdiff_t>(_payloadLen))
     {
         // master data
         for (int ix = 0; ix < stride; ix++) {
@@ -786,7 +786,7 @@
 void NETEQTEST_RTPpacket::splitStereoFrame(NETEQTEST_RTPpacket* slaveRtp)
 {
     if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
-        || _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
+        || _payloadLen == 0 || slaveRtp->_memSize < _memSize)
     {
         return;
     }
@@ -799,7 +799,7 @@
 void NETEQTEST_RTPpacket::splitStereoDouble(NETEQTEST_RTPpacket* slaveRtp)
 {
     if(!_payloadPtr || !slaveRtp || !slaveRtp->_payloadPtr
-        || _payloadLen <= 0 || slaveRtp->_memSize < _memSize)
+        || _payloadLen == 0 || slaveRtp->_memSize < _memSize)
     {
         return;
     }
@@ -868,7 +868,7 @@
 {
     parseHeader();
 
-    for (int i = 0; i < _payloadLen; ++i)
+    for (size_t i = 0; i < _payloadLen; ++i)
     {
         _payloadPtr[i] = static_cast<uint8_t>(rand());
     }
diff --git a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h
index 8a31274..86bf3b0 100644
--- a/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h
+++ b/webrtc/modules/audio_coding/neteq/test/NETEQTEST_RTPpacket.h
@@ -42,7 +42,7 @@
     const webrtc::WebRtcRTPHeader* RTPinfo() const;
     uint8_t * datagram() const;
     uint8_t * payload() const;
-    int16_t payloadLen();
+    size_t payloadLen();
     int16_t dataLen() const;
     bool isParsed() const;
     bool isLost() const;
@@ -73,7 +73,7 @@
     uint8_t *       _payloadPtr;
     int                 _memSize;
     int16_t         _datagramLen;
-    int16_t         _payloadLen;
+    size_t          _payloadLen;
     webrtc::WebRtcRTPHeader _rtpInfo;
     bool                _rtpParsed;
     uint32_t        _receiveTime;
diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc
index 433546f..ebe0784 100644
--- a/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc
+++ b/webrtc/modules/audio_coding/neteq/tools/neteq_performance_test.cc
@@ -64,9 +64,9 @@
   const int16_t* input_samples = audio_loop.GetNextBlock();
   if (!input_samples) exit(1);
   uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)];
-  int payload_len = WebRtcPcm16b_Encode(const_cast<int16_t*>(input_samples),
-                                        kInputBlockSizeSamples,
-                                        input_payload);
+  size_t payload_len = WebRtcPcm16b_Encode(const_cast<int16_t*>(input_samples),
+                                           kInputBlockSizeSamples,
+                                           input_payload);
   assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t));
 
   // Main loop.
diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h
index e0a43b6..00a2499 100644
--- a/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h
+++ b/webrtc/modules/audio_coding/neteq/tools/neteq_quality_test.h
@@ -118,7 +118,7 @@
   // Expected output number of samples per channel in a frame.
   const int out_size_samples_;
 
-  int payload_size_bytes_;
+  size_t payload_size_bytes_;
   int max_payload_bytes_;
 
   scoped_ptr<InputAudioFile> in_file_;
@@ -134,7 +134,7 @@
   scoped_ptr<int16_t[]> out_data_;
   WebRtcRTPHeader rtp_header_;
 
-  long total_payload_size_bytes_;
+  size_t total_payload_size_bytes_;
 };
 
 }  // namespace test
diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
index ef2c0b6..4247807 100644
--- a/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
+++ b/webrtc/modules/audio_coding/neteq/tools/neteq_rtpplay.cc
@@ -286,7 +286,7 @@
       int error =
           neteq->InsertPacket(rtp_header,
                               payload_ptr,
-                              static_cast<int>(payload_len),
+                              payload_len,
                               packet->time_ms() * sample_rate_hz / 1000);
       if (error != NetEq::kOK) {
         if (neteq->LastError() == NetEq::kUnknownRtpPayloadType) {
diff --git a/webrtc/modules/interface/module_common_types.h b/webrtc/modules/interface/module_common_types.h
index 60bb7ab..fea76ce 100644
--- a/webrtc/modules/interface/module_common_types.h
+++ b/webrtc/modules/interface/module_common_types.h
@@ -136,10 +136,10 @@
       if (src.fragmentationVectorSize > 0) {
         // allocate new
         if (src.fragmentationOffset) {
-          fragmentationOffset = new uint32_t[src.fragmentationVectorSize];
+          fragmentationOffset = new size_t[src.fragmentationVectorSize];
         }
         if (src.fragmentationLength) {
-          fragmentationLength = new uint32_t[src.fragmentationVectorSize];
+          fragmentationLength = new size_t[src.fragmentationVectorSize];
         }
         if (src.fragmentationTimeDiff) {
           fragmentationTimeDiff = new uint16_t[src.fragmentationVectorSize];
@@ -156,11 +156,11 @@
       // copy values
       if (src.fragmentationOffset) {
         memcpy(fragmentationOffset, src.fragmentationOffset,
-               src.fragmentationVectorSize * sizeof(uint32_t));
+               src.fragmentationVectorSize * sizeof(size_t));
       }
       if (src.fragmentationLength) {
         memcpy(fragmentationLength, src.fragmentationLength,
-               src.fragmentationVectorSize * sizeof(uint32_t));
+               src.fragmentationVectorSize * sizeof(size_t));
       }
       if (src.fragmentationTimeDiff) {
         memcpy(fragmentationTimeDiff, src.fragmentationTimeDiff,
@@ -178,23 +178,23 @@
       uint16_t oldVectorSize = fragmentationVectorSize;
       {
         // offset
-        uint32_t* oldOffsets = fragmentationOffset;
-        fragmentationOffset = new uint32_t[size];
+        size_t* oldOffsets = fragmentationOffset;
+        fragmentationOffset = new size_t[size];
         memset(fragmentationOffset + oldVectorSize, 0,
-               sizeof(uint32_t) * (size - oldVectorSize));
+               sizeof(size_t) * (size - oldVectorSize));
         // copy old values
         memcpy(fragmentationOffset, oldOffsets,
-               sizeof(uint32_t) * oldVectorSize);
+               sizeof(size_t) * oldVectorSize);
         delete[] oldOffsets;
       }
       // length
       {
-        uint32_t* oldLengths = fragmentationLength;
-        fragmentationLength = new uint32_t[size];
+        size_t* oldLengths = fragmentationLength;
+        fragmentationLength = new size_t[size];
         memset(fragmentationLength + oldVectorSize, 0,
-               sizeof(uint32_t) * (size - oldVectorSize));
+               sizeof(size_t) * (size - oldVectorSize));
         memcpy(fragmentationLength, oldLengths,
-               sizeof(uint32_t) * oldVectorSize);
+               sizeof(size_t) * oldVectorSize);
         delete[] oldLengths;
       }
       // time diff
@@ -222,11 +222,12 @@
   }
 
   uint16_t fragmentationVectorSize;  // Number of fragmentations
-  uint32_t* fragmentationOffset;    // Offset of pointer to data for each fragm.
-  uint32_t* fragmentationLength;    // Data size for each fragmentation
-  uint16_t* fragmentationTimeDiff;  // Timestamp difference relative "now" for
-                                    // each fragmentation
-  uint8_t* fragmentationPlType;     // Payload type of each fragmentation
+  size_t* fragmentationOffset;       // Offset of pointer to data for each
+                                     // fragmentation
+  size_t* fragmentationLength;       // Data size for each fragmentation
+  uint16_t* fragmentationTimeDiff;   // Timestamp difference relative "now" for
+                                     // each fragmentation
+  uint8_t* fragmentationPlType;      // Payload type of each fragmentation
 
  private:
   DISALLOW_COPY_AND_ASSIGN(RTPFragmentationHeader);
@@ -348,7 +349,7 @@
     }
     return *this;
   };
-  void VerifyAndAllocate(const uint32_t size) {
+  void VerifyAndAllocate(const size_t size) {
     if (bufferSize < size) {
       uint8_t* oldPayload = payloadData;
       payloadData = new uint8_t[size];
@@ -367,8 +368,8 @@
   bool completeFrame;
   bool missingFrame;
   uint8_t* payloadData;
-  uint32_t payloadSize;
-  uint32_t bufferSize;
+  size_t payloadSize;
+  size_t bufferSize;
   RTPFragmentationHeader fragmentationHeader;
   FrameType frameType;
   VideoCodecType codec;
@@ -414,17 +415,17 @@
   * is copied to the new buffer.
   * Buffer size is updated to minimumSize.
   */
-  int32_t VerifyAndAllocate(const uint32_t minimumSize);
+  int32_t VerifyAndAllocate(const size_t minimumSize);
   /**
   *    Update length of data buffer in frame. Function verifies that new length
   * is less or
   *    equal to allocated size.
   */
-  int32_t SetLength(const uint32_t newLength);
+  int32_t SetLength(const size_t newLength);
   /*
   *    Swap buffer and size data
   */
-  int32_t Swap(uint8_t*& newMemory, uint32_t& newLength, uint32_t& newSize);
+  int32_t Swap(uint8_t*& newMemory, size_t& newLength, size_t& newSize);
   /*
   *    Swap buffer and size data
   */
@@ -440,7 +441,7 @@
   * size length
   *    is allocated.
   */
-  int32_t CopyFrame(uint32_t length, const uint8_t* sourceBuffer);
+  int32_t CopyFrame(size_t length, const uint8_t* sourceBuffer);
   /**
   *    Delete VideoFrame and resets members to zero
   */
@@ -459,11 +460,11 @@
   /**
   *   Get allocated buffer size
   */
-  uint32_t Size() const { return _bufferSize; }
+  size_t Size() const { return _bufferSize; }
   /**
   *   Get frame length
   */
-  uint32_t Length() const { return _bufferLength; }
+  size_t Length() const { return _bufferLength; }
   /**
   *   Get frame timestamp (90kHz)
   */
@@ -498,10 +499,10 @@
  private:
   void Set(uint8_t* buffer, uint32_t size, uint32_t length, uint32_t timeStamp);
 
-  uint8_t* _buffer;        // Pointer to frame buffer
-  uint32_t _bufferSize;    // Allocated buffer size
-  uint32_t _bufferLength;  // Length (in bytes) of buffer
-  uint32_t _timeStamp;     // Timestamp of frame (90kHz)
+  uint8_t* _buffer;      // Pointer to frame buffer
+  size_t _bufferSize;    // Allocated buffer size
+  size_t _bufferLength;  // Length (in bytes) of buffer
+  uint32_t _timeStamp;   // Timestamp of frame (90kHz)
   uint32_t _width;
   uint32_t _height;
   int64_t _renderTimeMs;
@@ -525,7 +526,7 @@
   }
 }
 
-inline int32_t VideoFrame::VerifyAndAllocate(const uint32_t minimumSize) {
+inline int32_t VideoFrame::VerifyAndAllocate(const size_t minimumSize) {
   if (minimumSize < 1) {
     return -1;
   }
@@ -545,7 +546,7 @@
   return 0;
 }
 
-inline int32_t VideoFrame::SetLength(const uint32_t newLength) {
+inline int32_t VideoFrame::SetLength(const size_t newLength) {
   if (newLength > _bufferSize) {  // can't accomodate new value
     return -1;
   }
@@ -573,21 +574,15 @@
               videoFrame._bufferSize);
 }
 
-inline int32_t VideoFrame::Swap(uint8_t*& newMemory, uint32_t& newLength,
-                                uint32_t& newSize) {
-  uint8_t* tmpBuffer = _buffer;
-  uint32_t tmpLength = _bufferLength;
-  uint32_t tmpSize = _bufferSize;
-  _buffer = newMemory;
-  _bufferLength = newLength;
-  _bufferSize = newSize;
-  newMemory = tmpBuffer;
-  newLength = tmpLength;
-  newSize = tmpSize;
+inline int32_t VideoFrame::Swap(uint8_t*& newMemory, size_t& newLength,
+                                size_t& newSize) {
+  std::swap(_buffer, newMemory);
+  std::swap(_bufferLength, newLength);
+  std::swap(_bufferSize, newSize);
   return 0;
 }
 
-inline int32_t VideoFrame::CopyFrame(uint32_t length,
+inline int32_t VideoFrame::CopyFrame(size_t length,
                                      const uint8_t* sourceBuffer) {
   if (length > _bufferSize) {
     int32_t ret = VerifyAndAllocate(length);
diff --git a/webrtc/modules/media_file/interface/media_file.h b/webrtc/modules/media_file/interface/media_file.h
index 5413b44..3fb849f 100644
--- a/webrtc/modules/media_file/interface/media_file.h
+++ b/webrtc/modules/media_file/interface/media_file.h
@@ -39,7 +39,7 @@
     // mono).
     virtual int32_t PlayoutAudioData(
         int8_t* audioBuffer,
-        uint32_t& dataLengthInBytes) = 0;
+        size_t& dataLengthInBytes) = 0;
 
     // Put one video frame into videoBuffer. dataLengthInBytes is both an input
     // and output parameter. As input parameter it indicates the size of
@@ -47,7 +47,7 @@
     // to videoBuffer.
     virtual int32_t PlayoutAVIVideoData(
         int8_t* videoBuffer,
-        uint32_t& dataLengthInBytes) = 0;
+        size_t& dataLengthInBytes) = 0;
 
     // Put 10-60ms, depending on codec frame size, of audio data from file into
     // audioBufferLeft and audioBufferRight. The buffers contain the left and
@@ -61,7 +61,7 @@
     virtual int32_t PlayoutStereoData(
         int8_t* audioBufferLeft,
         int8_t* audioBufferRight,
-        uint32_t& dataLengthInBytes) = 0;
+        size_t& dataLengthInBytes) = 0;
 
     // Open the file specified by fileName (relative path is allowed) for
     // reading. FileCallback::PlayNotification(..) will be called after
@@ -130,8 +130,8 @@
     // parameter of the last sucessfull StartRecordingAudioFile(..) call.
     // Note: bufferLength must be exactly one frame.
     virtual int32_t IncomingAudioData(
-        const int8_t*  audioBuffer,
-        const uint32_t bufferLength) = 0;
+        const int8_t* audioBuffer,
+        const size_t bufferLength) = 0;
 
     // Write one video frame, i.e. the bufferLength first bytes of videoBuffer,
     // to file.
@@ -140,8 +140,8 @@
     // StartRecordingVideoFile(..) call. The videoBuffer must contain exactly
     // one video frame.
     virtual int32_t IncomingAVIVideoData(
-        const int8_t*  videoBuffer,
-        const uint32_t bufferLength) = 0;
+        const int8_t* videoBuffer,
+        const size_t bufferLength) = 0;
 
     // Open/creates file specified by fileName for writing (relative path is
     // allowed). FileCallback::RecordNotification(..) will be called after
diff --git a/webrtc/modules/media_file/source/avi_file.cc b/webrtc/modules/media_file/source/avi_file.cc
index 19baaa3..0d0fefd 100644
--- a/webrtc/modules/media_file/source/avi_file.cc
+++ b/webrtc/modules/media_file/source/avi_file.cc
@@ -360,7 +360,7 @@
     return 0;
 }
 
-int32_t AviFile::WriteAudio(const uint8_t* data, int32_t length)
+int32_t AviFile::WriteAudio(const uint8_t* data, size_t length)
 {
     _crit->Enter();
     size_t newBytesWritten = _bytesWritten;
@@ -410,7 +410,7 @@
     return static_cast<int32_t>(newBytesWritten);
 }
 
-int32_t AviFile::WriteVideo(const uint8_t* data, int32_t length)
+int32_t AviFile::WriteVideo(const uint8_t* data, size_t length)
 {
     _crit->Enter();
     size_t newBytesWritten = _bytesWritten;
@@ -482,7 +482,7 @@
     return 0;
 }
 
-int32_t AviFile::ReadMoviSubChunk(uint8_t* data, int32_t& length, uint32_t tag1,
+int32_t AviFile::ReadMoviSubChunk(uint8_t* data, size_t& length, uint32_t tag1,
                                   uint32_t tag2)
 {
     if (!_reading)
@@ -563,7 +563,7 @@
         _bytesRead += size;
     }
 
-    if (static_cast<int32_t>(size) > length)
+    if (size > length)
     {
         WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1,
                      "AviFile::ReadMoviSubChunk(): AVI read buffer too small!");
@@ -589,7 +589,7 @@
     return 0;
 }
 
-int32_t AviFile::ReadAudio(uint8_t* data, int32_t& length)
+int32_t AviFile::ReadAudio(uint8_t* data, size_t& length)
 {
     _crit->Enter();
     WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1,  "AviFile::ReadAudio()");
@@ -616,7 +616,7 @@
     return ret;
 }
 
-int32_t AviFile::ReadVideo(uint8_t* data, int32_t& length)
+int32_t AviFile::ReadVideo(uint8_t* data, size_t& length)
 {
     WEBRTC_TRACE(kTraceDebug, kTraceVideo, -1, "AviFile::ReadVideo()");
 
diff --git a/webrtc/modules/media_file/source/avi_file.h b/webrtc/modules/media_file/source/avi_file.h
index d8b1062..1b5b746 100644
--- a/webrtc/modules/media_file/source/avi_file.h
+++ b/webrtc/modules/media_file/source/avi_file.h
@@ -104,8 +104,8 @@
                               const WAVEFORMATEX& waveFormatHeader);
     int32_t Create(const char* fileName);
 
-    int32_t WriteAudio(const uint8_t* data, int32_t length);
-    int32_t WriteVideo(const uint8_t* data, int32_t length);
+    int32_t WriteAudio(const uint8_t* data, size_t length);
+    int32_t WriteVideo(const uint8_t* data, size_t length);
 
     int32_t GetVideoStreamInfo(AVISTREAMHEADER& videoStreamHeader,
                                BITMAPINFOHEADER& bitmapInfo,
@@ -116,8 +116,8 @@
 
     int32_t GetAudioStreamInfo(WAVEFORMATEX& waveHeader);
 
-    int32_t ReadAudio(uint8_t* data, int32_t& length);
-    int32_t ReadVideo(uint8_t* data, int32_t& length);
+    int32_t ReadAudio(uint8_t* data, size_t& length);
+    int32_t ReadVideo(uint8_t* data, size_t& length);
 
     int32_t Close();
 
@@ -145,7 +145,7 @@
 
     int32_t PrepareDataChunkHeaders();
 
-    int32_t ReadMoviSubChunk(uint8_t* data, int32_t& length, uint32_t tag1,
+    int32_t ReadMoviSubChunk(uint8_t* data, size_t& length, uint32_t tag1,
                              uint32_t tag2 = 0);
 
     int32_t WriteRIFF();
diff --git a/webrtc/modules/media_file/source/media_file_impl.cc b/webrtc/modules/media_file/source/media_file_impl.cc
index e832791..06df171 100644
--- a/webrtc/modules/media_file/source/media_file_impl.cc
+++ b/webrtc/modules/media_file/source/media_file_impl.cc
@@ -10,6 +10,7 @@
 
 #include <assert.h>
 
+#include "webrtc/base/format_macros.h"
 #include "webrtc/modules/media_file/source/media_file_impl.h"
 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
 #include "webrtc/system_wrappers/interface/file_wrapper.h"
@@ -109,25 +110,25 @@
 
 int32_t MediaFileImpl::PlayoutAVIVideoData(
     int8_t* buffer,
-    uint32_t& dataLengthInBytes)
+    size_t& dataLengthInBytes)
 {
     return PlayoutData( buffer, dataLengthInBytes, true);
 }
 
 int32_t MediaFileImpl::PlayoutAudioData(int8_t* buffer,
-                                        uint32_t& dataLengthInBytes)
+                                        size_t& dataLengthInBytes)
 {
     return PlayoutData( buffer, dataLengthInBytes, false);
 }
 
-int32_t MediaFileImpl::PlayoutData(int8_t* buffer, uint32_t& dataLengthInBytes,
+int32_t MediaFileImpl::PlayoutData(int8_t* buffer, size_t& dataLengthInBytes,
                                    bool video)
 {
     WEBRTC_TRACE(kTraceStream, kTraceFile, _id,
-               "MediaFileImpl::PlayoutData(buffer= 0x%x, bufLen= %ld)",
+               "MediaFileImpl::PlayoutData(buffer= 0x%x, bufLen= %" PRIuS ")",
                  buffer, dataLengthInBytes);
 
-    const uint32_t bufferLengthInBytes = dataLengthInBytes;
+    const size_t bufferLengthInBytes = dataLengthInBytes;
     dataLengthInBytes = 0;
 
     if(buffer == NULL || bufferLengthInBytes == 0)
@@ -185,7 +186,7 @@
                     bufferLengthInBytes);
                 if(bytesRead > 0)
                 {
-                    dataLengthInBytes = bytesRead;
+                    dataLengthInBytes = static_cast<size_t>(bytesRead);
                     return 0;
                 }
                 break;
@@ -216,7 +217,7 @@
 
         if( bytesRead > 0)
         {
-            dataLengthInBytes =(uint32_t) bytesRead;
+            dataLengthInBytes = static_cast<size_t>(bytesRead);
         }
     }
     HandlePlayCallbacks(bytesRead);
@@ -266,16 +267,16 @@
 int32_t MediaFileImpl::PlayoutStereoData(
     int8_t* bufferLeft,
     int8_t* bufferRight,
-    uint32_t& dataLengthInBytes)
+    size_t& dataLengthInBytes)
 {
     WEBRTC_TRACE(kTraceStream, kTraceFile, _id,
-                 "MediaFileImpl::PlayoutStereoData(Left = 0x%x, Right = 0x%x,\
- Len= %ld)",
+                 "MediaFileImpl::PlayoutStereoData(Left = 0x%x, Right = 0x%x,"
+                 " Len= %" PRIuS ")",
                  bufferLeft,
                  bufferRight,
                  dataLengthInBytes);
 
-    const uint32_t bufferLengthInBytes = dataLengthInBytes;
+    const size_t bufferLengthInBytes = dataLengthInBytes;
     dataLengthInBytes = 0;
 
     if(bufferLeft == NULL || bufferRight == NULL || bufferLengthInBytes == 0)
@@ -328,7 +329,7 @@
 
         if(bytesRead > 0)
         {
-            dataLengthInBytes = bytesRead;
+            dataLengthInBytes = static_cast<size_t>(bytesRead);
 
             // Check if it's time for PlayNotification(..).
             _playoutPositionMs = _ptrFileUtilityObj->PlayoutPositionMs();
@@ -690,25 +691,25 @@
 
 int32_t MediaFileImpl::IncomingAudioData(
     const int8_t*  buffer,
-    const uint32_t bufferLengthInBytes)
+    const size_t bufferLengthInBytes)
 {
     return IncomingAudioVideoData( buffer, bufferLengthInBytes, false);
 }
 
 int32_t MediaFileImpl::IncomingAVIVideoData(
     const int8_t*  buffer,
-    const uint32_t bufferLengthInBytes)
+    const size_t bufferLengthInBytes)
 {
     return IncomingAudioVideoData( buffer, bufferLengthInBytes, true);
 }
 
 int32_t MediaFileImpl::IncomingAudioVideoData(
     const int8_t*  buffer,
-    const uint32_t bufferLengthInBytes,
+    const size_t bufferLengthInBytes,
     const bool video)
 {
     WEBRTC_TRACE(kTraceStream, kTraceFile, _id,
-                 "MediaFile::IncomingData(buffer= 0x%x, bufLen= %hd",
+                 "MediaFile::IncomingData(buffer= 0x%x, bufLen= %" PRIuS,
                  buffer, bufferLengthInBytes);
 
     if(buffer == NULL || bufferLengthInBytes == 0)
@@ -803,7 +804,7 @@
             {
                 if(_ptrOutStream->Write(buffer, bufferLengthInBytes))
                 {
-                    bytesWritten = bufferLengthInBytes;
+                    bytesWritten = static_cast<int32_t>(bufferLengthInBytes);
                 }
             }
         }
diff --git a/webrtc/modules/media_file/source/media_file_impl.h b/webrtc/modules/media_file/source/media_file_impl.h
index eaec128..fc5799d 100644
--- a/webrtc/modules/media_file/source/media_file_impl.h
+++ b/webrtc/modules/media_file/source/media_file_impl.h
@@ -32,12 +32,12 @@
 
     // MediaFile functions
     virtual int32_t PlayoutAudioData(int8_t* audioBuffer,
-                                     uint32_t& dataLengthInBytes) OVERRIDE;
+                                     size_t& dataLengthInBytes) OVERRIDE;
     virtual int32_t PlayoutAVIVideoData(int8_t* videoBuffer,
-                                        uint32_t& dataLengthInBytes) OVERRIDE;
+                                        size_t& dataLengthInBytes) OVERRIDE;
     virtual int32_t PlayoutStereoData(int8_t* audioBufferLeft,
                                       int8_t* audioBufferRight,
-                                      uint32_t& dataLengthInBytes) OVERRIDE;
+                                      size_t& dataLengthInBytes) OVERRIDE;
     virtual int32_t StartPlayingAudioFile(
         const char*  fileName,
         const uint32_t notificationTimeMs = 0,
@@ -58,10 +58,10 @@
     virtual int32_t StopPlaying() OVERRIDE;
     virtual bool IsPlaying() OVERRIDE;
     virtual int32_t PlayoutPositionMs(uint32_t& positionMs) const OVERRIDE;
-    virtual int32_t IncomingAudioData(const int8_t*  audioBuffer,
-                                      const uint32_t bufferLength) OVERRIDE;
-    virtual int32_t IncomingAVIVideoData(const int8_t*  audioBuffer,
-                                         const uint32_t bufferLength) OVERRIDE;
+    virtual int32_t IncomingAudioData(const int8_t* audioBuffer,
+                                      const size_t bufferLength) OVERRIDE;
+    virtual int32_t IncomingAVIVideoData(const int8_t* audioBuffer,
+                                         const size_t bufferLength) OVERRIDE;
     virtual int32_t StartRecordingAudioFile(
         const char*  fileName,
         const FileFormats    format,
@@ -157,14 +157,14 @@
     // audioBuffer. As output parameter it indicates the number of bytes
     // written to audioBuffer. If video is true the data written is a video
     // frame otherwise it is an audio frame.
-    int32_t PlayoutData(int8_t* dataBuffer, uint32_t& dataLengthInBytes,
+    int32_t PlayoutData(int8_t* dataBuffer, size_t& dataLengthInBytes,
                         bool video);
 
     // Write one frame, i.e. the bufferLength first bytes of audioBuffer,
     // to file. The frame is an audio frame if video is true otherwise it is an
     // audio frame.
-    int32_t IncomingAudioVideoData(const int8_t*  buffer,
-                                   const uint32_t bufferLength,
+    int32_t IncomingAudioVideoData(const int8_t* buffer,
+                                   const size_t bufferLength,
                                    const bool video);
 
     // Open/creates file specified by fileName for writing (relative path is
diff --git a/webrtc/modules/media_file/source/media_file_unittest.cc b/webrtc/modules/media_file/source/media_file_unittest.cc
index 56d3544..15c529b 100644
--- a/webrtc/modules/media_file/source/media_file_unittest.cc
+++ b/webrtc/modules/media_file/source/media_file_unittest.cc
@@ -49,9 +49,11 @@
 
 TEST_F(MediaFileTest, WriteWavFile) {
   // Write file.
-  static const int kHeaderSize = 44;
-  static const int kPayloadSize = 320;
-  webrtc::CodecInst codec = {0, "L16", 16000, kPayloadSize, 1};
+  static const size_t kHeaderSize = 44;
+  static const size_t kPayloadSize = 320;
+  webrtc::CodecInst codec = {
+    0, "L16", 16000, static_cast<int>(kPayloadSize), 1
+  };
   std::string outfile = webrtc::test::OutputPath() + "wavtest.wav";
   ASSERT_EQ(0,
             media_file_->StartRecordingAudioFile(
@@ -78,8 +80,7 @@
   };
   COMPILE_ASSERT(sizeof(kExpectedHeader) == kHeaderSize, header_size);
 
-  EXPECT_EQ(size_t(kHeaderSize + kPayloadSize),
-            webrtc::test::GetFileSize(outfile));
+  EXPECT_EQ(kHeaderSize + kPayloadSize, webrtc::test::GetFileSize(outfile));
   FILE* f = fopen(outfile.c_str(), "rb");
   ASSERT_TRUE(f);
 
diff --git a/webrtc/modules/media_file/source/media_file_utility.cc b/webrtc/modules/media_file/source/media_file_utility.cc
index 71d62a1..7bffd0a 100644
--- a/webrtc/modules/media_file/source/media_file_utility.cc
+++ b/webrtc/modules/media_file/source/media_file_utility.cc
@@ -13,7 +13,9 @@
 #include <assert.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <limits>
 
+#include "webrtc/base/format_macros.h"
 #include "webrtc/common_audio/wav_header.h"
 #include "webrtc/common_types.h"
 #include "webrtc/engine_configurations.h"
@@ -234,7 +236,7 @@
 
 int32_t ModuleFileUtility::WriteAviAudioData(
     const int8_t* buffer,
-    uint32_t bufferLengthInBytes)
+    size_t bufferLengthInBytes)
 {
     if( _aviOutFile != 0)
     {
@@ -251,7 +253,7 @@
 
 int32_t ModuleFileUtility::WriteAviVideoData(
         const int8_t* buffer,
-        uint32_t bufferLengthInBytes)
+        size_t bufferLengthInBytes)
 {
     if( _aviOutFile != 0)
     {
@@ -370,7 +372,7 @@
 
 int32_t ModuleFileUtility::ReadAviAudioData(
     int8_t*  outBuffer,
-    const uint32_t bufferLengthInBytes)
+    size_t bufferLengthInBytes)
 {
     if(_aviAudioInFile == 0)
     {
@@ -378,22 +380,20 @@
         return -1;
     }
 
-    int32_t length = bufferLengthInBytes;
-    if(_aviAudioInFile->ReadAudio(
-        reinterpret_cast<uint8_t*>(outBuffer),
-        length) != 0)
+    if(_aviAudioInFile->ReadAudio(reinterpret_cast<uint8_t*>(outBuffer),
+                                  bufferLengthInBytes) != 0)
     {
         return -1;
     }
     else
     {
-        return length;
+        return static_cast<int32_t>(bufferLengthInBytes);
     }
 }
 
 int32_t ModuleFileUtility::ReadAviVideoData(
     int8_t* outBuffer,
-    const uint32_t bufferLengthInBytes)
+    size_t bufferLengthInBytes)
 {
     if(_aviVideoInFile == 0)
     {
@@ -401,14 +401,12 @@
         return -1;
     }
 
-    int32_t length = bufferLengthInBytes;
-    if( _aviVideoInFile->ReadVideo(
-        reinterpret_cast<uint8_t*>(outBuffer),
-        length) != 0)
+    if(_aviVideoInFile->ReadVideo(reinterpret_cast<uint8_t*>(outBuffer),
+                                  bufferLengthInBytes) != 0)
     {
         return -1;
     } else {
-        return length;
+        return static_cast<int32_t>(bufferLengthInBytes);
     }
 }
 
@@ -774,14 +772,14 @@
 int32_t ModuleFileUtility::ReadWavDataAsMono(
     InStream& wav,
     int8_t* outData,
-    const uint32_t bufferSize)
+    const size_t bufferSize)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::ReadWavDataAsMono(wav= 0x%x, outData= 0x%d,\
- bufSize= %ld)",
+        "ModuleFileUtility::ReadWavDataAsMono(wav= 0x%x, outData= 0x%d, "
+        "bufSize= %" PRIuS ")",
         &wav,
         outData,
         bufferSize);
@@ -853,14 +851,14 @@
     InStream& wav,
     int8_t* outDataLeft,
     int8_t* outDataRight,
-    const uint32_t bufferSize)
+    const size_t bufferSize)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::ReadWavDataAsStereo(wav= 0x%x, outLeft= 0x%x,\
- outRight= 0x%x, bufSize= %ld)",
+        "ModuleFileUtility::ReadWavDataAsStereo(wav= 0x%x, outLeft= 0x%x, "
+        "outRight= 0x%x, bufSize= %" PRIuS ")",
         &wav,
         outDataLeft,
         outDataRight,
@@ -1083,13 +1081,14 @@
 
 int32_t ModuleFileUtility::WriteWavData(OutStream& out,
                                         const int8_t*  buffer,
-                                        const uint32_t dataLength)
+                                        const size_t dataLength)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::WriteWavData(out= 0x%x, buf= 0x%x, dataLen= %d)",
+        "ModuleFileUtility::WriteWavData(out= 0x%x, buf= 0x%x, dataLen= %" PRIuS
+        ")",
         &out,
         buffer,
         dataLength);
@@ -1106,7 +1105,7 @@
         return -1;
     }
     _bytesWritten += dataLength;
-    return dataLength;
+    return static_cast<int32_t>(dataLength);
 }
 
 
@@ -1192,14 +1191,14 @@
 int32_t ModuleFileUtility::ReadPreEncodedData(
     InStream& in,
     int8_t* outData,
-    const uint32_t bufferSize)
+    const size_t bufferSize)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::ReadPreEncodedData(in= 0x%x, outData= 0x%x,\
- bufferSize= %d)",
+        "ModuleFileUtility::ReadPreEncodedData(in= 0x%x, outData= 0x%x, "
+        "bufferSize= %" PRIuS ")",
         &in,
         outData,
         bufferSize);
@@ -1259,14 +1258,14 @@
 int32_t ModuleFileUtility::WritePreEncodedData(
     OutStream& out,
     const int8_t*  buffer,
-    const uint32_t dataLength)
+    const size_t dataLength)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::WritePreEncodedData(out= 0x%x, inData= 0x%x,\
- dataLen= %d)",
+        "ModuleFileUtility::WritePreEncodedData(out= 0x%x, inData= 0x%x, "
+        "dataLen= %" PRIuS ")",
         &out,
         buffer,
         dataLength);
@@ -1276,11 +1275,12 @@
         WEBRTC_TRACE(kTraceError, kTraceFile, _id,"buffer NULL");
     }
 
-    int32_t bytesWritten = 0;
+    size_t bytesWritten = 0;
     // The first two bytes is the size of the frame.
     int16_t lengthBuf;
     lengthBuf = (int16_t)dataLength;
-    if(!out.Write(&lengthBuf, 2))
+    if(dataLength > static_cast<size_t>(std::numeric_limits<int16_t>::max()) ||
+       !out.Write(&lengthBuf, 2))
     {
        return -1;
     }
@@ -1291,7 +1291,7 @@
         return -1;
     }
     bytesWritten += dataLength;
-    return bytesWritten;
+    return static_cast<int32_t>(bytesWritten);
 }
 
 int32_t ModuleFileUtility::InitCompressedReading(
@@ -1495,14 +1495,14 @@
 
 int32_t ModuleFileUtility::ReadCompressedData(InStream& in,
                                               int8_t* outData,
-                                              uint32_t bufferSize)
+                                              size_t bufferSize)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::ReadCompressedData(in=0x%x, outData=0x%x,\
- bytes=%ld)",
+        "ModuleFileUtility::ReadCompressedData(in=0x%x, outData=0x%x, bytes=%"
+        PRIuS ")",
         &in,
         outData,
         bufferSize);
@@ -1554,7 +1554,7 @@
         }
         if(mode != 15)
         {
-            if(bufferSize < AMRmode2bytes[mode] + 1)
+            if(bufferSize < static_cast<size_t>(AMRmode2bytes[mode] + 1))
             {
                 WEBRTC_TRACE(
                     kTraceError,
@@ -1612,7 +1612,7 @@
         }
         if(mode != 15)
         {
-            if(bufferSize < AMRWBmode2bytes[mode] + 1)
+            if(bufferSize < static_cast<size_t>(AMRWBmode2bytes[mode] + 1))
             {
                 WEBRTC_TRACE(kTraceError, kTraceFile, _id,
                            "output buffer is too short to read AMRWB\
@@ -1770,14 +1770,14 @@
 int32_t ModuleFileUtility::WriteCompressedData(
     OutStream& out,
     const int8_t* buffer,
-    const uint32_t dataLength)
+    const size_t dataLength)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::WriteCompressedData(out= 0x%x, buf= 0x%x,\
- dataLen= %d)",
+        "ModuleFileUtility::WriteCompressedData(out= 0x%x, buf= 0x%x, "
+        "dataLen= %" PRIuS ")",
         &out,
         buffer,
         dataLength);
@@ -1791,7 +1791,7 @@
     {
         return -1;
     }
-    return dataLength;
+    return static_cast<int32_t>(dataLength);
 }
 
 int32_t ModuleFileUtility::InitPCMReading(InStream& pcm,
@@ -1872,13 +1872,14 @@
 
 int32_t ModuleFileUtility::ReadPCMData(InStream& pcm,
                                        int8_t* outData,
-                                       uint32_t bufferSize)
+                                       size_t bufferSize)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::ReadPCMData(pcm= 0x%x, outData= 0x%x, bufSize= %d)",
+        "ModuleFileUtility::ReadPCMData(pcm= 0x%x, outData= 0x%x, bufSize= %"
+        PRIuS ")",
         &pcm,
         outData,
         bufferSize);
@@ -2006,13 +2007,14 @@
 
 int32_t ModuleFileUtility::WritePCMData(OutStream& out,
                                         const int8_t*  buffer,
-                                        const uint32_t dataLength)
+                                        const size_t dataLength)
 {
     WEBRTC_TRACE(
         kTraceStream,
         kTraceFile,
         _id,
-        "ModuleFileUtility::WritePCMData(out= 0x%x, buf= 0x%x, dataLen= %d)",
+        "ModuleFileUtility::WritePCMData(out= 0x%x, buf= 0x%x, dataLen= %" PRIuS
+        ")",
         &out,
         buffer,
         dataLength);
@@ -2028,7 +2030,7 @@
     }
 
     _bytesWritten += dataLength;
-    return dataLength;
+    return static_cast<int32_t>(dataLength);
 }
 
 int32_t ModuleFileUtility::codec_info(CodecInst& codecInst)
diff --git a/webrtc/modules/media_file/source/media_file_utility.h b/webrtc/modules/media_file/source/media_file_utility.h
index 5fc9ef4..d8fefcc 100644
--- a/webrtc/modules/media_file/source/media_file_utility.h
+++ b/webrtc/modules/media_file/source/media_file_utility.h
@@ -43,13 +43,13 @@
     // audio with more channels (in which case the audio will be coverted to
     // mono).
     int32_t ReadAviAudioData(int8_t* outBuffer,
-                             const uint32_t bufferLengthInBytes);
+                             size_t bufferLengthInBytes);
 
     // Put one video frame into outBuffer. bufferLengthInBytes indicates the
     // size of outBuffer.
     // The return value is the number of bytes written to videoBuffer.
     int32_t ReadAviVideoData(int8_t* videoBuffer,
-                             const uint32_t bufferLengthInBytes);
+                             size_t bufferLengthInBytes);
 
     // Open/create the file specified by fileName for writing audio/video data
     // (relative path is allowed). codecInst specifies the encoding of the audio
@@ -66,7 +66,7 @@
     // InitAviWriting(..) call.
     // Note: bufferLength must be exactly one frame.
     int32_t WriteAviAudioData(const int8_t* audioBuffer,
-                              uint32_t bufferLengthInBytes);
+                              size_t bufferLengthInBytes);
 
 
     // Write one video frame, i.e. the bufferLength first bytes of videoBuffer,
@@ -76,7 +76,7 @@
     // InitAviWriting(..) call. The videoBuffer must contain exactly
     // one video frame.
     int32_t WriteAviVideoData(const int8_t* videoBuffer,
-                              uint32_t bufferLengthInBytes);
+                              size_t bufferLengthInBytes);
 
     // Stop recording to file or stream.
     int32_t CloseAviFile();
@@ -98,7 +98,7 @@
     // audio with more channels (in which case the audio will be converted to
     // mono).
     int32_t ReadWavDataAsMono(InStream& stream, int8_t* audioBuffer,
-                              const uint32_t dataLengthInBytes);
+                              const size_t dataLengthInBytes);
 
     // Put 10-60ms, depending on codec frame size, of audio data from file into
     // audioBufferLeft and audioBufferRight. The buffers contain the left and
@@ -111,7 +111,7 @@
     int32_t ReadWavDataAsStereo(InStream& wav,
                                 int8_t* audioBufferLeft,
                                 int8_t* audioBufferRight,
-                                const uint32_t bufferLength);
+                                const size_t bufferLength);
 
     // Prepare for recording audio to stream.
     // codecInst specifies the encoding of the audio data.
@@ -125,7 +125,7 @@
     // The return value is the number of bytes written to audioBuffer.
     int32_t WriteWavData(OutStream& stream,
                          const int8_t* audioBuffer,
-                         const uint32_t bufferLength);
+                         const size_t bufferLength);
 
     // Finalizes the WAV header so that it is correct if nothing more will be
     // written to stream.
@@ -148,7 +148,7 @@
     // codec frame size. dataLengthInBytes indicates the size of audioBuffer.
     // The return value is the number of bytes written to audioBuffer.
     int32_t ReadPCMData(InStream& stream, int8_t* audioBuffer,
-                        const uint32_t dataLengthInBytes);
+                        const size_t dataLengthInBytes);
 
     // Prepare for recording audio to stream.
     // freqInHz is the PCM sampling frequency.
@@ -161,7 +161,7 @@
     // The return value is the number of bytes written to audioBuffer.
     int32_t WritePCMData(OutStream& stream,
                          const int8_t* audioBuffer,
-                         uint32_t bufferLength);
+                         size_t bufferLength);
 
     // Prepare for playing audio from stream.
     // startPointMs and stopPointMs, unless zero, specify what part of the file
@@ -175,7 +175,7 @@
     // The return value is the number of bytes written to audioBuffer.
     int32_t ReadCompressedData(InStream& stream,
                                int8_t* audioBuffer,
-                               const uint32_t dataLengthInBytes);
+                               const size_t dataLengthInBytes);
 
     // Prepare for recording audio to stream.
     // codecInst specifies the encoding of the audio data.
@@ -189,7 +189,7 @@
     // Note: bufferLength must be exactly one frame.
     int32_t WriteCompressedData(OutStream& stream,
                                 const int8_t* audioBuffer,
-                                const uint32_t bufferLength);
+                                const size_t bufferLength);
 
     // Prepare for playing audio from stream.
     // codecInst specifies the encoding of the audio data.
@@ -201,7 +201,7 @@
     // The return value is the number of bytes written to audioBuffer.
     int32_t ReadPreEncodedData(InStream& stream,
                                int8_t* audioBuffer,
-                               const uint32_t dataLengthInBytes);
+                               const size_t dataLengthInBytes);
 
     // Prepare for recording audio to stream.
     // codecInst specifies the encoding of the audio data.
@@ -215,7 +215,7 @@
     // Note: bufferLength must be exactly one frame.
     int32_t WritePreEncodedData(OutStream& stream,
                                 const int8_t* inData,
-                                const uint32_t dataLengthInBytes);
+                                const size_t dataLengthInBytes);
 
     // Set durationMs to the size of the file (in ms) specified by fileName.
     // freqInHz specifies the sampling frequency of the file.
@@ -320,7 +320,7 @@
     uint32_t _stopPointInMs;
     uint32_t _startPointInMs;
     uint32_t _playoutPositionMs;
-    uint32_t _bytesWritten;
+    size_t _bytesWritten;
 
     CodecInst codec_info_;
     MediaFileUtility_CodecType _codecId;
diff --git a/webrtc/modules/pacing/include/mock/mock_paced_sender.h b/webrtc/modules/pacing/include/mock/mock_paced_sender.h
index 0c9e354..bff6a5d 100644
--- a/webrtc/modules/pacing/include/mock/mock_paced_sender.h
+++ b/webrtc/modules/pacing/include/mock/mock_paced_sender.h
@@ -27,7 +27,7 @@
                                 uint32_t ssrc,
                                 uint16_t sequence_number,
                                 int64_t capture_time_ms,
-                                int bytes,
+                                size_t bytes,
                                 bool retransmission));
   MOCK_CONST_METHOD0(QueueInMs, int());
   MOCK_CONST_METHOD0(QueueInPackets, int());
diff --git a/webrtc/modules/pacing/include/paced_sender.h b/webrtc/modules/pacing/include/paced_sender.h
index 6a420e4..f0e98e8 100644
--- a/webrtc/modules/pacing/include/paced_sender.h
+++ b/webrtc/modules/pacing/include/paced_sender.h
@@ -52,7 +52,7 @@
                                   bool retransmission) = 0;
     // Called when it's a good time to send a padding data.
     // Returns the number of bytes sent.
-    virtual int TimeToSendPadding(int bytes) = 0;
+    virtual size_t TimeToSendPadding(size_t bytes) = 0;
 
    protected:
     virtual ~Callback() {}
@@ -102,7 +102,7 @@
                           uint32_t ssrc,
                           uint16_t sequence_number,
                           int64_t capture_time_ms,
-                          int bytes,
+                          size_t bytes,
                           bool retransmission);
 
   // Returns the time since the oldest queued packet was enqueued.
@@ -131,7 +131,7 @@
 
   bool SendPacket(const paced_sender::Packet& packet)
       EXCLUSIVE_LOCKS_REQUIRED(critsect_);
-  void SendPadding(int padding_needed) EXCLUSIVE_LOCKS_REQUIRED(critsect_);
+  void SendPadding(size_t padding_needed) EXCLUSIVE_LOCKS_REQUIRED(critsect_);
 
   Clock* const clock_;
   Callback* const callback_;
diff --git a/webrtc/modules/pacing/paced_sender.cc b/webrtc/modules/pacing/paced_sender.cc
index 98f508c..890955e 100644
--- a/webrtc/modules/pacing/paced_sender.cc
+++ b/webrtc/modules/pacing/paced_sender.cc
@@ -42,7 +42,7 @@
          uint16_t seq_number,
          int64_t capture_time_ms,
          int64_t enqueue_time_ms,
-         int length_in_bytes,
+         size_t length_in_bytes,
          bool retransmission,
          uint64_t enqueue_order)
       : priority(priority),
@@ -59,7 +59,7 @@
   uint16_t sequence_number;
   int64_t capture_time_ms;
   int64_t enqueue_time_ms;
-  int bytes;
+  size_t bytes;
   bool retransmission;
   uint64_t enqueue_order;
   std::list<Packet>::iterator this_it;
@@ -189,8 +189,8 @@
     }
   }
 
-  void UseBudget(int bytes) {
-    bytes_remaining_ = std::max(bytes_remaining_ - bytes,
+  void UseBudget(size_t bytes) {
+    bytes_remaining_ = std::max(bytes_remaining_ - static_cast<int>(bytes),
                                 -500 * target_rate_kbps_ / 8);
   }
 
@@ -258,7 +258,7 @@
 }
 
 bool PacedSender::SendPacket(Priority priority, uint32_t ssrc,
-    uint16_t sequence_number, int64_t capture_time_ms, int bytes,
+    uint16_t sequence_number, int64_t capture_time_ms, size_t bytes,
     bool retransmission) {
   CriticalSectionScoped cs(critsect_.get());
 
@@ -353,7 +353,7 @@
 
     int padding_needed = padding_budget_->bytes_remaining();
     if (padding_needed > 0) {
-      SendPadding(padding_needed);
+      SendPadding(static_cast<size_t>(padding_needed));
     }
   }
   return 0;
@@ -377,9 +377,9 @@
   return success;
 }
 
-void PacedSender::SendPadding(int padding_needed) {
+void PacedSender::SendPadding(size_t padding_needed) {
   critsect_->Leave();
-  int bytes_sent = callback_->TimeToSendPadding(padding_needed);
+  size_t bytes_sent = callback_->TimeToSendPadding(padding_needed);
   critsect_->Enter();
 
   // Update padding bytes sent.
diff --git a/webrtc/modules/pacing/paced_sender_unittest.cc b/webrtc/modules/pacing/paced_sender_unittest.cc
index ac713c8..4303b64 100644
--- a/webrtc/modules/pacing/paced_sender_unittest.cc
+++ b/webrtc/modules/pacing/paced_sender_unittest.cc
@@ -32,7 +32,7 @@
                     int64_t capture_time_ms,
                     bool retransmission));
   MOCK_METHOD1(TimeToSendPadding,
-      int(int bytes));
+      size_t(size_t bytes));
 };
 
 class PacedSenderPadding : public PacedSender::Callback {
@@ -46,17 +46,17 @@
     return true;
   }
 
-  int TimeToSendPadding(int bytes) {
-    const int kPaddingPacketSize = 224;
-    int num_packets = (bytes + kPaddingPacketSize - 1) / kPaddingPacketSize;
+  size_t TimeToSendPadding(size_t bytes) {
+    const size_t kPaddingPacketSize = 224;
+    size_t num_packets = (bytes + kPaddingPacketSize - 1) / kPaddingPacketSize;
     padding_sent_ += kPaddingPacketSize * num_packets;
     return kPaddingPacketSize * num_packets;
   }
 
-  int padding_sent() { return padding_sent_; }
+  size_t padding_sent() { return padding_sent_; }
 
  private:
-  int padding_sent_;
+  size_t padding_sent_;
 };
 
 class PacedSenderProbing : public PacedSender::Callback {
@@ -84,7 +84,7 @@
     return true;
   }
 
-  int TimeToSendPadding(int bytes) {
+  size_t TimeToSendPadding(size_t bytes) {
     EXPECT_TRUE(false);
     return bytes;
   }
@@ -114,7 +114,7 @@
                            uint32_t ssrc,
                            uint16_t sequence_number,
                            int64_t capture_time_ms,
-                           int size,
+                           size_t size,
                            bool retransmission) {
     EXPECT_FALSE(send_bucket_->SendPacket(priority, ssrc,
         sequence_number, capture_time_ms, size, retransmission));
@@ -421,9 +421,9 @@
   send_bucket_->UpdateBitrate(
       kTargetBitrate, kPaceMultiplier * kTargetBitrate, kTargetBitrate);
   int64_t start_time = clock_.TimeInMilliseconds();
-  int media_bytes = 0;
+  size_t media_bytes = 0;
   while (clock_.TimeInMilliseconds() - start_time < kBitrateWindow) {
-    int media_payload = rand() % 100 + 200;  // [200, 300] bytes.
+    size_t media_payload = rand() % 100 + 200;  // [200, 300] bytes.
     EXPECT_FALSE(send_bucket_->SendPacket(PacedSender::kNormalPriority, ssrc,
                                           sequence_number++, capture_time_ms,
                                           media_payload, false));
@@ -431,8 +431,9 @@
     clock_.AdvanceTimeMilliseconds(kTimeStep);
     send_bucket_->Process();
   }
-  EXPECT_NEAR(kTargetBitrate, 8 * (media_bytes + callback.padding_sent()) /
-              kBitrateWindow, 1);
+  EXPECT_NEAR(kTargetBitrate,
+              static_cast<int>(8 * (media_bytes + callback.padding_sent()) /
+                  kBitrateWindow), 1);
 }
 
 TEST_F(PacedSenderTest, Priority) {
@@ -642,19 +643,20 @@
 TEST_F(PacedSenderTest, ExpectedQueueTimeMs) {
   uint32_t ssrc = 12346;
   uint16_t sequence_number = 1234;
-  const int32_t kNumPackets = 60;
-  const int32_t kPacketSize = 1200;
+  const size_t kNumPackets = 60;
+  const size_t kPacketSize = 1200;
   const int32_t kMaxBitrate = kPaceMultiplier * 30;
   EXPECT_EQ(0, send_bucket_->ExpectedQueueTimeMs());
 
   send_bucket_->UpdateBitrate(30, kMaxBitrate, 0);
-  for (int i = 0; i < kNumPackets; ++i) {
+  for (size_t i = 0; i < kNumPackets; ++i) {
     SendAndExpectPacket(PacedSender::kNormalPriority, ssrc, sequence_number++,
                         clock_.TimeInMilliseconds(), kPacketSize, false);
   }
 
   // Queue in ms = 1000 * (bytes in queue) / (kbit per second * 1000 / 8)
-  int64_t queue_in_ms = kNumPackets * kPacketSize * 8 / kMaxBitrate;
+  int64_t queue_in_ms =
+      static_cast<int64_t>(kNumPackets * kPacketSize * 8 / kMaxBitrate);
   EXPECT_EQ(queue_in_ms, send_bucket_->ExpectedQueueTimeMs());
 
   int64_t time_start = clock_.TimeInMilliseconds();
@@ -672,7 +674,8 @@
 
   // Allow for aliasing, duration should be in [expected(n - 1), expected(n)].
   EXPECT_LE(duration, queue_in_ms);
-  EXPECT_GE(duration, queue_in_ms - (kPacketSize * 8 / kMaxBitrate));
+  EXPECT_GE(duration,
+            queue_in_ms - static_cast<int64_t>(kPacketSize * 8 / kMaxBitrate));
 }
 
 TEST_F(PacedSenderTest, QueueTimeGrowsOverTime) {
@@ -713,7 +716,7 @@
 TEST_F(PacedSenderTest, ProbingWithInitialFrame) {
   const int kNumPackets = 11;
   const int kNumDeltas = kNumPackets - 1;
-  const int kPacketSize = 1200;
+  const size_t kPacketSize = 1200;
   const int kInitialBitrateKbps = 300;
   uint32_t ssrc = 12346;
   uint16_t sequence_number = 1234;
@@ -749,7 +752,7 @@
 TEST_F(PacedSenderTest, PriorityInversion) {
   uint32_t ssrc = 12346;
   uint16_t sequence_number = 1234;
-  const int32_t kPacketSize = 1200;
+  const size_t kPacketSize = 1200;
 
   EXPECT_FALSE(send_bucket_->SendPacket(
       PacedSender::kHighPriority, ssrc, sequence_number + 3,
@@ -797,7 +800,7 @@
 TEST_F(PacedSenderTest, PaddingOveruse) {
   uint32_t ssrc = 12346;
   uint16_t sequence_number = 1234;
-  const int32_t kPacketSize = 1200;
+  const size_t kPacketSize = 1200;
 
   // Min bitrate 0 => no padding, padding budget will stay at 0.
   send_bucket_->UpdateBitrate(60, 90, 0);
diff --git a/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h b/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h
index e61e903..ede3c5d 100644
--- a/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h
+++ b/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h
@@ -73,7 +73,7 @@
   // packet size excluding headers.
   // Note that |arrival_time_ms| can be of an arbitrary time base.
   virtual void IncomingPacket(int64_t arrival_time_ms,
-                              int payload_size,
+                              size_t payload_size,
                               const RTPHeader& header) = 0;
 
   // Removes all data for |ssrc|.
diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc b/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
index 9baaa9c..df98450 100644
--- a/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
+++ b/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
@@ -46,7 +46,7 @@
   ts_delta_hist_.clear();
 }
 
-void OveruseDetector::Update(uint16_t packet_size,
+void OveruseDetector::Update(size_t packet_size,
                              int64_t timestamp_ms,
                              uint32_t timestamp,
                              const int64_t arrival_time_ms) {
@@ -157,8 +157,8 @@
 
 void OveruseDetector::UpdateKalman(int64_t t_delta,
                                    double ts_delta,
-                                   uint32_t frame_size,
-                                   uint32_t prev_frame_size) {
+                                   size_t frame_size,
+                                   size_t prev_frame_size) {
   const double min_frame_period = UpdateMinFramePeriod(ts_delta);
   const double drift = CurrentDrift();
   // Compensate for drift
diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_detector.h b/webrtc/modules/remote_bitrate_estimator/overuse_detector.h
index 9c565e4..f80c92c 100644
--- a/webrtc/modules/remote_bitrate_estimator/overuse_detector.h
+++ b/webrtc/modules/remote_bitrate_estimator/overuse_detector.h
@@ -25,7 +25,7 @@
  public:
   explicit OveruseDetector(const OverUseDetectorOptions& options);
   ~OveruseDetector();
-  void Update(uint16_t packet_size,
+  void Update(size_t packet_size,
               int64_t timestamp_ms,
               uint32_t rtp_timestamp,
               int64_t arrival_time_ms);
@@ -41,7 +41,7 @@
           timestamp(-1),
           timestamp_ms(-1) {}
 
-    uint32_t size;
+    size_t size;
     int64_t complete_time_ms;
     int64_t timestamp;
     int64_t timestamp_ms;
@@ -63,8 +63,8 @@
                   double* ts_delta);
   void UpdateKalman(int64_t t_delta,
                     double ts_elta,
-                    uint32_t frame_size,
-                    uint32_t prev_frame_size);
+                    size_t frame_size,
+                    size_t prev_frame_size);
   double UpdateMinFramePeriod(double ts_delta);
   void UpdateNoiseEstimate(double residual, double ts_delta, bool stable_state);
   BandwidthUsage Detect(double ts_delta);
diff --git a/webrtc/modules/remote_bitrate_estimator/rate_statistics.cc b/webrtc/modules/remote_bitrate_estimator/rate_statistics.cc
index 48485ff..c1b4c80 100644
--- a/webrtc/modules/remote_bitrate_estimator/rate_statistics.cc
+++ b/webrtc/modules/remote_bitrate_estimator/rate_statistics.cc
@@ -16,7 +16,7 @@
 
 RateStatistics::RateStatistics(uint32_t window_size_ms, float scale)
     : num_buckets_(window_size_ms + 1),  // N ms in (N+1) buckets.
-      buckets_(new uint32_t[num_buckets_]()),
+      buckets_(new size_t[num_buckets_]()),
       accumulated_count_(0),
       oldest_time_(0),
       oldest_index_(0),
@@ -35,7 +35,7 @@
   }
 }
 
-void RateStatistics::Update(uint32_t count, int64_t now_ms) {
+void RateStatistics::Update(size_t count, int64_t now_ms) {
   if (now_ms < oldest_time_) {
     // Too old data is ignored.
     return;
@@ -65,7 +65,7 @@
   }
 
   while (oldest_time_ < new_oldest_time) {
-    uint32_t count_in_oldest_bucket = buckets_[oldest_index_];
+    size_t count_in_oldest_bucket = buckets_[oldest_index_];
     assert(accumulated_count_ >= count_in_oldest_bucket);
     accumulated_count_ -= count_in_oldest_bucket;
     buckets_[oldest_index_] = 0;
diff --git a/webrtc/modules/remote_bitrate_estimator/rate_statistics.h b/webrtc/modules/remote_bitrate_estimator/rate_statistics.h
index f97371b..d1d4a6f 100644
--- a/webrtc/modules/remote_bitrate_estimator/rate_statistics.h
+++ b/webrtc/modules/remote_bitrate_estimator/rate_statistics.h
@@ -25,7 +25,7 @@
   ~RateStatistics();
 
   void Reset();
-  void Update(uint32_t count, int64_t now_ms);
+  void Update(size_t count, int64_t now_ms);
   uint32_t Rate(int64_t now_ms);
 
  private:
@@ -34,10 +34,10 @@
   // Counters are kept in buckets (circular buffer), with one bucket
   // per millisecond.
   const int num_buckets_;
-  scoped_ptr<uint32_t[]> buckets_;
+  scoped_ptr<size_t[]> buckets_;
 
   // Total count recorded in buckets.
-  uint32_t accumulated_count_;
+  size_t accumulated_count_;
 
   // Oldest time recorded in buckets.
   int64_t oldest_time_;
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
index 08422d2..fd7de83 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
@@ -35,7 +35,7 @@
   // remote bitrate estimate will be updated. Note that |payload_size| is the
   // packet size excluding headers.
   virtual void IncomingPacket(int64_t arrival_time_ms,
-                              int payload_size,
+                              size_t payload_size,
                               const RTPHeader& header) OVERRIDE;
 
   // Triggers a new estimate calculation.
@@ -107,7 +107,7 @@
 
 void RemoteBitrateEstimatorSingleStream::IncomingPacket(
     int64_t arrival_time_ms,
-    int payload_size,
+    size_t payload_size,
     const RTPHeader& header) {
   uint32_t ssrc = header.ssrc;
   uint32_t rtp_timestamp = header.timestamp +
@@ -133,7 +133,7 @@
   const BandwidthUsage prior_state = overuse_detector->State();
   overuse_detector->Update(payload_size, -1, rtp_timestamp, arrival_time_ms);
   if (overuse_detector->State() == kBwOverusing) {
-    unsigned int incoming_bitrate = incoming_bitrate_.Rate(now_ms);
+    uint32_t incoming_bitrate = incoming_bitrate_.Rate(now_ms);
     if (prior_state != kBwOverusing ||
         remote_rate_.TimeToReduceFurther(now_ms, incoming_bitrate)) {
       // The first overuse should immediately trigger a new estimate.
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
index 4f9e16c..9073617 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
@@ -14,7 +14,8 @@
 
 namespace webrtc {
 
-enum { kMtu = 1200, kAcceptedBitrateErrorBps = 50000u };
+const size_t kMtu = 1200;
+const unsigned int kAcceptedBitrateErrorBps = 50000;
 
 namespace testing {
 
@@ -54,11 +55,11 @@
     return next_rtp_time_;
   }
   assert(packets != NULL);
-  int bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_;
-  int n_packets = std::max((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1);
-  int packet_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets);
-  assert(n_packets >= 0);
-  for (int i = 0; i < n_packets; ++i) {
+  size_t bits_per_frame = (bitrate_bps_ + fps_ / 2) / fps_;
+  size_t n_packets =
+      std::max<size_t>((bits_per_frame + 4 * kMtu) / (8 * kMtu), 1u);
+  size_t packet_size = (bits_per_frame + 4 * n_packets) / (8 * n_packets);
+  for (size_t i = 0; i < n_packets; ++i) {
     RtpPacket* packet = new RtpPacket;
     packet->send_time = time_now_us + kSendSideOffsetUs;
     packet->size = packet_size;
@@ -217,7 +218,7 @@
 const unsigned int RemoteBitrateEstimatorTest::kDefaultSsrc = 1;
 
 void RemoteBitrateEstimatorTest::IncomingPacket(uint32_t ssrc,
-                                                uint32_t payload_size,
+                                                size_t payload_size,
                                                 int64_t arrival_time,
                                                 uint32_t rtp_timestamp,
                                                 uint32_t absolute_send_time) {
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h
index 2ef2f45..a935896 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h
@@ -49,7 +49,7 @@
     int64_t send_time;
     int64_t arrival_time;
     uint32_t rtp_timestamp;
-    unsigned int size;
+    size_t size;
     unsigned int ssrc;
   };
 
@@ -165,7 +165,7 @@
   // estimator (all other fields are cleared) and call IncomingPacket on the
   // estimator.
   void IncomingPacket(uint32_t ssrc,
-                      uint32_t payload_size,
+                      size_t payload_size,
                       int64_t arrival_time,
                       uint32_t rtp_timestamp,
                       uint32_t absolute_send_time);
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
index f7a7197..42b5d34 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
@@ -127,7 +127,7 @@
   memset(&header_, 0, sizeof(header_));
 }
 
-Packet::Packet(int flow_id, int64_t send_time_us, uint32_t payload_size,
+Packet::Packet(int flow_id, int64_t send_time_us, size_t payload_size,
                const RTPHeader& header)
     : flow_id_(flow_id),
       creation_time_us_(send_time_us),
@@ -785,7 +785,7 @@
   return false;
 }
 
-int PacedVideoSender::TimeToSendPadding(int bytes) {
+size_t PacedVideoSender::TimeToSendPadding(size_t bytes) {
   return 0;
 }
 }  // namespace bwe
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
index 6098197..a7d0ebc 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
@@ -153,7 +153,7 @@
 class Packet {
  public:
   Packet();
-  Packet(int flow_id, int64_t send_time_us, uint32_t payload_size,
+  Packet(int flow_id, int64_t send_time_us, size_t payload_size,
          const RTPHeader& header);
   Packet(int64_t send_time_us, uint32_t sequence_number);
 
@@ -164,14 +164,14 @@
   void set_send_time_us(int64_t send_time_us);
   int64_t send_time_us() const { return send_time_us_; }
   void SetAbsSendTimeMs(int64_t abs_send_time_ms);
-  uint32_t payload_size() const { return payload_size_; }
+  size_t payload_size() const { return payload_size_; }
   const RTPHeader& header() const { return header_; }
 
  private:
   int flow_id_;
   int64_t creation_time_us_;  // Time when the packet was created.
   int64_t send_time_us_;   // Time the packet left last processor touching it.
-  uint32_t payload_size_;  // Size of the (non-existent, simulated) payload.
+  size_t payload_size_;    // Size of the (non-existent, simulated) payload.
   RTPHeader header_;       // Actual contents.
 };
 
@@ -474,7 +474,7 @@
                                 uint16_t sequence_number,
                                 int64_t capture_time_ms,
                                 bool retransmission) OVERRIDE;
-  virtual int TimeToSendPadding(int bytes) OVERRIDE;
+  virtual size_t TimeToSendPadding(size_t bytes) OVERRIDE;
 
  private:
   class ProbingPacedSender : public PacedSender {
diff --git a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
index eb224f2..45a03f9 100644
--- a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
+++ b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
@@ -83,7 +83,7 @@
       if (header.extension.transmissionTimeOffset != 0)
         ++non_zero_ts_offsets;
       rbe->IncomingPacket(clock.TimeInMilliseconds(),
-                          static_cast<int>(packet.length - header.headerLength),
+                          packet.length - header.headerLength,
                           header);
       ++packet_counter;
     }
diff --git a/webrtc/modules/rtp_rtcp/interface/fec_receiver.h b/webrtc/modules/rtp_rtcp/interface/fec_receiver.h
index e2ef4b1..da54bf6 100644
--- a/webrtc/modules/rtp_rtcp/interface/fec_receiver.h
+++ b/webrtc/modules/rtp_rtcp/interface/fec_receiver.h
@@ -24,7 +24,7 @@
 
   virtual int32_t AddReceivedRedPacket(const RTPHeader& rtp_header,
                                        const uint8_t* incoming_rtp_packet,
-                                       int packet_length,
+                                       size_t packet_length,
                                        uint8_t ulpfec_payload_type) = 0;
 
   virtual int32_t ProcessReceivedFec() = 0;
diff --git a/webrtc/modules/rtp_rtcp/interface/receive_statistics.h b/webrtc/modules/rtp_rtcp/interface/receive_statistics.h
index 6f2ea4f..ae1fbb6 100644
--- a/webrtc/modules/rtp_rtcp/interface/receive_statistics.h
+++ b/webrtc/modules/rtp_rtcp/interface/receive_statistics.h
@@ -26,7 +26,7 @@
   virtual ~StreamStatistician();
 
   virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) = 0;
-  virtual void GetDataCounters(uint32_t* bytes_received,
+  virtual void GetDataCounters(size_t* bytes_received,
                                uint32_t* packets_received) const = 0;
   virtual uint32_t BitrateReceived() const = 0;
 
diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h b/webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h
index 327ea16..bbdac67 100644
--- a/webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h
+++ b/webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h
@@ -83,7 +83,7 @@
 
   bool RestoreOriginalPacket(uint8_t** restored_packet,
                              const uint8_t* packet,
-                             int* packet_length,
+                             size_t* packet_length,
                              uint32_t original_ssrc,
                              const RTPHeader& header) const;
 
diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_receiver.h b/webrtc/modules/rtp_rtcp/interface/rtp_receiver.h
index 00e5e5d..6283566 100644
--- a/webrtc/modules/rtp_rtcp/interface/rtp_receiver.h
+++ b/webrtc/modules/rtp_rtcp/interface/rtp_receiver.h
@@ -72,7 +72,7 @@
   // detected and acted upon.
   virtual bool IncomingRtpPacket(const RTPHeader& rtp_header,
                                  const uint8_t* payload,
-                                 int payload_length,
+                                 size_t payload_length,
                                  PayloadUnion payload_specific,
                                  bool in_order) = 0;
 
diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
index ca686c0..c1250b9 100644
--- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
+++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h
@@ -83,7 +83,7 @@
    ***************************************************************************/
 
     virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
-                                       uint16_t incoming_packet_length) = 0;
+                                       size_t incoming_packet_length) = 0;
 
     virtual void SetRemoteSSRC(const uint32_t ssrc) = 0;
 
@@ -328,7 +328,7 @@
         const uint32_t timeStamp,
         int64_t capture_time_ms,
         const uint8_t* payloadData,
-        const uint32_t payloadSize,
+        const size_t payloadSize,
         const RTPFragmentationHeader* fragmentation = NULL,
         const RTPVideoHeader* rtpVideoHdr = NULL) = 0;
 
@@ -337,7 +337,7 @@
                                   int64_t capture_time_ms,
                                   bool retransmission) = 0;
 
-    virtual int TimeToSendPadding(int bytes) = 0;
+    virtual size_t TimeToSendPadding(size_t bytes) = 0;
 
     virtual bool GetSendSideDelay(int* avg_send_delay_ms,
                                   int* max_send_delay_ms) const = 0;
@@ -465,7 +465,7 @@
     *   return -1 on failure else 0
     */
     virtual int32_t DataCountersRTP(
-        uint32_t* bytesSent,
+        size_t* bytesSent,
         uint32_t* packetsSent) const = 0;
     /*
     *   Get received RTCP sender info
diff --git a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h
index dc51467..e94be57 100644
--- a/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h
+++ b/webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h
@@ -143,7 +143,7 @@
                                   // instead of padding.
 };
 
-const int kRtxHeaderSize = 2;
+const size_t kRtxHeaderSize = 2;
 
 struct RTCPSenderInfo
 {
@@ -220,11 +220,11 @@
 
     virtual int32_t OnReceivedPayloadData(
         const uint8_t* payloadData,
-        const uint16_t payloadSize,
+        const size_t payloadSize,
         const WebRtcRTPHeader* rtpHeader) = 0;
 
     virtual bool OnRecoveredPacket(const uint8_t* packet,
-                                   int packet_length) = 0;
+                                   size_t packet_length) = 0;
 };
 
 class RtpFeedback
@@ -334,13 +334,13 @@
 
   virtual int32_t OnReceivedPayloadData(
       const uint8_t* payloadData,
-      const uint16_t payloadSize,
+      const size_t payloadSize,
       const WebRtcRTPHeader* rtpHeader) OVERRIDE {
     return 0;
   }
 
   virtual bool OnRecoveredPacket(const uint8_t* packet,
-                                 int packet_length) OVERRIDE {
+                                 size_t packet_length) OVERRIDE {
     return true;
   }
 };
diff --git a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
index 584b9ad..7880660 100644
--- a/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
+++ b/webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h
@@ -23,11 +23,11 @@
  public:
   MOCK_METHOD3(OnReceivedPayloadData,
                int32_t(const uint8_t* payloadData,
-                       const uint16_t payloadSize,
+                       const size_t payloadSize,
                        const WebRtcRTPHeader* rtpHeader));
 
   MOCK_METHOD2(OnRecoveredPacket,
-               bool(const uint8_t* packet, int packet_length));
+               bool(const uint8_t* packet, size_t packet_length));
 };
 
 class MockRtpRtcp : public RtpRtcp {
@@ -47,7 +47,7 @@
   MOCK_METHOD0(DeRegisterSyncModule,
       int32_t());
   MOCK_METHOD2(IncomingRtcpPacket,
-      int32_t(const uint8_t* incomingPacket, uint16_t packetLength));
+      int32_t(const uint8_t* incomingPacket, size_t packetLength));
   MOCK_METHOD1(SetRemoteSSRC, void(const uint32_t ssrc));
   MOCK_METHOD4(IncomingAudioNTP,
       int32_t(const uint32_t audioReceivedNTPsecs,
@@ -126,14 +126,14 @@
               const uint32_t timeStamp,
               int64_t capture_time_ms,
               const uint8_t* payloadData,
-              const uint32_t payloadSize,
+              const size_t payloadSize,
               const RTPFragmentationHeader* fragmentation,
               const RTPVideoHeader* rtpVideoHdr));
   MOCK_METHOD4(TimeToSendPacket,
       bool(uint32_t ssrc, uint16_t sequence_number, int64_t capture_time_ms,
            bool retransmission));
   MOCK_METHOD1(TimeToSendPadding,
-      int(int bytes));
+      size_t(size_t bytes));
   MOCK_CONST_METHOD2(GetSendSideDelay,
       bool(int* avg_send_delay_ms, int* max_send_delay_ms));
   MOCK_METHOD2(RegisterRtcpObservers,
@@ -172,7 +172,7 @@
   MOCK_METHOD0(ResetSendDataCountersRTP,
       int32_t());
   MOCK_CONST_METHOD2(DataCountersRTP,
-      int32_t(uint32_t *bytesSent, uint32_t *packetsSent));
+      int32_t(size_t *bytesSent, uint32_t *packetsSent));
   MOCK_METHOD1(RemoteRTCPStat,
       int32_t(RTCPSenderInfo* senderInfo));
   MOCK_CONST_METHOD1(RemoteRTCPStat,
diff --git a/webrtc/modules/rtp_rtcp/source/bitrate.cc b/webrtc/modules/rtp_rtcp/source/bitrate.cc
index 11b3cb2..0d50221 100644
--- a/webrtc/modules/rtp_rtcp/source/bitrate.cc
+++ b/webrtc/modules/rtp_rtcp/source/bitrate.cc
@@ -32,7 +32,7 @@
 
 Bitrate::~Bitrate() {}
 
-void Bitrate::Update(const int32_t bytes) {
+void Bitrate::Update(const size_t bytes) {
   CriticalSectionScoped cs(crit_.get());
   bytes_count_ += bytes;
   packet_count_++;
diff --git a/webrtc/modules/rtp_rtcp/source/bitrate.h b/webrtc/modules/rtp_rtcp/source/bitrate.h
index 36fa1d3..086db2a 100644
--- a/webrtc/modules/rtp_rtcp/source/bitrate.h
+++ b/webrtc/modules/rtp_rtcp/source/bitrate.h
@@ -35,7 +35,7 @@
   void Process();
 
   // Update with a packet.
-  void Update(const int32_t bytes);
+  void Update(const size_t bytes);
 
   // Packet rate last second, updated roughly every 100 ms.
   uint32_t PacketRate() const;
@@ -68,7 +68,7 @@
   int64_t bitrate_array_[10];
   int64_t bitrate_diff_ms_[10];
   int64_t time_last_rate_update_;
-  uint32_t bytes_count_;
+  size_t bytes_count_;
   uint32_t packet_count_;
   Observer* const observer_;
 };
diff --git a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
index e795841..0fcb6f7 100644
--- a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.cc
@@ -71,10 +71,10 @@
 
 int32_t FecReceiverImpl::AddReceivedRedPacket(
     const RTPHeader& header, const uint8_t* incoming_rtp_packet,
-    int packet_length, uint8_t ulpfec_payload_type) {
+    size_t packet_length, uint8_t ulpfec_payload_type) {
   CriticalSectionScoped cs(crit_sect_.get());
   uint8_t REDHeaderLength = 1;
-  uint16_t payload_data_length = packet_length - header.headerLength;
+  size_t payload_data_length = packet_length - header.headerLength;
 
   // Add to list without RED header, aka a virtual RTP packet
   // we remove the RED header
diff --git a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h
index b876bed..8dd02b3 100644
--- a/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h
+++ b/webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h
@@ -30,7 +30,7 @@
 
   virtual int32_t AddReceivedRedPacket(const RTPHeader& rtp_header,
                                        const uint8_t* incoming_rtp_packet,
-                                       int packet_length,
+                                       size_t packet_length,
                                        uint8_t ulpfec_payload_type) OVERRIDE;
 
   virtual int32_t ProcessReceivedFec() OVERRIDE;
diff --git a/webrtc/modules/rtp_rtcp/source/fec_test_helper.cc b/webrtc/modules/rtp_rtcp/source/fec_test_helper.cc
index 0ffd5bf..a85e749 100644
--- a/webrtc/modules/rtp_rtcp/source/fec_test_helper.cc
+++ b/webrtc/modules/rtp_rtcp/source/fec_test_helper.cc
@@ -44,7 +44,7 @@
 
 // Creates a new RtpPacket with the RED header added to the packet.
 RtpPacket* FrameGenerator::BuildMediaRedPacket(const RtpPacket* packet) {
-  const int kHeaderLength = packet->header.header.headerLength;
+  const size_t kHeaderLength = packet->header.header.headerLength;
   RtpPacket* red_packet = new RtpPacket;
   red_packet->header = packet->header;
   red_packet->length = packet->length + 1;  // 1 byte RED header.
@@ -65,7 +65,7 @@
   ++num_packets_;
   RtpPacket* red_packet = NextPacket(0, packet->length + 1);
   red_packet->data[1] &= ~0x80;  // Clear marker bit.
-  const int kHeaderLength = red_packet->header.header.headerLength;
+  const size_t kHeaderLength = red_packet->header.header.headerLength;
   SetRedHeader(red_packet, kFecPayloadType, kHeaderLength);
   memcpy(red_packet->data + kHeaderLength + 1, packet->data, packet->length);
   red_packet->length = kHeaderLength + 1 + packet->length;
@@ -73,7 +73,7 @@
 }
 
 void FrameGenerator::SetRedHeader(Packet* red_packet, uint8_t payload_type,
-                                  int header_length) const {
+                                  size_t header_length) const {
   // Replace pltype.
   red_packet->data[1] &= 0x80;             // Reset.
   red_packet->data[1] += kRedPayloadType;  // Replace.
diff --git a/webrtc/modules/rtp_rtcp/source/fec_test_helper.h b/webrtc/modules/rtp_rtcp/source/fec_test_helper.h
index e6426ea..8253961 100644
--- a/webrtc/modules/rtp_rtcp/source/fec_test_helper.h
+++ b/webrtc/modules/rtp_rtcp/source/fec_test_helper.h
@@ -51,7 +51,7 @@
   RtpPacket* BuildFecRedPacket(const Packet* packet);
 
   void SetRedHeader(Packet* red_packet, uint8_t payload_type,
-                    int header_length) const;
+                    size_t header_length) const;
 
  private:
   static void BuildRtpHeader(uint8_t* data, const RTPHeader* header);
diff --git a/webrtc/modules/rtp_rtcp/source/forward_error_correction.cc b/webrtc/modules/rtp_rtcp/source/forward_error_correction.cc
index b02ea08..9010e7e 100644
--- a/webrtc/modules/rtp_rtcp/source/forward_error_correction.cc
+++ b/webrtc/modules/rtp_rtcp/source/forward_error_correction.cc
@@ -693,7 +693,7 @@
 
   // XOR with RTP payload.
   // TODO(marpan/ajm): Are we doing more XORs than required here?
-  for (int32_t i = kRtpHeaderSize; i < src_packet->length; ++i) {
+  for (size_t i = kRtpHeaderSize; i < src_packet->length; ++i) {
     dst_packet->pkt->data[i] ^= src_packet->data[i];
   }
 }
@@ -816,7 +816,7 @@
   return 0;
 }
 
-uint16_t ForwardErrorCorrection::PacketOverhead() {
+size_t ForwardErrorCorrection::PacketOverhead() {
   return kFecHeaderSize + kUlpHeaderSizeLBitSet;
 }
 }  // namespace webrtc
diff --git a/webrtc/modules/rtp_rtcp/source/forward_error_correction.h b/webrtc/modules/rtp_rtcp/source/forward_error_correction.h
index bb790f3..a3b3fa0 100644
--- a/webrtc/modules/rtp_rtcp/source/forward_error_correction.h
+++ b/webrtc/modules/rtp_rtcp/source/forward_error_correction.h
@@ -49,7 +49,7 @@
     // reaches zero.
     virtual int32_t Release();
 
-    uint16_t length;               // Length of packet in bytes.
+    size_t length;               // Length of packet in bytes.
     uint8_t data[IP_PACKET_SIZE];  // Packet data.
 
    private:
@@ -200,7 +200,7 @@
   // Gets the size in bytes of the FEC/ULP headers, which must be accounted for
   // as packet overhead.
   // \return Packet overhead in bytes.
-  static uint16_t PacketOverhead();
+  static size_t PacketOverhead();
 
   // Reset internal states from last frame and clear the recovered_packet_list.
   // Frees all memory allocated by this class.
diff --git a/webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc b/webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc
index b852205..d6e557d 100644
--- a/webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/nack_rtx_unittest.cc
@@ -40,7 +40,7 @@
 
   virtual int32_t OnReceivedPayloadData(
       const uint8_t* data,
-      const uint16_t size,
+      const size_t size,
       const webrtc::WebRtcRTPHeader* rtp_header) OVERRIDE {
     if (!sequence_numbers_.empty())
       EXPECT_EQ(kTestSsrc, rtp_header->header.ssrc);
@@ -95,7 +95,7 @@
     packet_loss_ = 0;
   }
 
-  virtual int SendPacket(int channel, const void *data, int len) OVERRIDE {
+  virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE {
     count_++;
     const unsigned char* ptr = static_cast<const unsigned  char*>(data);
     uint32_t ssrc = (ptr[8] << 24) + (ptr[9] << 16) + (ptr[10] << 8) + ptr[11];
@@ -105,13 +105,13 @@
         sequence_number);
     if (packet_loss_ > 0) {
       if ((count_ % packet_loss_) == 0) {
-        return len;
+        return static_cast<int>(len);
       }
     } else if (count_ >= consecutive_drop_start_ &&
         count_ < consecutive_drop_end_) {
-      return len;
+      return static_cast<int>(len);
     }
-    int packet_length = len;
+    size_t packet_length = len;
     // TODO(pbos): Figure out why this needs to be initialized. Likely this
     // is hiding a bug either in test setup or other code.
     // https://code.google.com/p/webrtc/issues/detail?id=3183
@@ -143,12 +143,14 @@
                                           true)) {
       return -1;
     }
-    return len;
+    return static_cast<int>(len);
   }
 
-  virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE {
+  virtual int SendRTCPPacket(int channel,
+                             const void *data,
+                             size_t len) OVERRIDE {
     if (module_->IncomingRtcpPacket((const uint8_t*)data, len) == 0) {
-      return len;
+      return static_cast<int>(len);
     }
     return -1;
   }
@@ -214,7 +216,7 @@
                                                        0,
                                                        video_codec.maxBitrate));
 
-    for (int n = 0; n < payload_data_length; n++) {
+    for (size_t n = 0; n < payload_data_length; n++) {
       payload_data[n] = n % 10;
     }
   }
@@ -292,7 +294,7 @@
   RtxLoopBackTransport transport_;
   VerifyingRtxReceiver receiver_;
   uint8_t  payload_data[65000];
-  int payload_data_length;
+  size_t payload_data_length;
   SimulatedClock fake_clock;
 };
 
diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec.cc b/webrtc/modules/rtp_rtcp/source/producer_fec.cc
index 747cd89..a571a01 100644
--- a/webrtc/modules/rtp_rtcp/source/producer_fec.cc
+++ b/webrtc/modules/rtp_rtcp/source/producer_fec.cc
@@ -36,7 +36,7 @@
   ForwardErrorCorrection::Packet* pkt;
 };
 
-RedPacket::RedPacket(int length)
+RedPacket::RedPacket(size_t length)
     : data_(new uint8_t[length]),
       length_(length),
       header_length_(0) {
@@ -46,7 +46,7 @@
   delete [] data_;
 }
 
-void RedPacket::CreateHeader(const uint8_t* rtp_header, int header_length,
+void RedPacket::CreateHeader(const uint8_t* rtp_header, size_t header_length,
                              int red_pl_type, int pl_type) {
   assert(header_length + kREDForFECHeaderLength <= length_);
   memcpy(data_, rtp_header, header_length);
@@ -64,7 +64,7 @@
   RtpUtility::AssignUWord16ToBuffer(&data_[2], seq_num);
 }
 
-void RedPacket::AssignPayload(const uint8_t* payload, int length) {
+void RedPacket::AssignPayload(const uint8_t* payload, size_t length) {
   assert(header_length_ + length <= length_);
   memcpy(data_ + header_length_, payload, length);
 }
@@ -77,7 +77,7 @@
   return data_;
 }
 
-int RedPacket::length() const {
+size_t RedPacket::length() const {
   return length_;
 }
 
@@ -120,8 +120,8 @@
 }
 
 RedPacket* ProducerFec::BuildRedPacket(const uint8_t* data_buffer,
-                                       int payload_length,
-                                       int rtp_header_length,
+                                       size_t payload_length,
+                                       size_t rtp_header_length,
                                        int red_pl_type) {
   RedPacket* red_packet = new RedPacket(payload_length +
                                         kREDForFECHeaderLength +
@@ -134,8 +134,8 @@
 }
 
 int ProducerFec::AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
-                                            int payload_length,
-                                            int rtp_header_length) {
+                                            size_t payload_length,
+                                            size_t rtp_header_length) {
   assert(fec_packets_.empty());
   if (media_packets_fec_.empty()) {
     params_ = new_params_;
@@ -210,7 +210,7 @@
 RedPacket* ProducerFec::GetFecPacket(int red_pl_type,
                                      int fec_pl_type,
                                      uint16_t seq_num,
-                                     int rtp_header_length) {
+                                     size_t rtp_header_length) {
   if (fec_packets_.empty())
     return NULL;
   // Build FEC packet. The FEC packets in |fec_packets_| doesn't
diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec.h b/webrtc/modules/rtp_rtcp/source/producer_fec.h
index e3f9d1d..ec58bcf 100644
--- a/webrtc/modules/rtp_rtcp/source/producer_fec.h
+++ b/webrtc/modules/rtp_rtcp/source/producer_fec.h
@@ -21,20 +21,20 @@
 
 class RedPacket {
  public:
-  explicit RedPacket(int length);
+  explicit RedPacket(size_t length);
   ~RedPacket();
-  void CreateHeader(const uint8_t* rtp_header, int header_length,
+  void CreateHeader(const uint8_t* rtp_header, size_t header_length,
                     int red_pl_type, int pl_type);
   void SetSeqNum(int seq_num);
-  void AssignPayload(const uint8_t* payload, int length);
+  void AssignPayload(const uint8_t* payload, size_t length);
   void ClearMarkerBit();
   uint8_t* data() const;
-  int length() const;
+  size_t length() const;
 
  private:
   uint8_t* data_;
-  int length_;
-  int header_length_;
+  size_t length_;
+  size_t header_length_;
 };
 
 class ProducerFec {
@@ -46,13 +46,13 @@
                         int max_fec_frames);
 
   RedPacket* BuildRedPacket(const uint8_t* data_buffer,
-                            int payload_length,
-                            int rtp_header_length,
+                            size_t payload_length,
+                            size_t rtp_header_length,
                             int red_pl_type);
 
   int AddRtpPacketAndGenerateFec(const uint8_t* data_buffer,
-                                 int payload_length,
-                                 int rtp_header_length);
+                                 size_t payload_length,
+                                 size_t rtp_header_length);
 
   bool ExcessOverheadBelowMax();
 
@@ -63,7 +63,7 @@
   RedPacket* GetFecPacket(int red_pl_type,
                           int fec_pl_type,
                           uint16_t seq_num,
-                          int rtp_header_length);
+                          size_t rtp_header_length);
 
  private:
   void DeletePackets();
diff --git a/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc b/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc
index baa3827..d8b67a7 100644
--- a/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/producer_fec_unittest.cc
@@ -23,7 +23,7 @@
                   int fec_pltype,
                   RedPacket* packet,
                   bool marker_bit) {
-  EXPECT_GT(packet->length(), static_cast<int>(kRtpHeaderSize));
+  EXPECT_GT(packet->length(), kRtpHeaderSize);
   EXPECT_TRUE(packet->data() != NULL);
   uint8_t* data = packet->data();
   // Marker bit not set.
diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
index f063ce3..eeb6e31 100644
--- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.cc
@@ -123,7 +123,7 @@
     last_receive_time_ms_ = clock_->TimeInMilliseconds();
   }
 
-  uint16_t packet_oh = header.headerLength + header.paddingLength;
+  size_t packet_oh = header.headerLength + header.paddingLength;
 
   // Our measured overhead. Filter from RFC 5104 4.2.1.2:
   // avg_OH (new) = 15/16*avg_OH (old) + 1/16*pckt_OH,
@@ -303,7 +303,7 @@
 }
 
 void StreamStatisticianImpl::GetDataCounters(
-    uint32_t* bytes_received, uint32_t* packets_received) const {
+    size_t* bytes_received, uint32_t* packets_received) const {
   CriticalSectionScoped cs(stream_lock_.get());
   if (bytes_received) {
     *bytes_received = receive_counters_.bytes + receive_counters_.header_bytes +
diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h
index 40ca285..bef856f 100644
--- a/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h
+++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_impl.h
@@ -31,7 +31,7 @@
   virtual ~StreamStatisticianImpl() {}
 
   virtual bool GetStatistics(RtcpStatistics* statistics, bool reset) OVERRIDE;
-  virtual void GetDataCounters(uint32_t* bytes_received,
+  virtual void GetDataCounters(size_t* bytes_received,
                                uint32_t* packets_received) const OVERRIDE;
   virtual uint32_t BitrateReceived() const OVERRIDE;
   virtual void ResetStatistics() OVERRIDE;
@@ -80,7 +80,7 @@
   uint16_t received_seq_wraps_;
 
   // Current counter values.
-  uint16_t received_packet_overhead_;
+  size_t received_packet_overhead_;
   StreamDataCounters receive_counters_;
 
   // Counter values when we sent the last report.
diff --git a/webrtc/modules/rtp_rtcp/source/receive_statistics_unittest.cc b/webrtc/modules/rtp_rtcp/source/receive_statistics_unittest.cc
index 5b4d0dd..808a880 100644
--- a/webrtc/modules/rtp_rtcp/source/receive_statistics_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/receive_statistics_unittest.cc
@@ -16,8 +16,8 @@
 
 namespace webrtc {
 
-const int kPacketSize1 = 100;
-const int kPacketSize2 = 300;
+const size_t kPacketSize1 = 100;
+const size_t kPacketSize2 = 300;
 const uint32_t kSsrc1 = 1;
 const uint32_t kSsrc2 = 2;
 
@@ -56,7 +56,7 @@
       receive_statistics_->GetStatistician(kSsrc1);
   ASSERT_TRUE(statistician != NULL);
   EXPECT_GT(statistician->BitrateReceived(), 0u);
-  uint32_t bytes_received = 0;
+  size_t bytes_received = 0;
   uint32_t packets_received = 0;
   statistician->GetDataCounters(&bytes_received, &packets_received);
   EXPECT_EQ(200u, bytes_received);
@@ -125,7 +125,7 @@
   StreamStatistician* statistician =
       receive_statistics_->GetStatistician(kSsrc1);
   ASSERT_TRUE(statistician != NULL);
-  uint32_t bytes_received = 0;
+  size_t bytes_received = 0;
   uint32_t packets_received = 0;
   statistician->GetDataCounters(&bytes_received, &packets_received);
   EXPECT_EQ(200u, bytes_received);
@@ -234,8 +234,8 @@
 
   void ExpectMatches(uint32_t num_calls,
                      uint32_t ssrc,
-                     uint32_t bytes,
-                     uint32_t padding,
+                     size_t bytes,
+                     size_t padding,
                      uint32_t packets,
                      uint32_t retransmits,
                      uint32_t fec) {
@@ -257,8 +257,8 @@
   RtpTestCallback callback;
   receive_statistics_->RegisterRtpStatisticsCallback(&callback);
 
-  const uint32_t kHeaderLength = 20;
-  const uint32_t kPaddingLength = 9;
+  const size_t kHeaderLength = 20;
+  const size_t kPaddingLength = 9;
 
   // One packet of size kPacketSize1.
   header1_.headerLength = kHeaderLength;
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc
index 17671b7..6a7b7f9 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_format_remb_unittest.cc
@@ -32,14 +32,14 @@
 
   virtual int SendPacket(int /*channel*/,
                          const void* /*data*/,
-                         int /*len*/) OVERRIDE {
+                         size_t /*len*/) OVERRIDE {
     return -1;
   }
   virtual int SendRTCPPacket(int /*channel*/,
                              const void *packet,
-                             int packetLength) OVERRIDE {
+                             size_t packetLength) OVERRIDE {
     RTCPUtility::RTCPParserV2 rtcpParser((uint8_t*)packet,
-                                         (int32_t)packetLength,
+                                         packetLength,
                                          true); // Allow non-compound RTCP
 
     EXPECT_TRUE(rtcpParser.IsValid());
@@ -51,7 +51,7 @@
               rtcpPacketInformation.rtcpPacketTypeFlags & kRtcpRemb);
     EXPECT_EQ((uint32_t)1234,
               rtcpPacketInformation.receiverEstimatedMaxBitrate);
-    return packetLength;
+    return static_cast<int>(packetLength);
   }
  private:
   RTCPReceiver* rtcp_receiver_;
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
index 2a61573..d65157d 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
@@ -41,7 +41,7 @@
   }
   virtual int SendPacket(int /*ch*/,
                          const void* /*data*/,
-                         int /*len*/) OVERRIDE {
+                         size_t /*len*/) OVERRIDE {
     ADD_FAILURE();  // FAIL() gives a compile error.
     return -1;
   }
@@ -49,13 +49,13 @@
   // Injects an RTCP packet into the receiver.
   virtual int SendRTCPPacket(int /* ch */,
                              const void *packet,
-                             int packet_len) OVERRIDE {
+                             size_t packet_len) OVERRIDE {
     ADD_FAILURE();
     return 0;
   }
 
   virtual int OnReceivedPayloadData(const uint8_t* payloadData,
-                                    const uint16_t payloadSize,
+                                    const size_t payloadSize,
                                     const WebRtcRTPHeader* rtpHeader) OVERRIDE {
     ADD_FAILURE();
     return 0;
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
index 1752ab9..9991992 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -1633,7 +1633,7 @@
   {
       return -1;
   }
-  return SendToNetwork(rtcp_buffer, static_cast<uint16_t>(rtcp_length));
+  return SendToNetwork(rtcp_buffer, static_cast<size_t>(rtcp_length));
 }
 
 int RTCPSender::PrepareRTCP(const FeedbackState& feedback_state,
@@ -2000,7 +2000,7 @@
 
 int32_t
 RTCPSender::SendToNetwork(const uint8_t* dataBuffer,
-                          const uint16_t length)
+                          const size_t length)
 {
     CriticalSectionScoped lock(_criticalSectionTransport);
     if(_cbTransport)
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h
index 668c7c7..23f720f 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_sender.h
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender.h
@@ -56,7 +56,7 @@
    uint8_t send_payload_type;
    uint32_t frequency_hz;
    uint32_t packets_sent;
-   uint32_t media_bytes_sent;
+   size_t media_bytes_sent;
    uint32_t send_bitrate;
 
    uint32_t last_rr_ntp_secs;
@@ -177,7 +177,7 @@
     void GetPacketTypeCounter(RtcpPacketTypeCounter* packet_counter) const;
 
 private:
-    int32_t SendToNetwork(const uint8_t* dataBuffer, const uint16_t length);
+    int32_t SendToNetwork(const uint8_t* dataBuffer, const size_t length);
 
     int32_t WriteAllReportBlocksToBuffer(uint8_t* rtcpbuffer,
                             int pos,
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
index 44d4a2b..a72fe58 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_sender_unittest.cc
@@ -188,7 +188,7 @@
 void CreateRtpPacket(const bool marker_bit, const uint8_t payload,
     const uint16_t seq_num, const uint32_t timestamp,
     const uint32_t ssrc, uint8_t* array,
-    uint16_t* cur_pos) {
+    size_t* cur_pos) {
   ASSERT_TRUE(payload <= 127);
   array[(*cur_pos)++] = 0x80;
   array[(*cur_pos)++] = payload | (marker_bit ? 0x80 : 0);
@@ -229,15 +229,15 @@
   }
   virtual int SendPacket(int /*ch*/,
                          const void* /*data*/,
-                         int /*len*/) OVERRIDE {
+                         size_t /*len*/) OVERRIDE {
     return -1;
   }
 
   virtual int SendRTCPPacket(int /*ch*/,
                              const void *packet,
-                             int packet_len) OVERRIDE {
+                             size_t packet_len) OVERRIDE {
     RTCPUtility::RTCPParserV2 rtcpParser((uint8_t*)packet,
-                                         (int32_t)packet_len,
+                                         packet_len,
                                          true); // Allow non-compound RTCP
 
     EXPECT_TRUE(rtcpParser.IsValid());
@@ -262,11 +262,11 @@
     rtcp_packet_info_.ntp_frac = rtcpPacketInformation.ntp_frac;
     rtcp_packet_info_.rtp_timestamp = rtcpPacketInformation.rtp_timestamp;
 
-    return packet_len;
+    return static_cast<int>(packet_len);
   }
 
   virtual int OnReceivedPayloadData(const uint8_t* payloadData,
-                                    const uint16_t payloadSize,
+                                    const size_t payloadSize,
                                     const WebRtcRTPHeader* rtpHeader) OVERRIDE {
     return 0;
   }
@@ -357,10 +357,10 @@
   const uint16_t seq_num = 11111;
   const uint32_t timestamp = 1234567;
   const uint32_t ssrc = 0x11111111;
-  uint16_t packet_length = 0;
+  size_t packet_length = 0;
   CreateRtpPacket(marker_bit, payload, seq_num, timestamp, ssrc, packet_,
       &packet_length);
-  EXPECT_EQ(25, packet_length);
+  EXPECT_EQ(25u, packet_length);
 
   VideoCodec codec_inst;
   strncpy(codec_inst.plName, "VP8", webrtc::kPayloadNameSize - 1);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
index 9d19fde..5a3eb39 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_fec_unittest.cc
@@ -896,7 +896,7 @@
   for (int i = 0; i < num_media_packets; ++i) {
     media_packet = new ForwardErrorCorrection::Packet;
     media_packet_list_.push_back(media_packet);
-    media_packet->length = static_cast<uint16_t>(
+    media_packet->length = static_cast<size_t>(
         (static_cast<float>(rand()) / RAND_MAX) *
         (IP_PACKET_SIZE - kRtpHeaderSize - kTransportOverhead -
          ForwardErrorCorrection::PacketOverhead()));
@@ -928,7 +928,7 @@
     webrtc::RtpUtility::AssignUWord32ToBuffer(&media_packet->data[8], ssrc_);
 
     // Generate random values for payload.
-    for (int j = 12; j < media_packet->length; ++j) {
+    for (size_t j = 12; j < media_packet->length; ++j) {
       media_packet->data[j] = static_cast<uint8_t>(rand() % 256);
     }
     sequence_number++;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc
index ab210ec..1fa288a 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.cc
@@ -36,7 +36,7 @@
   payload_size_ = payload_size;
 
   // Fragment packets more evenly by splitting the payload up evenly.
-  uint32_t num_packets =
+  size_t num_packets =
       (payload_size_ + max_payload_len_ - 1) / max_payload_len_;
   payload_length_ = (payload_size_ + num_packets - 1) / num_packets;
   assert(payload_length_ <= max_payload_len_);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h b/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h
index 491cab5..2fd6aad 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_video_generic.h
@@ -57,7 +57,7 @@
   size_t payload_size_;
   const size_t max_payload_len_;
   FrameType frame_type_;
-  uint32_t payload_length_;
+  size_t payload_length_;
   uint8_t generic_header_;
 
   DISALLOW_COPY_AND_ASSIGN(RtpPacketizerGeneric);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc
index d74e04f..57ff74f 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc
@@ -22,17 +22,17 @@
 namespace {
 int ParseVP8PictureID(RTPVideoHeaderVP8* vp8,
                       const uint8_t** data,
-                      int* data_length,
-                      int* parsed_bytes) {
+                      size_t* data_length,
+                      size_t* parsed_bytes) {
   assert(vp8 != NULL);
-  if (*data_length <= 0)
+  if (*data_length == 0)
     return -1;
 
   vp8->pictureId = (**data & 0x7F);
   if (**data & 0x80) {
     (*data)++;
     (*parsed_bytes)++;
-    if (--(*data_length) <= 0)
+    if (--(*data_length) == 0)
       return -1;
     // PictureId is 15 bits
     vp8->pictureId = (vp8->pictureId << 8) + **data;
@@ -45,10 +45,10 @@
 
 int ParseVP8Tl0PicIdx(RTPVideoHeaderVP8* vp8,
                       const uint8_t** data,
-                      int* data_length,
-                      int* parsed_bytes) {
+                      size_t* data_length,
+                      size_t* parsed_bytes) {
   assert(vp8 != NULL);
-  if (*data_length <= 0)
+  if (*data_length == 0)
     return -1;
 
   vp8->tl0PicIdx = **data;
@@ -60,12 +60,12 @@
 
 int ParseVP8TIDAndKeyIdx(RTPVideoHeaderVP8* vp8,
                          const uint8_t** data,
-                         int* data_length,
-                         int* parsed_bytes,
+                         size_t* data_length,
+                         size_t* parsed_bytes,
                          bool has_tid,
                          bool has_key_idx) {
   assert(vp8 != NULL);
-  if (*data_length <= 0)
+  if (*data_length == 0)
     return -1;
 
   if (has_tid) {
@@ -83,11 +83,10 @@
 
 int ParseVP8Extension(RTPVideoHeaderVP8* vp8,
                       const uint8_t* data,
-                      int data_length) {
+                      size_t data_length) {
   assert(vp8 != NULL);
-  int parsed_bytes = 0;
-  if (data_length <= 0)
-    return -1;
+  assert(data_length > 0);
+  size_t parsed_bytes = 0;
   // Optional X field is present.
   bool has_picture_id = (*data & 0x80) ? true : false;   // I bit
   bool has_tl0_pic_idx = (*data & 0x40) ? true : false;  // L bit
@@ -118,12 +117,12 @@
       return -1;
     }
   }
-  return parsed_bytes;
+  return static_cast<int>(parsed_bytes);
 }
 
 int ParseVP8FrameSize(RtpDepacketizer::ParsedPayload* parsed_payload,
                       const uint8_t* data,
-                      int data_length) {
+                      size_t data_length) {
   assert(parsed_payload != NULL);
   if (parsed_payload->frame_type != kVideoFrameKey) {
     // Included in payload header for I-frames.
@@ -149,7 +148,7 @@
                                                                  false};
 
 RtpPacketizerVp8::RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info,
-                                   int max_payload_len,
+                                   size_t max_payload_len,
                                    VP8PacketizerMode mode)
     : payload_data_(NULL),
       payload_size_(0),
@@ -164,7 +163,7 @@
 }
 
 RtpPacketizerVp8::RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info,
-                                   int max_payload_len)
+                                   size_t max_payload_len)
     : payload_data_(NULL),
       payload_size_(0),
       part_info_(),
@@ -222,7 +221,7 @@
   if (bytes < 0) {
     return false;
   }
-  *bytes_to_send = bytes;
+  *bytes_to_send = static_cast<size_t>(bytes);
 
   *last_packet = packets_.empty();
   return true;
@@ -251,9 +250,9 @@
   return "RtpPacketizerVp8";
 }
 
-int RtpPacketizerVp8::CalcNextSize(int max_payload_len,
-                                   int remaining_bytes,
-                                   bool split_payload) const {
+size_t RtpPacketizerVp8::CalcNextSize(size_t max_payload_len,
+                                      size_t remaining_bytes,
+                                      bool split_payload) const {
   if (max_payload_len == 0 || remaining_bytes == 0) {
     return 0;
   }
@@ -265,10 +264,10 @@
     // Balance payload sizes to produce (almost) equal size
     // fragments.
     // Number of fragments for remaining_bytes:
-    int num_frags = remaining_bytes / max_payload_len + 1;
+    size_t num_frags = remaining_bytes / max_payload_len + 1;
     // Number of bytes in this fragment:
-    return static_cast<int>(static_cast<double>(remaining_bytes) / num_frags +
-                            0.5);
+    return static_cast<size_t>(
+        static_cast<double>(remaining_bytes) / num_frags + 0.5);
   } else {
     return max_payload_len >= remaining_bytes ? remaining_bytes
                                               : max_payload_len;
@@ -282,22 +281,22 @@
     // descriptor and one payload byte. Return an error.
     return -1;
   }
-  int total_bytes_processed = 0;
+  size_t total_bytes_processed = 0;
   bool start_on_new_fragment = true;
   bool beginning = true;
-  int part_ix = 0;
+  size_t part_ix = 0;
   while (total_bytes_processed < payload_size_) {
-    int packet_bytes = 0;       // How much data to send in this packet.
+    size_t packet_bytes = 0;    // How much data to send in this packet.
     bool split_payload = true;  // Splitting of partitions is initially allowed.
-    int remaining_in_partition = part_info_.fragmentationOffset[part_ix] -
+    size_t remaining_in_partition = part_info_.fragmentationOffset[part_ix] -
                                  total_bytes_processed +
                                  part_info_.fragmentationLength[part_ix];
-    int rem_payload_len =
+    size_t rem_payload_len =
         max_payload_len_ -
         (vp8_fixed_payload_descriptor_bytes_ + PayloadDescriptorExtraLength());
-    int first_partition_in_packet = part_ix;
+    size_t first_partition_in_packet = part_ix;
 
-    while (int next_size = CalcNextSize(
+    while (size_t next_size = CalcNextSize(
                rem_payload_len, remaining_in_partition, split_payload)) {
       packet_bytes += next_size;
       rem_payload_len -= next_size;
@@ -348,44 +347,44 @@
     return -1;
   }
   std::vector<int> partition_decision;
-  const int overhead =
+  const size_t overhead =
       vp8_fixed_payload_descriptor_bytes_ + PayloadDescriptorExtraLength();
-  const uint32_t max_payload_len = max_payload_len_ - overhead;
+  const size_t max_payload_len = max_payload_len_ - overhead;
   int min_size, max_size;
   AggregateSmallPartitions(&partition_decision, &min_size, &max_size);
 
-  int total_bytes_processed = 0;
-  int part_ix = 0;
+  size_t total_bytes_processed = 0;
+  size_t part_ix = 0;
   while (part_ix < num_partitions_) {
     if (partition_decision[part_ix] == -1) {
       // Split large partitions.
-      int remaining_partition = part_info_.fragmentationLength[part_ix];
-      int num_fragments = Vp8PartitionAggregator::CalcNumberOfFragments(
+      size_t remaining_partition = part_info_.fragmentationLength[part_ix];
+      size_t num_fragments = Vp8PartitionAggregator::CalcNumberOfFragments(
           remaining_partition, max_payload_len, overhead, min_size, max_size);
-      const int packet_bytes =
+      const size_t packet_bytes =
           (remaining_partition + num_fragments - 1) / num_fragments;
-      for (int n = 0; n < num_fragments; ++n) {
-        const int this_packet_bytes = packet_bytes < remaining_partition
-                                          ? packet_bytes
-                                          : remaining_partition;
+      for (size_t n = 0; n < num_fragments; ++n) {
+        const size_t this_packet_bytes = packet_bytes < remaining_partition
+                                             ? packet_bytes
+                                             : remaining_partition;
         QueuePacket(
             total_bytes_processed, this_packet_bytes, part_ix, (n == 0));
         remaining_partition -= this_packet_bytes;
         total_bytes_processed += this_packet_bytes;
-        if (this_packet_bytes < min_size) {
+        if (static_cast<int>(this_packet_bytes) < min_size) {
           min_size = this_packet_bytes;
         }
-        if (this_packet_bytes > max_size) {
+        if (static_cast<int>(this_packet_bytes) > max_size) {
           max_size = this_packet_bytes;
         }
       }
       assert(remaining_partition == 0);
       ++part_ix;
     } else {
-      int this_packet_bytes = 0;
-      const int first_partition_in_packet = part_ix;
+      size_t this_packet_bytes = 0;
+      const size_t first_partition_in_packet = part_ix;
       const int aggregation_index = partition_decision[part_ix];
-      while (static_cast<size_t>(part_ix) < partition_decision.size() &&
+      while (part_ix < partition_decision.size() &&
              partition_decision[part_ix] == aggregation_index) {
         // Collect all partitions that were aggregated into the same packet.
         this_packet_bytes += part_info_.fragmentationLength[part_ix];
@@ -410,11 +409,11 @@
   *max_size = -1;
   assert(partition_vec);
   partition_vec->assign(num_partitions_, -1);
-  const int overhead =
+  const size_t overhead =
       vp8_fixed_payload_descriptor_bytes_ + PayloadDescriptorExtraLength();
-  const uint32_t max_payload_len = max_payload_len_ - overhead;
-  int first_in_set = 0;
-  int last_in_set = 0;
+  const size_t max_payload_len = max_payload_len_ - overhead;
+  size_t first_in_set = 0;
+  size_t last_in_set = 0;
   int num_aggregate_packets = 0;
   // Find sets of partitions smaller than max_payload_len_.
   while (first_in_set < num_partitions_) {
@@ -434,7 +433,7 @@
       Vp8PartitionAggregator::ConfigVec optimal_config =
           aggregator.FindOptimalConfiguration(max_payload_len, overhead);
       aggregator.CalcMinMax(optimal_config, min_size, max_size);
-      for (int i = first_in_set, j = 0; i <= last_in_set; ++i, ++j) {
+      for (size_t i = first_in_set, j = 0; i <= last_in_set; ++i, ++j) {
         // Transfer configuration for this set of partitions to the joint
         // partition vector representing all partitions in the frame.
         (*partition_vec)[i] = num_aggregate_packets + optimal_config[j];
@@ -446,9 +445,9 @@
   }
 }
 
-void RtpPacketizerVp8::QueuePacket(int start_pos,
-                                   int packet_size,
-                                   int first_partition_in_packet,
+void RtpPacketizerVp8::QueuePacket(size_t start_pos,
+                                   size_t packet_size,
+                                   size_t first_partition_in_packet,
                                    bool start_on_new_fragment) {
   // Write info to packet info struct and store in packet info queue.
   InfoStruct packet_info;
@@ -461,7 +460,7 @@
 
 int RtpPacketizerVp8::WriteHeaderAndPayload(const InfoStruct& packet_info,
                                             uint8_t* buffer,
-                                            int buffer_length) const {
+                                            size_t buffer_length) const {
   // Write the VP8 payload descriptor.
   //       0
   //       0 1 2 3 4 5 6 7 8
@@ -488,6 +487,8 @@
   buffer[0] |= (packet_info.first_partition_ix & kPartIdField);
 
   const int extension_length = WriteExtensionFields(buffer, buffer_length);
+  if (extension_length < 0)
+    return -1;
 
   memcpy(&buffer[vp8_fixed_payload_descriptor_bytes_ + extension_length],
          &payload_data_[packet_info.payload_start_pos],
@@ -499,8 +500,8 @@
 }
 
 int RtpPacketizerVp8::WriteExtensionFields(uint8_t* buffer,
-                                           int buffer_length) const {
-  int extension_length = 0;
+                                           size_t buffer_length) const {
+  size_t extension_length = 0;
   if (XFieldPresent()) {
     uint8_t* x_field = buffer + vp8_fixed_payload_descriptor_bytes_;
     *x_field = 0;
@@ -525,14 +526,16 @@
     }
     assert(extension_length == PayloadDescriptorExtraLength());
   }
-  return extension_length;
+  return static_cast<int>(extension_length);
 }
 
 int RtpPacketizerVp8::WritePictureIDFields(uint8_t* x_field,
                                            uint8_t* buffer,
-                                           int buffer_length,
-                                           int* extension_length) const {
+                                           size_t buffer_length,
+                                           size_t* extension_length) const {
   *x_field |= kIBit;
+  assert(buffer_length >=
+      vp8_fixed_payload_descriptor_bytes_ + *extension_length);
   const int pic_id_length = WritePictureID(
       buffer + vp8_fixed_payload_descriptor_bytes_ + *extension_length,
       buffer_length - vp8_fixed_payload_descriptor_bytes_ - *extension_length);
@@ -542,9 +545,10 @@
   return 0;
 }
 
-int RtpPacketizerVp8::WritePictureID(uint8_t* buffer, int buffer_length) const {
+int RtpPacketizerVp8::WritePictureID(uint8_t* buffer,
+                                     size_t buffer_length) const {
   const uint16_t pic_id = static_cast<uint16_t>(hdr_info_.pictureId);
-  int picture_id_len = PictureIdLength();
+  size_t picture_id_len = PictureIdLength();
   if (picture_id_len > buffer_length)
     return -1;
   if (picture_id_len == 2) {
@@ -553,13 +557,13 @@
   } else if (picture_id_len == 1) {
     buffer[0] = pic_id & 0x7F;
   }
-  return picture_id_len;
+  return static_cast<int>(picture_id_len);
 }
 
 int RtpPacketizerVp8::WriteTl0PicIdxFields(uint8_t* x_field,
                                            uint8_t* buffer,
-                                           int buffer_length,
-                                           int* extension_length) const {
+                                           size_t buffer_length,
+                                           size_t* extension_length) const {
   if (buffer_length <
       vp8_fixed_payload_descriptor_bytes_ + *extension_length + 1) {
     return -1;
@@ -573,8 +577,8 @@
 
 int RtpPacketizerVp8::WriteTIDAndKeyIdxFields(uint8_t* x_field,
                                               uint8_t* buffer,
-                                              int buffer_length,
-                                              int* extension_length) const {
+                                              size_t buffer_length,
+                                              size_t* extension_length) const {
   if (buffer_length <
       vp8_fixed_payload_descriptor_bytes_ + *extension_length + 1) {
     return -1;
@@ -596,8 +600,8 @@
   return 0;
 }
 
-int RtpPacketizerVp8::PayloadDescriptorExtraLength() const {
-  int length_bytes = PictureIdLength();
+size_t RtpPacketizerVp8::PayloadDescriptorExtraLength() const {
+  size_t length_bytes = PictureIdLength();
   if (TL0PicIdxFieldPresent())
     ++length_bytes;
   if (TIDFieldPresent() || KeyIdxFieldPresent())
@@ -607,7 +611,7 @@
   return length_bytes;
 }
 
-int RtpPacketizerVp8::PictureIdLength() const {
+size_t RtpPacketizerVp8::PictureIdLength() const {
   if (hdr_info_.pictureId == kNoPictureId) {
     return 0;
   }
@@ -693,6 +697,10 @@
 
   // Advance payload_data and decrease remaining payload size.
   payload_data++;
+  if (payload_data_length <= 1) {
+    LOG(LS_ERROR) << "Error parsing VP8 payload descriptor!";
+    return false;
+  }
   payload_data_length--;
 
   if (extension) {
@@ -704,15 +712,14 @@
       return false;
     payload_data += parsed_bytes;
     payload_data_length -= parsed_bytes;
-  }
-
-  if (payload_data_length <= 0) {
-    LOG(LS_ERROR) << "Error parsing VP8 payload descriptor!";
-    return false;
+    if (payload_data_length == 0) {
+      LOG(LS_ERROR) << "Error parsing VP8 payload descriptor!";
+      return false;
+    }
   }
 
   // Read P bit from payload header (only at beginning of first partition).
-  if (payload_data_length > 0 && beginning_of_partition && partition_id == 0) {
+  if (beginning_of_partition && partition_id == 0) {
     parsed_payload->frame_type =
         (*payload_data & 0x01) ? kVideoFrameDelta : kVideoFrameKey;
   } else {
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h
index 4b7a6a2..dab7921 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h
@@ -51,12 +51,12 @@
   // Initialize with payload from encoder and fragmentation info.
   // The payload_data must be exactly one encoded VP8 frame.
   RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info,
-                   int max_payload_len,
+                   size_t max_payload_len,
                    VP8PacketizerMode mode);
 
   // Initialize without fragmentation info. Mode kEqualSize will be used.
   // The payload_data must be exactly one encoded VP8 frame.
-  RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, int max_payload_len);
+  RtpPacketizerVp8(const RTPVideoHeaderVP8& hdr_info, size_t max_payload_len);
 
   virtual ~RtpPacketizerVp8();
 
@@ -88,10 +88,10 @@
 
  private:
   typedef struct {
-    int payload_start_pos;
-    int size;
+    size_t payload_start_pos;
+    size_t size;
     bool first_fragment;
-    int first_partition_ix;
+    size_t first_partition_ix;
   } InfoStruct;
   typedef std::queue<InfoStruct> InfoQueue;
   enum AggregationMode {
@@ -115,9 +115,9 @@
   static const int kYBit = 0x20;
 
   // Calculate size of next chunk to send. Returns 0 if none can be sent.
-  int CalcNextSize(int max_payload_len,
-                   int remaining_bytes,
-                   bool split_payload) const;
+  size_t CalcNextSize(size_t max_payload_len,
+                      size_t remaining_bytes,
+                      bool split_payload) const;
 
   // Calculate all packet sizes and load to packet info queue.
   int GeneratePackets();
@@ -140,9 +140,9 @@
                                 int* max_size);
 
   // Insert packet into packet queue.
-  void QueuePacket(int start_pos,
-                   int packet_size,
-                   int first_partition_in_packet,
+  void QueuePacket(size_t start_pos,
+                   size_t packet_size,
+                   size_t first_partition_in_packet,
                    bool start_on_new_fragment);
 
   // Write the payload header and copy the payload to the buffer.
@@ -150,47 +150,47 @@
   // and what to write in the header fields.
   int WriteHeaderAndPayload(const InfoStruct& packet_info,
                             uint8_t* buffer,
-                            int buffer_length) const;
+                            size_t buffer_length) const;
 
   // Write the X field and the appropriate extension fields to buffer.
   // The function returns the extension length (including X field), or -1
   // on error.
-  int WriteExtensionFields(uint8_t* buffer, int buffer_length) const;
+  int WriteExtensionFields(uint8_t* buffer, size_t buffer_length) const;
 
   // Set the I bit in the x_field, and write PictureID to the appropriate
   // position in buffer. The function returns 0 on success, -1 otherwise.
   int WritePictureIDFields(uint8_t* x_field,
                            uint8_t* buffer,
-                           int buffer_length,
-                           int* extension_length) const;
+                           size_t buffer_length,
+                           size_t* extension_length) const;
 
   // Set the L bit in the x_field, and write Tl0PicIdx to the appropriate
   // position in buffer. The function returns 0 on success, -1 otherwise.
   int WriteTl0PicIdxFields(uint8_t* x_field,
                            uint8_t* buffer,
-                           int buffer_length,
-                           int* extension_length) const;
+                           size_t buffer_length,
+                           size_t* extension_length) const;
 
   // Set the T and K bits in the x_field, and write TID, Y and KeyIdx to the
   // appropriate position in buffer. The function returns 0 on success,
   // -1 otherwise.
   int WriteTIDAndKeyIdxFields(uint8_t* x_field,
                               uint8_t* buffer,
-                              int buffer_length,
-                              int* extension_length) const;
+                              size_t buffer_length,
+                              size_t* extension_length) const;
 
   // Write the PictureID from codec_specific_info_ to buffer. One or two
   // bytes are written, depending on magnitude of PictureID. The function
   // returns the number of bytes written.
-  int WritePictureID(uint8_t* buffer, int buffer_length) const;
+  int WritePictureID(uint8_t* buffer, size_t buffer_length) const;
 
   // Calculate and return length (octets) of the variable header fields in
   // the next header (i.e., header length in addition to vp8_header_bytes_).
-  int PayloadDescriptorExtraLength() const;
+  size_t PayloadDescriptorExtraLength() const;
 
   // Calculate and return length (octets) of PictureID field in the next
   // header. Can be 0, 1, or 2.
-  int PictureIdLength() const;
+  size_t PictureIdLength() const;
 
   // Check whether each of the optional fields will be included in the header.
   bool XFieldPresent() const;
@@ -200,16 +200,16 @@
   bool PictureIdPresent() const { return (PictureIdLength() > 0); }
 
   const uint8_t* payload_data_;
-  int payload_size_;
+  size_t payload_size_;
   RTPFragmentationHeader part_info_;
-  const int vp8_fixed_payload_descriptor_bytes_;  // Length of VP8 payload
-                                                  // descriptors's fixed part.
+  const size_t vp8_fixed_payload_descriptor_bytes_;  // Length of VP8 payload
+                                                     // descriptors' fixed part.
   const AggregationMode aggr_mode_;
   const bool balance_;
   const bool separate_first_;
   const RTPVideoHeaderVP8 hdr_info_;
-  int num_partitions_;
-  const int max_payload_len_;
+  size_t num_partitions_;
+  const size_t max_payload_len_;
   InfoQueue packets_;
   bool packets_calculated_;
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
index 549512b..a62f496 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
@@ -35,25 +35,25 @@
   delete [] buffer_;
 }
 
-bool RtpFormatVp8TestHelper::Init(const int* partition_sizes,
-                                  int num_partitions) {
+bool RtpFormatVp8TestHelper::Init(const size_t* partition_sizes,
+                                  size_t num_partitions) {
   if (inited_) return false;
   fragmentation_ = new RTPFragmentationHeader;
   fragmentation_->VerifyAndAllocateFragmentationHeader(num_partitions);
   payload_size_ = 0;
   // Calculate sum payload size.
-  for (int p = 0; p < num_partitions; ++p) {
+  for (size_t p = 0; p < num_partitions; ++p) {
     payload_size_ += partition_sizes[p];
   }
   buffer_size_ = payload_size_ + 6;  // Add space for payload descriptor.
   payload_data_ = new uint8_t[payload_size_];
   buffer_ = new uint8_t[buffer_size_];
-  int j = 0;
+  size_t j = 0;
   // Loop through the partitions again.
-  for (int p = 0; p < num_partitions; ++p) {
+  for (size_t p = 0; p < num_partitions; ++p) {
     fragmentation_->fragmentationLength[p] = partition_sizes[p];
     fragmentation_->fragmentationOffset[p] = j;
-    for (int i = 0; i < partition_sizes[p]; ++i) {
+    for (size_t i = 0; i < partition_sizes[p]; ++i) {
       assert(j < payload_size_);
       payload_data_[j++] = p;  // Set the payload value to the partition index.
     }
@@ -65,14 +65,14 @@
 
 void RtpFormatVp8TestHelper::GetAllPacketsAndCheck(
     RtpPacketizerVp8* packetizer,
-    const int* expected_sizes,
+    const size_t* expected_sizes,
     const int* expected_part,
     const bool* expected_frag_start,
-    int expected_num_packets) {
+    size_t expected_num_packets) {
   ASSERT_TRUE(inited_);
   size_t send_bytes = 0;
   bool last = false;
-  for (int i = 0; i < expected_num_packets; ++i) {
+  for (size_t i = 0; i < expected_num_packets; ++i) {
     std::ostringstream ss;
     ss << "Checking packet " << i;
     SCOPED_TRACE(ss.str());
@@ -222,8 +222,8 @@
 
 // Verify that the payload (i.e., after the headers) of the packet stored in
 // buffer_ is identical to the expected (as found in data_ptr_).
-void RtpFormatVp8TestHelper::CheckPayload(int payload_end) {
-  for (int i = payload_start_; i < payload_end; ++i, ++data_ptr_)
+void RtpFormatVp8TestHelper::CheckPayload(size_t payload_end) {
+  for (size_t i = payload_start_; i < payload_end; ++i, ++data_ptr_)
     EXPECT_EQ(buffer_[i], *data_ptr_);
 }
 
@@ -236,8 +236,8 @@
 
 // Verify the contents of a packet. Check the length versus expected_bytes,
 // the header, payload, and "last" flag.
-void RtpFormatVp8TestHelper::CheckPacket(int send_bytes,
-                                         int expect_bytes,
+void RtpFormatVp8TestHelper::CheckPacket(size_t send_bytes,
+                                         size_t expect_bytes,
                                          bool last,
                                          bool frag_start) {
   EXPECT_EQ(expect_bytes, send_bytes);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h
index 22e6803..2454fb7 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.h
@@ -31,17 +31,17 @@
  public:
   explicit RtpFormatVp8TestHelper(const RTPVideoHeaderVP8* hdr);
   ~RtpFormatVp8TestHelper();
-  bool Init(const int* partition_sizes, int num_partitions);
+  bool Init(const size_t* partition_sizes, size_t num_partitions);
   void GetAllPacketsAndCheck(RtpPacketizerVp8* packetizer,
-                             const int* expected_sizes,
+                             const size_t* expected_sizes,
                              const int* expected_part,
                              const bool* expected_frag_start,
-                             int expected_num_packets);
+                             size_t expected_num_packets);
 
   uint8_t* payload_data() const { return payload_data_; }
-  int payload_size() const { return payload_size_; }
+  size_t payload_size() const { return payload_size_; }
   RTPFragmentationHeader* fragmentation() const { return fragmentation_; }
-  int buffer_size() const { return buffer_size_; }
+  size_t buffer_size() const { return buffer_size_; }
   void set_sloppy_partitioning(bool value) { sloppy_partitioning_ = value; }
 
  private:
@@ -49,9 +49,9 @@
   void CheckPictureID();
   void CheckTl0PicIdx();
   void CheckTIDAndKeyIdx();
-  void CheckPayload(int payload_end);
+  void CheckPayload(size_t payload_end);
   void CheckLast(bool last) const;
-  void CheckPacket(int send_bytes, int expect_bytes, bool last,
+  void CheckPacket(size_t send_bytes, size_t expect_bytes, bool last,
                    bool frag_start);
 
   uint8_t* payload_data_;
@@ -60,8 +60,8 @@
   RTPFragmentationHeader* fragmentation_;
   const RTPVideoHeaderVP8* hdr_info_;
   int payload_start_;
-  int payload_size_;
-  int buffer_size_;
+  size_t payload_size_;
+  size_t buffer_size_;
   bool sloppy_partitioning_;
   bool inited_;
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
index 4382ac2..84b880d 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
@@ -80,7 +80,7 @@
  protected:
   RtpPacketizerVp8Test() : helper_(NULL) {}
   virtual void TearDown() { delete helper_; }
-  bool Init(const int* partition_sizes, int num_partitions) {
+  bool Init(const size_t* partition_sizes, size_t num_partitions) {
     hdr_info_.pictureId = kNoPictureId;
     hdr_info_.nonReference = false;
     hdr_info_.temporalIdx = kNoTemporalIdx;
@@ -98,23 +98,23 @@
 };
 
 TEST_F(RtpPacketizerVp8Test, TestStrictMode) {
-  const int kSizeVector[] = {10, 8, 27};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {10, 8, 27};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.pictureId = 200;  // > 0x7F should produce 2-byte PictureID.
-  const int kMaxSize = 13;
+  const size_t kMaxSize = 13;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kStrict);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // The expected sizes are obtained by running a verified good implementation.
-  const int kExpectedSizes[] = {9, 9, 12, 11, 11, 11, 10};
+  const size_t kExpectedSizes[] = {9, 9, 12, 11, 11, 11, 10};
   const int kExpectedPart[] = {0, 0, 1, 2, 2, 2, 2};
   const bool kExpectedFragStart[] = {true,  false, true, true,
                                      false, false, false};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -126,22 +126,22 @@
 }
 
 TEST_F(RtpPacketizerVp8Test, TestAggregateMode) {
-  const int kSizeVector[] = {60, 10, 10};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {60, 10, 10};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.pictureId = 20;  // <= 0x7F should produce 1-byte PictureID.
-  const int kMaxSize = 25;
+  const size_t kMaxSize = 25;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // The expected sizes are obtained by running a verified good implementation.
-  const int kExpectedSizes[] = {23, 23, 23, 23};
+  const size_t kExpectedSizes[] = {23, 23, 23, 23};
   const int kExpectedPart[] = {0, 0, 0, 1};
   const bool kExpectedFragStart[] = {true, false, false, true};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -153,22 +153,22 @@
 }
 
 TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions1) {
-  const int kSizeVector[] = {1600, 200, 200, 200, 200, 200, 200, 200, 200};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {1600, 200, 200, 200, 200, 200, 200, 200, 200};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.pictureId = 20;  // <= 0x7F should produce 1-byte PictureID.
-  const int kMaxSize = 1500;
+  const size_t kMaxSize = 1500;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // The expected sizes are obtained by running a verified good implementation.
-  const int kExpectedSizes[] = {803, 803, 803, 803};
+  const size_t kExpectedSizes[] = {803, 803, 803, 803};
   const int kExpectedPart[] = {0, 0, 1, 5};
   const bool kExpectedFragStart[] = {true, false, true, true};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -180,22 +180,22 @@
 }
 
 TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions2) {
-  const int kSizeVector[] = {1599, 200, 200, 200, 1600, 200, 200, 200, 200};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {1599, 200, 200, 200, 1600, 200, 200, 200, 200};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.pictureId = 20;  // <= 0x7F should produce 1-byte PictureID.
-  const int kMaxSize = 1500;
+  const size_t kMaxSize = 1500;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // The expected sizes are obtained by running a verified good implementation.
-  const int kExpectedSizes[] = {803, 802, 603, 803, 803, 803};
+  const size_t kExpectedSizes[] = {803, 802, 603, 803, 803, 803};
   const int kExpectedPart[] = {0, 0, 1, 4, 4, 5};
   const bool kExpectedFragStart[] = {true, false, true, true, false, true};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -207,22 +207,22 @@
 }
 
 TEST_F(RtpPacketizerVp8Test, TestAggregateModeTwoLargePartitions) {
-  const int kSizeVector[] = {1654, 2268};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {1654, 2268};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.pictureId = 20;  // <= 0x7F should produce 1-byte PictureID.
-  const int kMaxSize = 1460;
+  const size_t kMaxSize = 1460;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // The expected sizes are obtained by running a verified good implementation.
-  const int kExpectedSizes[] = {830, 830, 1137, 1137};
+  const size_t kExpectedSizes[] = {830, 830, 1137, 1137};
   const int kExpectedPart[] = {0, 0, 1, 1};
   const bool kExpectedFragStart[] = {true, false, true, false};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -235,22 +235,22 @@
 
 // Verify that EqualSize mode is forced if fragmentation info is missing.
 TEST_F(RtpPacketizerVp8Test, TestEqualSizeModeFallback) {
-  const int kSizeVector[] = {10, 10, 10};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {10, 10, 10};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
-  hdr_info_.pictureId = 200;  // > 0x7F should produce 2-byte PictureID
-  const int kMaxSize = 12;    // Small enough to produce 4 packets.
+  hdr_info_.pictureId = 200;   // > 0x7F should produce 2-byte PictureID
+  const size_t kMaxSize = 12;  // Small enough to produce 4 packets.
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize);
   packetizer.SetPayloadData(
       helper_->payload_data(), helper_->payload_size(), NULL);
 
   // Expecting three full packets, and one with the remainder.
-  const int kExpectedSizes[] = {12, 11, 12, 11};
+  const size_t kExpectedSizes[] = {12, 11, 12, 11};
   const int kExpectedPart[] = {0, 0, 0, 0};  // Always 0 for equal size mode.
   // Frag start only true for first packet in equal size mode.
   const bool kExpectedFragStart[] = {true, false, false, false};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -264,22 +264,22 @@
 
 // Verify that non-reference bit is set. EqualSize mode fallback is expected.
 TEST_F(RtpPacketizerVp8Test, TestNonReferenceBit) {
-  const int kSizeVector[] = {10, 10, 10};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {10, 10, 10};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.nonReference = true;
-  const int kMaxSize = 25;  // Small enough to produce two packets.
+  const size_t kMaxSize = 25;  // Small enough to produce two packets.
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize);
   packetizer.SetPayloadData(
       helper_->payload_data(), helper_->payload_size(), NULL);
 
   // EqualSize mode => First packet full; other not.
-  const int kExpectedSizes[] = {16, 16};
+  const size_t kExpectedSizes[] = {16, 16};
   const int kExpectedPart[] = {0, 0};  // Always 0 for equal size mode.
   // Frag start only true for first packet in equal size mode.
   const bool kExpectedFragStart[] = {true, false};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -293,25 +293,25 @@
 
 // Verify Tl0PicIdx and TID fields, and layerSync bit.
 TEST_F(RtpPacketizerVp8Test, TestTl0PicIdxAndTID) {
-  const int kSizeVector[] = {10, 10, 10};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {10, 10, 10};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.tl0PicIdx = 117;
   hdr_info_.temporalIdx = 2;
   hdr_info_.layerSync = true;
   // kMaxSize is only limited by allocated buffer size.
-  const int kMaxSize = helper_->buffer_size();
+  const size_t kMaxSize = helper_->buffer_size();
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // Expect one single packet of payload_size() + 4 bytes header.
-  const int kExpectedSizes[1] = {helper_->payload_size() + 4};
+  const size_t kExpectedSizes[1] = {helper_->payload_size() + 4};
   const int kExpectedPart[1] = {0};  // Packet starts with partition 0.
   const bool kExpectedFragStart[1] = {true};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -324,23 +324,23 @@
 
 // Verify KeyIdx field.
 TEST_F(RtpPacketizerVp8Test, TestKeyIdx) {
-  const int kSizeVector[] = {10, 10, 10};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {10, 10, 10};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.keyIdx = 17;
   // kMaxSize is only limited by allocated buffer size.
-  const int kMaxSize = helper_->buffer_size();
+  const size_t kMaxSize = helper_->buffer_size();
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // Expect one single packet of payload_size() + 3 bytes header.
-  const int kExpectedSizes[1] = {helper_->payload_size() + 3};
+  const size_t kExpectedSizes[1] = {helper_->payload_size() + 3};
   const int kExpectedPart[1] = {0};  // Packet starts with partition 0.
   const bool kExpectedFragStart[1] = {true};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
@@ -353,24 +353,24 @@
 
 // Verify TID field and KeyIdx field in combination.
 TEST_F(RtpPacketizerVp8Test, TestTIDAndKeyIdx) {
-  const int kSizeVector[] = {10, 10, 10};
-  const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
+  const size_t kSizeVector[] = {10, 10, 10};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
   hdr_info_.temporalIdx = 1;
   hdr_info_.keyIdx = 5;
   // kMaxSize is only limited by allocated buffer size.
-  const int kMaxSize = helper_->buffer_size();
+  const size_t kMaxSize = helper_->buffer_size();
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // Expect one single packet of payload_size() + 3 bytes header.
-  const int kExpectedSizes[1] = {helper_->payload_size() + 3};
+  const size_t kExpectedSizes[1] = {helper_->payload_size() + 3};
   const int kExpectedPart[1] = {0};  // Packet starts with partition 0.
   const bool kExpectedFragStart[1] = {true};
-  const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
+  const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc b/webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc
index 9a1836e..a19eeaa 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc
@@ -105,9 +105,9 @@
   return -1;
 }
 
-uint16_t RtpHeaderExtensionMap::GetTotalLengthInBytes() const {
+size_t RtpHeaderExtensionMap::GetTotalLengthInBytes() const {
   // Get length for each extension block.
-  uint16_t length = 0;
+  size_t length = 0;
   std::map<uint8_t, HeaderExtension*>::const_iterator it =
       extensionMap_.begin();
   while (it != extensionMap_.end()) {
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h b/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h
index edffe8a..335d0a1 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_header_extension.h
@@ -68,7 +68,7 @@
 
   int32_t GetId(const RTPExtensionType type, uint8_t* id) const;
 
-  uint16_t GetTotalLengthInBytes() const;
+  size_t GetTotalLengthInBytes() const;
 
   int32_t GetLengthUntilBlockStartInBytes(const RTPExtensionType type) const;
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_header_extension_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_header_extension_unittest.cc
index 90d3f64..d8387e8 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_header_extension_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_header_extension_unittest.cc
@@ -59,7 +59,7 @@
 }
 
 TEST_F(RtpHeaderExtensionTest, GetTotalLength) {
-  EXPECT_EQ(0, map_.GetTotalLengthInBytes());
+  EXPECT_EQ(0u, map_.GetTotalLengthInBytes());
   EXPECT_EQ(0, map_.Register(kRtpExtensionTransmissionTimeOffset, kId));
   EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength,
             map_.GetTotalLengthInBytes());
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc
index e3515f4..2546ac0 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.cc
@@ -94,7 +94,7 @@
 }
 
 // private, lock should already be taken
-void RTPPacketHistory::VerifyAndAllocatePacketLength(uint16_t packet_length) {
+void RTPPacketHistory::VerifyAndAllocatePacketLength(size_t packet_length) {
   assert(packet_length > 0);
   if (!store_) {
     return;
@@ -112,8 +112,8 @@
 }
 
 int32_t RTPPacketHistory::PutRTPPacket(const uint8_t* packet,
-                                       uint16_t packet_length,
-                                       uint16_t max_packet_length,
+                                       size_t packet_length,
+                                       size_t max_packet_length,
                                        int64_t capture_time_ms,
                                        StorageType type) {
   if (type == kDontStore) {
@@ -169,7 +169,7 @@
     return false;
   }
 
-  uint16_t length = stored_lengths_.at(index);
+  size_t length = stored_lengths_.at(index);
   if (length == 0 || length > max_packet_length_) {
     // Invalid length.
     return false;
@@ -181,7 +181,7 @@
                                                uint32_t min_elapsed_time_ms,
                                                bool retransmit,
                                                uint8_t* packet,
-                                               uint16_t* packet_length,
+                                               size_t* packet_length,
                                                int64_t* stored_time_ms) {
   assert(*packet_length >= max_packet_length_);
   CriticalSectionScoped cs(critsect_);
@@ -196,7 +196,7 @@
     return false;
   }
 
-  uint16_t length = stored_lengths_.at(index);
+  size_t length = stored_lengths_.at(index);
   assert(length <= max_packet_length_);
   if (length == 0) {
     LOG(LS_WARNING) << "No match for getting seqNum " << sequence_number
@@ -223,10 +223,10 @@
 
 void RTPPacketHistory::GetPacket(int index,
                                  uint8_t* packet,
-                                 uint16_t* packet_length,
+                                 size_t* packet_length,
                                  int64_t* stored_time_ms) const {
   // Get packet.
-  uint16_t length = stored_lengths_.at(index);
+  size_t length = stored_lengths_.at(index);
   std::vector<std::vector<uint8_t> >::const_iterator it_found_packet =
       stored_packets_.begin() + index;
   std::copy(it_found_packet->begin(), it_found_packet->begin() + length,
@@ -236,7 +236,7 @@
 }
 
 bool RTPPacketHistory::GetBestFittingPacket(uint8_t* packet,
-                                            uint16_t* packet_length,
+                                            size_t* packet_length,
                                             int64_t* stored_time_ms) {
   CriticalSectionScoped cs(critsect_);
   if (!store_)
@@ -283,22 +283,21 @@
   return false;
 }
 
-int RTPPacketHistory::FindBestFittingPacket(uint16_t size) const {
+int RTPPacketHistory::FindBestFittingPacket(size_t size) const {
   if (size < kMinPacketRequestBytes || stored_lengths_.empty())
     return -1;
-  int min_diff = -1;
-  size_t best_index = 0;
+  size_t min_diff = std::numeric_limits<size_t>::max();
+  int best_index = -1;  // Returned unchanged if we don't find anything.
   for (size_t i = 0; i < stored_lengths_.size(); ++i) {
     if (stored_lengths_[i] == 0)
       continue;
-    int diff = abs(stored_lengths_[i] - size);
-    if (min_diff < 0 || diff < min_diff) {
+    size_t diff = (stored_lengths_[i] > size) ?
+        (stored_lengths_[i] - size) : (size - stored_lengths_[i]);
+    if (diff < min_diff) {
       min_diff = diff;
-      best_index = i;
+      best_index = static_cast<int>(i);
     }
   }
-  if (min_diff < 0)
-    return -1;
   return best_index;
 }
 }  // namespace webrtc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h
index 253f6d0..eea3f12 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_history.h
@@ -36,8 +36,8 @@
 
   // Stores RTP packet.
   int32_t PutRTPPacket(const uint8_t* packet,
-                       uint16_t packet_length,
-                       uint16_t max_packet_length,
+                       size_t packet_length,
+                       size_t max_packet_length,
                        int64_t capture_time_ms,
                        StorageType type);
 
@@ -56,33 +56,33 @@
                                uint32_t min_elapsed_time_ms,
                                bool retransmit,
                                uint8_t* packet,
-                               uint16_t* packet_length,
+                               size_t* packet_length,
                                int64_t* stored_time_ms);
 
-  bool GetBestFittingPacket(uint8_t* packet, uint16_t* packet_length,
+  bool GetBestFittingPacket(uint8_t* packet, size_t* packet_length,
                             int64_t* stored_time_ms);
 
   bool HasRTPPacket(uint16_t sequence_number) const;
 
  private:
-  void GetPacket(int index, uint8_t* packet, uint16_t* packet_length,
+  void GetPacket(int index, uint8_t* packet, size_t* packet_length,
                  int64_t* stored_time_ms) const;
   void Allocate(uint16_t number_to_store) EXCLUSIVE_LOCKS_REQUIRED(*critsect_);
   void Free() EXCLUSIVE_LOCKS_REQUIRED(*critsect_);
-  void VerifyAndAllocatePacketLength(uint16_t packet_length);
+  void VerifyAndAllocatePacketLength(size_t packet_length);
   bool FindSeqNum(uint16_t sequence_number, int32_t* index) const;
-  int FindBestFittingPacket(uint16_t size) const;
+  int FindBestFittingPacket(size_t size) const;
 
  private:
   Clock* clock_;
   CriticalSectionWrapper* critsect_;
   bool store_;
   uint32_t prev_index_;
-  uint16_t max_packet_length_;
+  size_t max_packet_length_;
 
   std::vector<std::vector<uint8_t> > stored_packets_;
   std::vector<uint16_t> stored_seq_nums_;
-  std::vector<uint16_t> stored_lengths_;
+  std::vector<size_t> stored_lengths_;
   std::vector<int64_t> stored_times_;
   std::vector<int64_t> stored_send_times_;
   std::vector<StorageType> stored_types_;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc
index 7eb22ff..76798b6 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc
@@ -40,7 +40,7 @@
   uint8_t packet_out_[kMaxPacketLength];
 
   void CreateRtpPacket(uint16_t seq_num, uint32_t ssrc, uint8_t payload,
-      uint32_t timestamp, uint8_t* array, uint16_t* cur_pos) {
+      uint32_t timestamp, uint8_t* array, size_t* cur_pos) {
     array[(*cur_pos)++] = 0x80;
     array[(*cur_pos)++] = payload;
     array[(*cur_pos)++] = seq_num >> 8;
@@ -66,7 +66,7 @@
 
 TEST_F(RtpPacketHistoryTest, NoStoreStatus) {
   EXPECT_FALSE(hist_->StorePackets());
-  uint16_t len = 0;
+  size_t len = 0;
   int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
   CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
   EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
@@ -80,7 +80,7 @@
 
 TEST_F(RtpPacketHistoryTest, DontStore) {
   hist_->SetStorePacketsStatus(true, 10);
-  uint16_t len = 0;
+  size_t len = 0;
   int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
   CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
   EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
@@ -105,7 +105,7 @@
 
 TEST_F(RtpPacketHistoryTest, GetRtpPacket_NotStored) {
   hist_->SetStorePacketsStatus(true, 10);
-  uint16_t len = kMaxPacketLength;
+  size_t len = kMaxPacketLength;
   int64_t time;
   EXPECT_FALSE(hist_->GetPacketAndSetSendTime(0, 0, false, packet_, &len,
                                               &time));
@@ -113,7 +113,7 @@
 
 TEST_F(RtpPacketHistoryTest, PutRtpPacket) {
   hist_->SetStorePacketsStatus(true, 10);
-  uint16_t len = 0;
+  size_t len = 0;
   CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
 
   EXPECT_FALSE(hist_->HasRTPPacket(kSeqNum));
@@ -125,52 +125,52 @@
 
 TEST_F(RtpPacketHistoryTest, GetRtpPacket) {
   hist_->SetStorePacketsStatus(true, 10);
-  uint16_t len = 0;
+  size_t len = 0;
   int64_t capture_time_ms = 1;
   CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
   EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
                                    capture_time_ms, kAllowRetransmission));
 
-  uint16_t len_out = kMaxPacketLength;
+  size_t len_out = kMaxPacketLength;
   int64_t time;
   EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_,
                                              &len_out, &time));
   EXPECT_EQ(len, len_out);
   EXPECT_EQ(capture_time_ms, time);
-  for (int i = 0; i < len; i++)  {
+  for (size_t i = 0; i < len; i++)  {
     EXPECT_EQ(packet_[i], packet_out_[i]);
   }
 }
 
 TEST_F(RtpPacketHistoryTest, NoCaptureTime) {
   hist_->SetStorePacketsStatus(true, 10);
-  uint16_t len = 0;
+  size_t len = 0;
   fake_clock_.AdvanceTimeMilliseconds(1);
   int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
   CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
   EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
                                    -1, kAllowRetransmission));
 
-  uint16_t len_out = kMaxPacketLength;
+  size_t len_out = kMaxPacketLength;
   int64_t time;
   EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_,
                                              &len_out, &time));
   EXPECT_EQ(len, len_out);
   EXPECT_EQ(capture_time_ms, time);
-  for (int i = 0; i < len; i++)  {
+  for (size_t i = 0; i < len; i++)  {
     EXPECT_EQ(packet_[i], packet_out_[i]);
   }
 }
 
 TEST_F(RtpPacketHistoryTest, DontRetransmit) {
   hist_->SetStorePacketsStatus(true, 10);
-  uint16_t len = 0;
+  size_t len = 0;
   int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
   CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
   EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
                                    capture_time_ms, kDontRetransmit));
 
-  uint16_t len_out = kMaxPacketLength;
+  size_t len_out = kMaxPacketLength;
   int64_t time;
   EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 0, false, packet_out_,
                                              &len_out, &time));
@@ -180,7 +180,7 @@
 
 TEST_F(RtpPacketHistoryTest, MinResendTime) {
   hist_->SetStorePacketsStatus(true, 10);
-  uint16_t len = 0;
+  size_t len = 0;
   int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
   CreateRtpPacket(kSeqNum, kSsrc, kPayload, kTimestamp, packet_, &len);
   EXPECT_EQ(0, hist_->PutRTPPacket(packet_, len, kMaxPacketLength,
@@ -195,7 +195,7 @@
   len = kMaxPacketLength;
   EXPECT_TRUE(hist_->GetPacketAndSetSendTime(kSeqNum, 100, false, packet_, &len,
                                              &time));
-  EXPECT_GT(len, 0);
+  EXPECT_GT(len, 0u);
   EXPECT_EQ(capture_time_ms, time);
 
   // Time has not elapsed. Packet should be found, but no bytes copied.
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc
index ec05a73..6073016 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc
@@ -242,7 +242,7 @@
 
 bool RTPPayloadRegistry::RestoreOriginalPacket(uint8_t** restored_packet,
                                                const uint8_t* packet,
-                                               int* packet_length,
+                                               size_t* packet_length,
                                                uint32_t original_ssrc,
                                                const RTPHeader& header) const {
   if (kRtxHeaderSize + header.headerLength > *packet_length) {
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc
index 05eefbe..7e37528 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.cc
@@ -184,7 +184,7 @@
                                          const PayloadUnion& specific_payload,
                                          bool is_red,
                                          const uint8_t* payload,
-                                         uint16_t payload_length,
+                                         size_t payload_length,
                                          int64_t timestamp_ms,
                                          bool is_first_packet) {
   TRACE_EVENT2("webrtc_rtp", "Audio::ParseRtp",
@@ -288,7 +288,7 @@
 int32_t RTPReceiverAudio::ParseAudioCodecSpecific(
     WebRtcRTPHeader* rtp_header,
     const uint8_t* payload_data,
-    uint16_t payload_length,
+    size_t payload_length,
     const AudioPayload& audio_specific,
     bool is_red) {
 
@@ -311,13 +311,13 @@
     if (payload_length % 4 != 0) {
       return -1;
     }
-    uint8_t number_of_events = payload_length / 4;
+    size_t number_of_events = payload_length / 4;
 
     // sanity
     if (number_of_events >= MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS) {
       number_of_events = MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS;
     }
-    for (int n = 0; n < number_of_events; ++n) {
+    for (size_t n = 0; n < number_of_events; ++n) {
       bool end = (payload_data[(4 * n) + 1] & 0x80) ? true : false;
 
       std::set<uint8_t>::iterator event =
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h
index 4fb7256..2c6af68 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_audio.h
@@ -53,13 +53,13 @@
                       uint32_t* frequency,
                       bool* cng_payload_type_has_changed);
 
-  int32_t ParseRtpPacket(WebRtcRTPHeader* rtp_header,
-                         const PayloadUnion& specific_payload,
-                         bool is_red,
-                         const uint8_t* packet,
-                         uint16_t packet_length,
-                         int64_t timestamp_ms,
-                         bool is_first_packet);
+  virtual int32_t ParseRtpPacket(WebRtcRTPHeader* rtp_header,
+                                 const PayloadUnion& specific_payload,
+                                 bool is_red,
+                                 const uint8_t* packet,
+                                 size_t payload_length,
+                                 int64_t timestamp_ms,
+                                 bool is_first_packet) OVERRIDE;
 
   int GetPayloadTypeFrequency() const OVERRIDE;
 
@@ -104,7 +104,7 @@
   int32_t ParseAudioCodecSpecific(
       WebRtcRTPHeader* rtp_header,
       const uint8_t* payload_data,
-      uint16_t payload_length,
+      size_t payload_length,
       const AudioPayload& audio_specific,
       bool is_red);
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc
index 22fae10..1cbc2ac 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.cc
@@ -163,12 +163,9 @@
 bool RtpReceiverImpl::IncomingRtpPacket(
   const RTPHeader& rtp_header,
   const uint8_t* payload,
-  int payload_length,
+  size_t payload_length,
   PayloadUnion payload_specific,
   bool in_order) {
-  // Sanity check.
-  assert(payload_length >= 0);
-
   // Trigger our callbacks.
   CheckSSRCChanged(rtp_header);
 
@@ -198,7 +195,7 @@
   webrtc_rtp_header.header = rtp_header;
   CheckCSRC(webrtc_rtp_header);
 
-  uint16_t payload_data_length = payload_length - rtp_header.paddingLength;
+  size_t payload_data_length = payload_length - rtp_header.paddingLength;
 
   bool is_first_packet_in_frame = false;
   {
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h b/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h
index 6068811..9e58b1a 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_impl.h
@@ -46,7 +46,7 @@
   virtual bool IncomingRtpPacket(
       const RTPHeader& rtp_header,
       const uint8_t* payload,
-      int payload_length,
+      size_t payload_length,
       PayloadUnion payload_specific,
       bool in_order) OVERRIDE;
 
@@ -88,7 +88,7 @@
 
   scoped_ptr<CriticalSectionWrapper> critical_section_rtp_receiver_;
   int64_t last_receive_time_;
-  uint16_t last_received_payload_length_;
+  size_t last_received_payload_length_;
 
   // SSRCs.
   uint32_t ssrc_;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h b/webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h
index 09c9b6f..0eb23e5 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h
@@ -43,7 +43,7 @@
                                  const PayloadUnion& specific_payload,
                                  bool is_red,
                                  const uint8_t* payload,
-                                 uint16_t payload_length,
+                                 size_t payload_length,
                                  int64_t timestamp_ms,
                                  bool is_first_packet) = 0;
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc b/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc
index 6f6d647..6fe3e1d 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc
@@ -51,7 +51,7 @@
                                          const PayloadUnion& specific_payload,
                                          bool is_red,
                                          const uint8_t* payload,
-                                         uint16_t payload_length,
+                                         size_t payload_length,
                                          int64_t timestamp_ms,
                                          bool is_first_packet) {
   TRACE_EVENT2("webrtc_rtp",
@@ -62,7 +62,7 @@
                rtp_header->header.timestamp);
   rtp_header->type.Video.codec = specific_payload.Video.videoCodecType;
 
-  const uint16_t payload_data_length =
+  const size_t payload_data_length =
       payload_length - rtp_header->header.paddingLength;
 
   if (payload == NULL || payload_data_length == 0) {
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h b/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h
index 8fe4acb..177f303 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.h
@@ -30,7 +30,7 @@
                                  const PayloadUnion& specific_payload,
                                  bool is_red,
                                  const uint8_t* packet,
-                                 uint16_t packet_length,
+                                 size_t packet_length,
                                  int64_t timestamp,
                                  bool is_first_packet) OVERRIDE;
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 6446cb7..db10956 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -259,7 +259,7 @@
 
 int32_t ModuleRtpRtcpImpl::IncomingRtcpPacket(
     const uint8_t* rtcp_packet,
-    const uint16_t length) {
+    const size_t length) {
   // Allow receive of non-compound RTCP packets.
   RTCPUtility::RTCPParserV2 rtcp_parser(rtcp_packet, length, true);
 
@@ -504,7 +504,7 @@
     uint32_t time_stamp,
     int64_t capture_time_ms,
     const uint8_t* payload_data,
-    uint32_t payload_size,
+    size_t payload_size,
     const RTPFragmentationHeader* fragmentation,
     const RTPVideoHeader* rtp_video_hdr) {
   rtcp_sender_.SetLastRtpTime(time_stamp, capture_time_ms);
@@ -603,7 +603,7 @@
   return true;
 }
 
-int ModuleRtpRtcpImpl::TimeToSendPadding(int bytes) {
+size_t ModuleRtpRtcpImpl::TimeToSendPadding(size_t bytes) {
   if (!IsDefaultModule()) {
     // Don't send from default module.
     return rtp_sender_.TimeToSendPadding(bytes);
@@ -816,7 +816,7 @@
 }
 
 int32_t ModuleRtpRtcpImpl::DataCountersRTP(
-    uint32_t* bytes_sent,
+    size_t* bytes_sent,
     uint32_t* packets_sent) const {
   StreamDataCounters rtp_stats;
   StreamDataCounters rtx_stats;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index 4975812..1b7db9f 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -40,7 +40,7 @@
 
   // Called when we receive an RTCP packet.
   virtual int32_t IncomingRtcpPacket(const uint8_t* incoming_packet,
-                                     uint16_t incoming_packet_length) OVERRIDE;
+                                     size_t incoming_packet_length) OVERRIDE;
 
   virtual void SetRemoteSSRC(const uint32_t ssrc) OVERRIDE;
 
@@ -120,7 +120,7 @@
       const uint32_t time_stamp,
       int64_t capture_time_ms,
       const uint8_t* payload_data,
-      const uint32_t payload_size,
+      const size_t payload_size,
       const RTPFragmentationHeader* fragmentation = NULL,
       const RTPVideoHeader* rtp_video_hdr = NULL) OVERRIDE;
 
@@ -130,7 +130,7 @@
                                 bool retransmission) OVERRIDE;
   // Returns the number of padding bytes actually sent, which can be more or
   // less than |bytes|.
-  virtual int TimeToSendPadding(int bytes) OVERRIDE;
+  virtual size_t TimeToSendPadding(size_t bytes) OVERRIDE;
 
   virtual bool GetSendSideDelay(int* avg_send_delay_ms,
                                 int* max_send_delay_ms) const OVERRIDE;
@@ -179,7 +179,7 @@
   virtual int32_t ResetSendDataCountersRTP() OVERRIDE;
 
   // Statistics of the amount of data sent and received.
-  virtual int32_t DataCountersRTP(uint32_t* bytes_sent,
+  virtual int32_t DataCountersRTP(size_t* bytes_sent,
                                   uint32_t* packets_sent) const OVERRIDE;
 
   // Get received RTCP report, sender info.
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
index 24ff227..bf6ab39 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
@@ -67,17 +67,17 @@
     clock_ = clock;
     delay_ms_ = delay_ms;
   }
-  virtual int SendPacket(int /*ch*/, const void* data, int len) OVERRIDE {
+  virtual int SendPacket(int /*ch*/, const void* data, size_t len) OVERRIDE {
     RTPHeader header;
     scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
-    EXPECT_TRUE(parser->Parse(static_cast<const uint8_t*>(data),
-                              static_cast<size_t>(len),
-                              &header));
+    EXPECT_TRUE(parser->Parse(static_cast<const uint8_t*>(data), len, &header));
     ++rtp_packets_sent_;
     last_rtp_header_ = header;
-    return len;
+    return static_cast<int>(len);
   }
-  virtual int SendRTCPPacket(int /*ch*/, const void *data, int len) OVERRIDE {
+  virtual int SendRTCPPacket(int /*ch*/,
+                             const void *data,
+                             size_t len) OVERRIDE {
     test::RtcpPacketParser parser;
     parser.Parse(static_cast<const uint8_t*>(data), len);
     last_nack_list_ = parser.nack_item()->last_nack_list();
@@ -88,7 +88,7 @@
     EXPECT_TRUE(receiver_ != NULL);
     EXPECT_EQ(0, receiver_->IncomingRtcpPacket(
         static_cast<const uint8_t*>(data), len));
-    return len;
+    return static_cast<int>(len);
   }
   ModuleRtpRtcpImpl* receiver_;
   SimulatedClock* clock_;
@@ -398,7 +398,9 @@
  public:
   void ResetCounters() { bytes_received_.clear(); }
 
-  virtual int SendPacket(int channel, const void* data, int length) OVERRIDE {
+  virtual int SendPacket(int channel,
+                         const void* data,
+                         size_t length) OVERRIDE {
     RTPHeader header;
     scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
     EXPECT_TRUE(parser->Parse(static_cast<const uint8_t*>(data),
@@ -406,13 +408,13 @@
                               &header));
     bytes_received_[header.ssrc] += length;
     ++packets_received_[header.ssrc];
-    return length;
+    return static_cast<int>(length);
   }
 
   virtual int SendRTCPPacket(int channel,
                              const void* data,
-                             int length) OVERRIDE {
-    return length;
+                             size_t length) OVERRIDE {
+    return static_cast<int>(length);
   }
 
   int GetPacketsReceived(uint32_t ssrc) const {
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
index 677f3fc..38ac859 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.cc
@@ -22,7 +22,7 @@
 namespace webrtc {
 
 // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
-const int kMaxPaddingLength = 224;
+const size_t kMaxPaddingLength = 224;
 const int kSendSideDelayWindowMs = 1000;
 
 namespace {
@@ -272,7 +272,7 @@
   return rtp_header_extension_map_.Deregister(type);
 }
 
-uint16_t RTPSender::RtpHeaderExtensionTotalLength() const {
+size_t RTPSender::RtpHeaderExtensionTotalLength() const {
   CriticalSectionScoped cs(send_critsect_);
   return rtp_header_extension_map_.GetTotalLengthInBytes();
 }
@@ -355,7 +355,7 @@
 }
 
 int32_t RTPSender::SetMaxPayloadLength(
-    const uint16_t max_payload_length,
+    const size_t max_payload_length,
     const uint16_t packet_over_head) {
   // Sanity check.
   if (max_payload_length < 100 || max_payload_length > IP_PACKET_SIZE) {
@@ -368,7 +368,7 @@
   return 0;
 }
 
-uint16_t RTPSender::MaxDataPayloadLength() const {
+size_t RTPSender::MaxDataPayloadLength() const {
   int rtx;
   {
     CriticalSectionScoped rtx_lock(send_critsect_);
@@ -383,7 +383,7 @@
   }
 }
 
-uint16_t RTPSender::MaxPayloadLength() const {
+size_t RTPSender::MaxPayloadLength() const {
   return max_payload_length_;
 }
 
@@ -461,7 +461,7 @@
 int32_t RTPSender::SendOutgoingData(
     const FrameType frame_type, const int8_t payload_type,
     const uint32_t capture_timestamp, int64_t capture_time_ms,
-    const uint8_t *payload_data, const uint32_t payload_size,
+    const uint8_t *payload_data, const size_t payload_size,
     const RTPFragmentationHeader *fragmentation,
     VideoCodecInformation *codec_info, const RTPVideoTypeHeader *rtp_type_hdr) {
   uint32_t ssrc;
@@ -513,7 +513,7 @@
   return ret_val;
 }
 
-int RTPSender::TrySendRedundantPayloads(int bytes_to_send) {
+size_t RTPSender::TrySendRedundantPayloads(size_t bytes_to_send) {
   {
     CriticalSectionScoped cs(send_critsect_);
     if ((rtx_ & kRtxRedundantPayloads) == 0)
@@ -521,44 +521,41 @@
   }
 
   uint8_t buffer[IP_PACKET_SIZE];
-  int bytes_left = bytes_to_send;
+  int bytes_left = static_cast<int>(bytes_to_send);
   while (bytes_left > 0) {
-    uint16_t length = bytes_left;
+    size_t length = bytes_left;
     int64_t capture_time_ms;
     if (!packet_history_.GetBestFittingPacket(buffer, &length,
                                               &capture_time_ms)) {
       break;
     }
     if (!PrepareAndSendPacket(buffer, length, capture_time_ms, true, false))
-      return -1;
+      break;
     RtpUtility::RtpHeaderParser rtp_parser(buffer, length);
     RTPHeader rtp_header;
     rtp_parser.Parse(rtp_header);
-    bytes_left -= length - rtp_header.headerLength;
+    bytes_left -= static_cast<int>(length - rtp_header.headerLength);
   }
   return bytes_to_send - bytes_left;
 }
 
-int RTPSender::BuildPaddingPacket(uint8_t* packet, int header_length,
-                                  int32_t bytes) {
-  int padding_bytes_in_packet = kMaxPaddingLength;
-  if (bytes < kMaxPaddingLength) {
-    padding_bytes_in_packet = bytes;
-  }
+size_t RTPSender::BuildPaddingPacket(uint8_t* packet, size_t header_length) {
+  size_t padding_bytes_in_packet = kMaxPaddingLength;
   packet[0] |= 0x20;  // Set padding bit.
   int32_t *data =
       reinterpret_cast<int32_t *>(&(packet[header_length]));
 
   // Fill data buffer with random data.
-  for (int j = 0; j < (padding_bytes_in_packet >> 2); ++j) {
+  for (size_t j = 0; j < (padding_bytes_in_packet >> 2); ++j) {
     data[j] = rand();  // NOLINT
   }
   // Set number of padding bytes in the last byte of the packet.
-  packet[header_length + padding_bytes_in_packet - 1] = padding_bytes_in_packet;
+  packet[header_length + padding_bytes_in_packet - 1] =
+      static_cast<uint8_t>(padding_bytes_in_packet);
   return padding_bytes_in_packet;
 }
 
-int RTPSender::TrySendPadData(int bytes) {
+size_t RTPSender::TrySendPadData(size_t bytes) {
   int64_t capture_time_ms;
   uint32_t timestamp;
   {
@@ -575,11 +572,11 @@
   return SendPadData(timestamp, capture_time_ms, bytes);
 }
 
-int RTPSender::SendPadData(uint32_t timestamp,
-                           int64_t capture_time_ms,
-                           int32_t bytes) {
-  int padding_bytes_in_packet = 0;
-  int bytes_sent = 0;
+size_t RTPSender::SendPadData(uint32_t timestamp,
+                              int64_t capture_time_ms,
+                              size_t bytes) {
+  size_t padding_bytes_in_packet = 0;
+  size_t bytes_sent = 0;
   for (; bytes > 0; bytes -= padding_bytes_in_packet) {
     // Always send full padding packets.
     if (bytes < kMaxPaddingLength)
@@ -618,17 +615,18 @@
     }
 
     uint8_t padding_packet[IP_PACKET_SIZE];
-    int header_length = CreateRTPHeader(padding_packet,
-                                        payload_type,
-                                        ssrc,
-                                        false,
-                                        timestamp,
-                                        sequence_number,
-                                        NULL,
-                                        0);
-    padding_bytes_in_packet =
-        BuildPaddingPacket(padding_packet, header_length, bytes);
-    int length = padding_bytes_in_packet + header_length;
+    size_t header_length = CreateRTPHeader(padding_packet,
+                                           payload_type,
+                                           ssrc,
+                                           false,
+                                           timestamp,
+                                           sequence_number,
+                                           NULL,
+                                           0);
+    assert(header_length != static_cast<size_t>(-1));
+    padding_bytes_in_packet = BuildPaddingPacket(padding_packet, header_length);
+    assert(padding_bytes_in_packet <= bytes);
+    size_t length = padding_bytes_in_packet + header_length;
     int64_t now_ms = clock_->TimeInMilliseconds();
 
     RtpUtility::RtpHeaderParser rtp_parser(padding_packet, length);
@@ -660,7 +658,7 @@
 }
 
 int32_t RTPSender::ReSendPacket(uint16_t packet_id, uint32_t min_resend_time) {
-  uint16_t length = IP_PACKET_SIZE;
+  size_t length = IP_PACKET_SIZE;
   uint8_t data_buffer[IP_PACKET_SIZE];
   int64_t capture_time_ms;
   if (!packet_history_.GetPacketAndSetSendTime(packet_id, min_resend_time, true,
@@ -695,10 +693,10 @@
   }
   return PrepareAndSendPacket(data_buffer, length, capture_time_ms,
                               (rtx & kRtxRetransmitted) > 0, true) ?
-      length : -1;
+      static_cast<int32_t>(length) : -1;
 }
 
-bool RTPSender::SendPacketToNetwork(const uint8_t *packet, uint32_t size) {
+bool RTPSender::SendPacketToNetwork(const uint8_t *packet, size_t size) {
   int bytes_sent = -1;
   if (transport_) {
     bytes_sent = transport_->SendPacket(id_, packet, size);
@@ -731,7 +729,7 @@
   TRACE_EVENT2("webrtc_rtp", "RTPSender::OnReceivedNACK",
                "num_seqnum", nack_sequence_numbers.size(), "avg_rtt", avg_rtt);
   const int64_t now = clock_->TimeInMilliseconds();
-  uint32_t bytes_re_sent = 0;
+  size_t bytes_re_sent = 0;
   uint32_t target_bitrate = GetTargetBitrate();
 
   // Enough bandwidth to send NACK?
@@ -759,8 +757,8 @@
     // Delay bandwidth estimate (RTT * BW).
     if (target_bitrate != 0 && avg_rtt) {
       // kbits/s * ms = bits => bits/8 = bytes
-      uint32_t target_bytes =
-          (static_cast<uint32_t>(target_bitrate / 1000) * avg_rtt) >> 3;
+      size_t target_bytes =
+          (static_cast<size_t>(target_bitrate / 1000) * avg_rtt) >> 3;
       if (bytes_re_sent > target_bytes) {
         break;  // Ignore the rest of the packets in the list.
       }
@@ -775,7 +773,7 @@
 
 bool RTPSender::ProcessNACKBitRate(const uint32_t now) {
   uint32_t num = 0;
-  int byte_count = 0;
+  size_t byte_count = 0;
   const uint32_t kAvgIntervalMs = 1000;
   uint32_t target_bitrate = GetTargetBitrate();
 
@@ -800,11 +798,10 @@
       time_interval = now - nack_byte_count_times_[num - 1];
     }
   }
-  return (byte_count * 8) <
-         static_cast<int>(target_bitrate / 1000 * time_interval);
+  return (byte_count * 8) < (target_bitrate / 1000 * time_interval);
 }
 
-void RTPSender::UpdateNACKBitRate(const uint32_t bytes,
+void RTPSender::UpdateNACKBitRate(const size_t bytes,
                                   const uint32_t now) {
   CriticalSectionScoped cs(send_critsect_);
 
@@ -833,7 +830,7 @@
 bool RTPSender::TimeToSendPacket(uint16_t sequence_number,
                                  int64_t capture_time_ms,
                                  bool retransmission) {
-  uint16_t length = IP_PACKET_SIZE;
+  size_t length = IP_PACKET_SIZE;
   uint8_t data_buffer[IP_PACKET_SIZE];
   int64_t stored_time_ms;
 
@@ -862,7 +859,7 @@
 }
 
 bool RTPSender::PrepareAndSendPacket(uint8_t* buffer,
-                                     uint16_t length,
+                                     size_t length,
                                      int64_t capture_time_ms,
                                      bool send_over_rtx,
                                      bool is_retransmit) {
@@ -901,7 +898,7 @@
 }
 
 void RTPSender::UpdateRtpStats(const uint8_t* buffer,
-                               uint32_t size,
+                               size_t size,
                                const RTPHeader& header,
                                bool is_rtx,
                                bool is_retransmit) {
@@ -949,22 +946,22 @@
       buffer[header.headerLength] == pt_fec;
 }
 
-int RTPSender::TimeToSendPadding(int bytes) {
+size_t RTPSender::TimeToSendPadding(size_t bytes) {
   {
     CriticalSectionScoped cs(send_critsect_);
     if (!sending_media_) return 0;
   }
-  int available_bytes = bytes;
-  if (available_bytes > 0)
-    available_bytes -= TrySendRedundantPayloads(available_bytes);
-  if (available_bytes > 0)
-    available_bytes -= TrySendPadData(available_bytes);
-  return bytes - available_bytes;
+  if (bytes == 0)
+    return 0;
+  size_t bytes_sent = TrySendRedundantPayloads(bytes);
+  if (bytes_sent < bytes)
+    bytes_sent += TrySendPadData(bytes - bytes_sent);
+  return bytes_sent;
 }
 
 // TODO(pwestin): send in the RtpHeaderParser to avoid parsing it again.
 int32_t RTPSender::SendToNetwork(
-    uint8_t *buffer, int payload_length, int rtp_header_length,
+    uint8_t *buffer, size_t payload_length, size_t rtp_header_length,
     int64_t capture_time_ms, StorageType storage,
     PacedSender::Priority priority) {
   RtpUtility::RtpHeaderParser rtp_parser(buffer,
@@ -1013,7 +1010,7 @@
   if (capture_time_ms > 0) {
     UpdateDelayStatistics(capture_time_ms, now_ms);
   }
-  uint32_t length = payload_length + rtp_header_length;
+  size_t length = payload_length + rtp_header_length;
   if (!SendPacketToNetwork(buffer, length))
     return -1;
   {
@@ -1057,9 +1054,9 @@
   video_->ProcessBitrate();
 }
 
-uint16_t RTPSender::RTPHeaderLength() const {
+size_t RTPSender::RTPHeaderLength() const {
   CriticalSectionScoped lock(send_critsect_);
-  uint16_t rtp_header_length = 12;
+  size_t rtp_header_length = 12;
   if (include_csrcs_) {
     rtp_header_length += sizeof(uint32_t) * num_csrcs_;
   }
@@ -1326,7 +1323,7 @@
 }
 
 void RTPSender::UpdateTransmissionTimeOffset(
-    uint8_t *rtp_packet, const uint16_t rtp_packet_length,
+    uint8_t *rtp_packet, const size_t rtp_packet_length,
     const RTPHeader &rtp_header, const int64_t time_diff_ms) const {
   CriticalSectionScoped cs(send_critsect_);
   // Get id.
@@ -1345,7 +1342,7 @@
         << "Failed to update transmission time offset, not registered.";
     return;
   }
-  int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
+  size_t block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
   if (rtp_packet_length < block_pos + kTransmissionTimeOffsetLength ||
       rtp_header.headerLength <
           block_pos + kTransmissionTimeOffsetLength) {
@@ -1372,7 +1369,7 @@
 }
 
 bool RTPSender::UpdateAudioLevel(uint8_t *rtp_packet,
-                                 const uint16_t rtp_packet_length,
+                                 const size_t rtp_packet_length,
                                  const RTPHeader &rtp_header,
                                  const bool is_voiced,
                                  const uint8_t dBov) const {
@@ -1392,7 +1389,7 @@
     // The feature is not enabled.
     return false;
   }
-  int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
+  size_t block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
   if (rtp_packet_length < block_pos + kAudioLevelLength ||
       rtp_header.headerLength < block_pos + kAudioLevelLength) {
     LOG(LS_WARNING) << "Failed to update audio level, invalid length.";
@@ -1415,7 +1412,7 @@
 }
 
 void RTPSender::UpdateAbsoluteSendTime(
-    uint8_t *rtp_packet, const uint16_t rtp_packet_length,
+    uint8_t *rtp_packet, const size_t rtp_packet_length,
     const RTPHeader &rtp_header, const int64_t now_ms) const {
   CriticalSectionScoped cs(send_critsect_);
 
@@ -1434,7 +1431,7 @@
     // The feature is not enabled.
     return;
   }
-  int block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
+  size_t block_pos = 12 + rtp_header.numCSRCs + extension_block_pos;
   if (rtp_packet_length < block_pos + kAbsoluteSendTimeLength ||
       rtp_header.headerLength < block_pos + kAbsoluteSendTimeLength) {
     LOG(LS_WARNING) << "Failed to update absolute send time, invalid length.";
@@ -1685,7 +1682,7 @@
   return video_->SetFecParameters(delta_params, key_params);
 }
 
-void RTPSender::BuildRtxPacket(uint8_t* buffer, uint16_t* length,
+void RTPSender::BuildRtxPacket(uint8_t* buffer, size_t* length,
                                uint8_t* buffer_rtx) {
   CriticalSectionScoped cs(send_critsect_);
   uint8_t* data_buffer_rtx = buffer_rtx;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender.h b/webrtc/modules/rtp_rtcp/source/rtp_sender.h
index 6564d47..4781aae 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender.h
@@ -52,16 +52,16 @@
                                  const bool timestamp_provided = true,
                                  const bool inc_sequence_number = true) = 0;
 
-  virtual uint16_t RTPHeaderLength() const = 0;
+  virtual size_t RTPHeaderLength() const = 0;
   virtual uint16_t IncrementSequenceNumber() = 0;
   virtual uint16_t SequenceNumber() const = 0;
-  virtual uint16_t MaxPayloadLength() const = 0;
-  virtual uint16_t MaxDataPayloadLength() const = 0;
+  virtual size_t MaxPayloadLength() const = 0;
+  virtual size_t MaxDataPayloadLength() const = 0;
   virtual uint16_t PacketOverHead() const = 0;
   virtual uint16_t ActualSendBitrateKbit() const = 0;
 
   virtual int32_t SendToNetwork(
-      uint8_t *data_buffer, int payload_length, int rtp_header_length,
+      uint8_t *data_buffer, size_t payload_length, size_t rtp_header_length,
       int64_t capture_time_ms, StorageType storage,
       PacedSender::Priority priority) = 0;
 };
@@ -91,8 +91,8 @@
   void SetTargetBitrate(uint32_t bitrate);
   uint32_t GetTargetBitrate();
 
-  virtual uint16_t MaxDataPayloadLength() const
-      OVERRIDE;  // with RTP and FEC headers.
+  // Includes size of RTP and FEC headers.
+  virtual size_t MaxDataPayloadLength() const OVERRIDE;
 
   int32_t RegisterPayload(
       const char payload_name[RTP_PAYLOAD_NAME_SIZE],
@@ -133,7 +133,7 @@
   void SetCSRCs(const uint32_t arr_of_csrc[kRtpCsrcSize],
                 const uint8_t arr_length);
 
-  int32_t SetMaxPayloadLength(const uint16_t length,
+  int32_t SetMaxPayloadLength(const size_t length,
                               const uint16_t packet_over_head);
 
   int32_t SendOutgoingData(const FrameType frame_type,
@@ -141,7 +141,7 @@
                            const uint32_t timestamp,
                            int64_t capture_time_ms,
                            const uint8_t* payload_data,
-                           const uint32_t payload_size,
+                           const size_t payload_size,
                            const RTPFragmentationHeader* fragmentation,
                            VideoCodecInformation* codec_info = NULL,
                            const RTPVideoTypeHeader* rtp_type_hdr = NULL);
@@ -157,7 +157,7 @@
 
   int32_t DeregisterRtpHeaderExtension(const RTPExtensionType type);
 
-  uint16_t RtpHeaderExtensionTotalLength() const;
+  size_t RtpHeaderExtensionTotalLength() const;
 
   uint16_t BuildRTPHeaderExtension(uint8_t* data_buffer) const;
 
@@ -166,14 +166,14 @@
   uint8_t BuildAbsoluteSendTimeExtension(uint8_t* data_buffer) const;
 
   bool UpdateAudioLevel(uint8_t *rtp_packet,
-                        const uint16_t rtp_packet_length,
+                        const size_t rtp_packet_length,
                         const RTPHeader &rtp_header,
                         const bool is_voiced,
                         const uint8_t dBov) const;
 
   bool TimeToSendPacket(uint16_t sequence_number, int64_t capture_time_ms,
                         bool retransmission);
-  int TimeToSendPadding(int bytes);
+  size_t TimeToSendPadding(size_t bytes);
 
   // NACK.
   int SelectiveRetransmissions() const;
@@ -210,9 +210,9 @@
       const bool timestamp_provided = true,
       const bool inc_sequence_number = true) OVERRIDE;
 
-  virtual uint16_t RTPHeaderLength() const OVERRIDE;
+  virtual size_t RTPHeaderLength() const OVERRIDE;
   virtual uint16_t IncrementSequenceNumber() OVERRIDE;
-  virtual uint16_t MaxPayloadLength() const OVERRIDE;
+  virtual size_t MaxPayloadLength() const OVERRIDE;
   virtual uint16_t PacketOverHead() const OVERRIDE;
 
   // Current timestamp.
@@ -220,7 +220,7 @@
   virtual uint32_t SSRC() const OVERRIDE;
 
   virtual int32_t SendToNetwork(
-      uint8_t *data_buffer, int payload_length, int rtp_header_length,
+      uint8_t *data_buffer, size_t payload_length, size_t rtp_header_length,
       int64_t capture_time_ms, StorageType storage,
       PacedSender::Priority priority) OVERRIDE;
 
@@ -267,9 +267,9 @@
   int32_t SetFecParameters(const FecProtectionParams *delta_params,
                            const FecProtectionParams *key_params);
 
-  int SendPadData(uint32_t timestamp,
-                  int64_t capture_time_ms,
-                  int32_t bytes);
+  size_t SendPadData(uint32_t timestamp,
+                     int64_t capture_time_ms,
+                     size_t bytes);
 
   // Called on update of RTP statistics.
   void RegisterRtpStatisticsCallback(StreamDataCountersCallback* callback);
@@ -297,38 +297,39 @@
                       uint32_t timestamp, uint16_t sequence_number,
                       const uint32_t* csrcs, uint8_t csrcs_length) const;
 
-  void UpdateNACKBitRate(const uint32_t bytes, const uint32_t now);
+  void UpdateNACKBitRate(const size_t bytes, const uint32_t now);
 
   bool PrepareAndSendPacket(uint8_t* buffer,
-                            uint16_t length,
+                            size_t length,
                             int64_t capture_time_ms,
                             bool send_over_rtx,
                             bool is_retransmit);
 
-  // Return the number of bytes sent.
-  int TrySendRedundantPayloads(int bytes);
-  int TrySendPadData(int bytes);
+  // Return the number of bytes sent.  Note that both of these functions may
+  // return a larger value that their argument.
+  size_t TrySendRedundantPayloads(size_t bytes);
+  size_t TrySendPadData(size_t bytes);
 
-  int BuildPaddingPacket(uint8_t* packet, int header_length, int32_t bytes);
+  size_t BuildPaddingPacket(uint8_t* packet, size_t header_length);
 
-  void BuildRtxPacket(uint8_t* buffer, uint16_t* length,
+  void BuildRtxPacket(uint8_t* buffer, size_t* length,
                       uint8_t* buffer_rtx);
 
-  bool SendPacketToNetwork(const uint8_t *packet, uint32_t size);
+  bool SendPacketToNetwork(const uint8_t *packet, size_t size);
 
   void UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms);
 
   void UpdateTransmissionTimeOffset(uint8_t *rtp_packet,
-                                    const uint16_t rtp_packet_length,
+                                    const size_t rtp_packet_length,
                                     const RTPHeader &rtp_header,
                                     const int64_t time_diff_ms) const;
   void UpdateAbsoluteSendTime(uint8_t *rtp_packet,
-                              const uint16_t rtp_packet_length,
+                              const size_t rtp_packet_length,
                               const RTPHeader &rtp_header,
                               const int64_t now_ms) const;
 
   void UpdateRtpStats(const uint8_t* buffer,
-                      uint32_t size,
+                      size_t size,
                       const RTPHeader& header,
                       bool is_rtx,
                       bool is_retransmit);
@@ -352,7 +353,7 @@
   Transport *transport_;
   bool sending_media_ GUARDED_BY(send_critsect_);
 
-  uint16_t max_payload_length_;
+  size_t max_payload_length_;
   uint16_t packet_over_head_;
 
   int8_t payload_type_ GUARDED_BY(send_critsect_);
@@ -364,7 +365,7 @@
 
   // NACK
   uint32_t nack_byte_count_times_[NACK_BYTECOUNT_SIZE];
-  int32_t nack_byte_count_[NACK_BYTECOUNT_SIZE];
+  size_t nack_byte_count_[NACK_BYTECOUNT_SIZE];
   Bitrate nack_bitrate_;
 
   RTPPacketHistory packet_history_;
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc
index 7efe987..084a39c 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.cc
@@ -233,11 +233,11 @@
     const int8_t payloadType,
     const uint32_t captureTimeStamp,
     const uint8_t* payloadData,
-    const uint32_t dataSize,
+    const size_t dataSize,
     const RTPFragmentationHeader* fragmentation) {
   // TODO(pwestin) Breakup function in smaller functions.
-  uint16_t payloadSize = static_cast<uint16_t>(dataSize);
-  uint16_t maxPayloadLength = _rtpSender->MaxPayloadLength();
+  size_t payloadSize = dataSize;
+  size_t maxPayloadLength = _rtpSender->MaxPayloadLength();
   bool dtmfToneStarted = false;
   uint16_t dtmfLengthMS = 0;
   uint8_t key = 0;
@@ -383,7 +383,7 @@
         // only 0x80 if we have multiple blocks
         dataBuffer[rtpHeaderLength++] = 0x80 +
             fragmentation->fragmentationPlType[1];
-        uint32_t blockLength = fragmentation->fragmentationLength[1];
+        size_t blockLength = fragmentation->fragmentationLength[1];
 
         // sanity blockLength
         if(blockLength > 0x3ff) {  // block length 10 bits 1023 bytes
@@ -406,9 +406,8 @@
                payloadData + fragmentation->fragmentationOffset[0],
                fragmentation->fragmentationLength[0]);
 
-        payloadSize = static_cast<uint16_t>(
-            fragmentation->fragmentationLength[0] +
-            fragmentation->fragmentationLength[1]);
+        payloadSize = fragmentation->fragmentationLength[0] +
+            fragmentation->fragmentationLength[1];
       } else {
         // silence for too long send only new data
         dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0];
@@ -416,8 +415,7 @@
                payloadData + fragmentation->fragmentationOffset[0],
                fragmentation->fragmentationLength[0]);
 
-        payloadSize = static_cast<uint16_t>(
-            fragmentation->fragmentationLength[0]);
+        payloadSize = fragmentation->fragmentationLength[0];
       }
     } else {
       if (fragmentation && fragmentation->fragmentationVectorSize > 0) {
@@ -427,8 +425,7 @@
                 payloadData + fragmentation->fragmentationOffset[0],
                 fragmentation->fragmentationLength[0]);
 
-        payloadSize = static_cast<uint16_t>(
-            fragmentation->fragmentationLength[0]);
+        payloadSize = fragmentation->fragmentationLength[0];
       } else {
         memcpy(dataBuffer+rtpHeaderLength, payloadData, payloadSize);
       }
@@ -437,7 +434,7 @@
 
     // Update audio level extension, if included.
     {
-      uint16_t packetSize = payloadSize + rtpHeaderLength;
+      size_t packetSize = payloadSize + rtpHeaderLength;
       RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize);
       RTPHeader rtp_header;
       rtp_parser.Parse(rtp_header);
@@ -451,7 +448,7 @@
                          "seqnum", _rtpSender->SequenceNumber());
   return _rtpSender->SendToNetwork(dataBuffer,
                                    payloadSize,
-                                   static_cast<uint16_t>(rtpHeaderLength),
+                                   rtpHeaderLength,
                                    -1,
                                    kAllowRetransmission,
                                    PacedSender::kHighPriority);
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h
index d3f67e5..1affd2a 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h
@@ -37,7 +37,7 @@
                       const int8_t payloadType,
                       const uint32_t captureTimeStamp,
                       const uint8_t* payloadData,
-                      const uint32_t payloadSize,
+                      const size_t payloadSize,
                       const RTPFragmentationHeader* fragmentation);
 
     // set audio packet size, used to determine when it's time to send a DTMF packet in silence (CNG)
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc
index 2a49477..905b559 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_unittest.cc
@@ -49,11 +49,9 @@
   return packet + rtp_header.headerLength;
 }
 
-uint16_t GetPayloadDataLength(const RTPHeader& rtp_header,
-                              const uint16_t packet_length) {
-  uint16_t length = packet_length - rtp_header.headerLength -
-      rtp_header.paddingLength;
-  return static_cast<uint16_t>(length);
+size_t GetPayloadDataLength(const RTPHeader& rtp_header,
+                            const size_t packet_length) {
+  return packet_length - rtp_header.headerLength - rtp_header.paddingLength;
 }
 
 uint64_t ConvertMsToAbsSendTime(int64_t time_ms) {
@@ -64,18 +62,20 @@
  public:
   LoopbackTransportTest()
       : packets_sent_(0), last_sent_packet_len_(0), total_bytes_sent_(0) {}
-  virtual int SendPacket(int channel, const void *data, int len) OVERRIDE {
+  virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE {
     packets_sent_++;
     memcpy(last_sent_packet_, data, len);
     last_sent_packet_len_ = len;
-    total_bytes_sent_ += static_cast<size_t>(len);
-    return len;
+    total_bytes_sent_ += len;
+    return static_cast<int>(len);
   }
-  virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE {
+  virtual int SendRTCPPacket(int channel,
+                             const void *data,
+                             size_t len) OVERRIDE {
     return -1;
   }
   int packets_sent_;
-  int last_sent_packet_len_;
+  size_t last_sent_packet_len_;
   size_t total_bytes_sent_;
   uint8_t last_sent_packet_[kMaxPacketLength];
 };
@@ -114,7 +114,7 @@
     EXPECT_EQ(kTimestamp, rtp_header.timestamp);
     EXPECT_EQ(rtp_sender_->SSRC(), rtp_header.ssrc);
     EXPECT_EQ(0, rtp_header.numCSRCs);
-    EXPECT_EQ(0, rtp_header.paddingLength);
+    EXPECT_EQ(0U, rtp_header.paddingLength);
   }
 
   void SendPacket(int64_t capture_time_ms, int payload_length) {
@@ -124,6 +124,7 @@
                                                      kMarkerBit,
                                                      timestamp,
                                                      capture_time_ms);
+    ASSERT_GE(rtp_length, 0);
 
     // Packet should be stored in a send bucket.
     EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
@@ -136,40 +137,40 @@
 };
 
 TEST_F(RtpSenderTest, RegisterRtpTransmissionTimeOffsetHeaderExtension) {
-  EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
+  EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength());
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId));
   EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength,
             rtp_sender_->RtpHeaderExtensionTotalLength());
   EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension(
       kRtpExtensionTransmissionTimeOffset));
-  EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
+  EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength());
 }
 
 TEST_F(RtpSenderTest, RegisterRtpAbsoluteSendTimeHeaderExtension) {
-  EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
+  EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength());
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId));
   EXPECT_EQ(kRtpOneByteHeaderLength + kAbsoluteSendTimeLength,
             rtp_sender_->RtpHeaderExtensionTotalLength());
   EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension(
       kRtpExtensionAbsoluteSendTime));
-  EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
+  EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength());
 }
 
 TEST_F(RtpSenderTest, RegisterRtpAudioLevelHeaderExtension) {
-  EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
+  EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength());
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionAudioLevel, kAudioLevelExtensionId));
   EXPECT_EQ(kRtpOneByteHeaderLength + kAudioLevelLength,
             rtp_sender_->RtpHeaderExtensionTotalLength());
   EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension(
       kRtpExtensionAudioLevel));
-  EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
+  EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength());
 }
 
 TEST_F(RtpSenderTest, RegisterRtpHeaderExtensions) {
-  EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
+  EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength());
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId));
   EXPECT_EQ(kRtpOneByteHeaderLength + kTransmissionTimeOffsetLength,
@@ -193,16 +194,13 @@
       rtp_sender_->RtpHeaderExtensionTotalLength());
   EXPECT_EQ(0, rtp_sender_->DeregisterRtpHeaderExtension(
       kRtpExtensionAudioLevel));
-  EXPECT_EQ(0, rtp_sender_->RtpHeaderExtensionTotalLength());
+  EXPECT_EQ(0u, rtp_sender_->RtpHeaderExtensionTotalLength());
 }
 
 TEST_F(RtpSenderTest, BuildRTPPacket) {
-  int32_t length = rtp_sender_->BuildRTPheader(packet_,
-                                               kPayload,
-                                               kMarkerBit,
-                                               kTimestamp,
-                                               0);
-  EXPECT_EQ(kRtpHeaderSize, length);
+  size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, kTimestamp, 0));
+  ASSERT_EQ(kRtpHeaderSize, length);
 
   // Verify
   webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length);
@@ -227,13 +225,10 @@
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId));
 
-  int32_t length = rtp_sender_->BuildRTPheader(packet_,
-                                               kPayload,
-                                               kMarkerBit,
-                                               kTimestamp,
-                                               0);
-  EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
-      length);
+  size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, kTimestamp, 0));
+  ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
+            length);
 
   // Verify
   webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length);
@@ -268,13 +263,10 @@
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId));
 
-  int32_t length = rtp_sender_->BuildRTPheader(packet_,
-                                               kPayload,
-                                               kMarkerBit,
-                                               kTimestamp,
-                                               0);
-  EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
-      length);
+  size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, kTimestamp, 0));
+  ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
+            length);
 
   // Verify
   webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length);
@@ -298,13 +290,10 @@
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId));
 
-  int32_t length = rtp_sender_->BuildRTPheader(packet_,
-                                               kPayload,
-                                               kMarkerBit,
-                                               kTimestamp,
-                                               0);
-  EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
-      length);
+  size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, kTimestamp, 0));
+  ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
+            length);
 
   // Verify
   webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length);
@@ -336,13 +325,10 @@
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionAudioLevel, kAudioLevelExtensionId));
 
-  int32_t length = rtp_sender_->BuildRTPheader(packet_,
-                                               kPayload,
-                                               kMarkerBit,
-                                               kTimestamp,
-                                               0);
-  EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
-      length);
+  size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, kTimestamp, 0));
+  ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
+            length);
 
   // Verify
   webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length);
@@ -386,13 +372,10 @@
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionAudioLevel, kAudioLevelExtensionId));
 
-  int32_t length = rtp_sender_->BuildRTPheader(packet_,
-                                               kPayload,
-                                               kMarkerBit,
-                                               kTimestamp,
-                                               0);
-  EXPECT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
-      length);
+  size_t length = static_cast<size_t>(rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, kTimestamp, 0));
+  ASSERT_EQ(kRtpHeaderSize + rtp_sender_->RtpHeaderExtensionTotalLength(),
+            length);
 
   // Verify
   webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet_, length);
@@ -447,11 +430,10 @@
       kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId));
   rtp_sender_->SetTargetBitrate(300000);
   int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
-  int32_t rtp_length = rtp_sender_->BuildRTPheader(packet_,
-                                                   kPayload,
-                                                   kMarkerBit,
-                                                   kTimestamp,
-                                                   capture_time_ms);
+  int rtp_length_int = rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, kTimestamp, capture_time_ms);
+  ASSERT_NE(-1, rtp_length_int);
+  size_t rtp_length = static_cast<size_t>(rtp_length_int);
 
   // Packet should be stored in a send bucket.
   EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
@@ -501,11 +483,10 @@
       kRtpExtensionAbsoluteSendTime, kAbsoluteSendTimeExtensionId));
   rtp_sender_->SetTargetBitrate(300000);
   int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
-  int32_t rtp_length = rtp_sender_->BuildRTPheader(packet_,
-                                                   kPayload,
-                                                   kMarkerBit,
-                                                   kTimestamp,
-                                                   capture_time_ms);
+  int rtp_length_int = rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, kTimestamp, capture_time_ms);
+  ASSERT_NE(-1, rtp_length_int);
+  size_t rtp_length = static_cast<size_t>(rtp_length_int);
 
   // Packet should be stored in a send bucket.
   EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
@@ -524,7 +505,7 @@
   const int kStoredTimeInMs = 100;
   fake_clock_.AdvanceTimeMilliseconds(kStoredTimeInMs);
 
-  EXPECT_EQ(rtp_length, rtp_sender_->ReSendPacket(kSeqNum));
+  EXPECT_EQ(rtp_length_int, rtp_sender_->ReSendPacket(kSeqNum));
   EXPECT_EQ(0, transport_.packets_sent_);
 
   rtp_sender_->TimeToSendPacket(kSeqNum, capture_time_ms, false);
@@ -562,7 +543,7 @@
   uint16_t seq_num = kSeqNum;
   uint32_t timestamp = kTimestamp;
   rtp_sender_->SetStorePacketsStatus(true, 10);
-  int32_t rtp_header_len = kRtpHeaderSize;
+  size_t rtp_header_len = kRtpHeaderSize;
   EXPECT_EQ(0, rtp_sender_->RegisterRtpHeaderExtension(
       kRtpExtensionTransmissionTimeOffset, kTransmissionTimeOffsetExtensionId));
   rtp_header_len += 4;  // 4 bytes extension.
@@ -583,11 +564,10 @@
 
   rtp_sender_->SetTargetBitrate(300000);
   int64_t capture_time_ms = fake_clock_.TimeInMilliseconds();
-  int32_t rtp_length = rtp_sender_->BuildRTPheader(packet_,
-                                                   kPayload,
-                                                   kMarkerBit,
-                                                   timestamp,
-                                                   capture_time_ms);
+  int rtp_length_int = rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, timestamp, capture_time_ms);
+  ASSERT_NE(-1, rtp_length_int);
+  size_t rtp_length = static_cast<size_t>(rtp_length_int);
 
   // Packet should be stored in a send bucket.
   EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
@@ -611,8 +591,8 @@
   // Send padding 4 times, waiting 50 ms between each.
   for (int i = 0; i < 4; ++i) {
     const int kPaddingPeriodMs = 50;
-    const int kPaddingBytes = 100;
-    const int kMaxPaddingLength = 224;  // Value taken from rtp_sender.cc.
+    const size_t kPaddingBytes = 100;
+    const size_t kMaxPaddingLength = 224;  // Value taken from rtp_sender.cc.
     // Padding will be forced to full packets.
     EXPECT_EQ(kMaxPaddingLength, rtp_sender_->TimeToSendPadding(kPaddingBytes));
 
@@ -638,11 +618,10 @@
 
   // Send a regular video packet again.
   capture_time_ms = fake_clock_.TimeInMilliseconds();
-  rtp_length = rtp_sender_->BuildRTPheader(packet_,
-                                           kPayload,
-                                           kMarkerBit,
-                                           timestamp,
-                                           capture_time_ms);
+  rtp_length_int = rtp_sender_->BuildRTPheader(
+      packet_, kPayload, kMarkerBit, timestamp, capture_time_ms);
+  ASSERT_NE(-1, rtp_length_int);
+  rtp_length = static_cast<size_t>(rtp_length_int);
 
   // Packet should be stored in a send bucket.
   EXPECT_EQ(0, rtp_sender_->SendToNetwork(packet_,
@@ -716,15 +695,12 @@
   EXPECT_CALL(transport,
               SendPacket(_, _, kMaxPaddingSize + rtp_header_len))
       .WillOnce(testing::ReturnArg<2>());
-  EXPECT_EQ(kMaxPaddingSize,
-            static_cast<size_t>(rtp_sender_->TimeToSendPadding(49)));
+  EXPECT_EQ(kMaxPaddingSize, rtp_sender_->TimeToSendPadding(49));
 
-  const int kRtxHeaderSize = 2;
   EXPECT_CALL(transport, SendPacket(_, _, kPayloadSizes[0] +
                                     rtp_header_len + kRtxHeaderSize))
       .WillOnce(testing::ReturnArg<2>());
-  EXPECT_EQ(kPayloadSizes[0],
-            static_cast<size_t>(rtp_sender_->TimeToSendPadding(500)));
+  EXPECT_EQ(kPayloadSizes[0], rtp_sender_->TimeToSendPadding(500));
 
   EXPECT_CALL(transport, SendPacket(_, _, kPayloadSizes[kNumPayloadSizes - 1] +
                                     rtp_header_len + kRtxHeaderSize))
@@ -732,7 +708,7 @@
   EXPECT_CALL(transport, SendPacket(_, _, kMaxPaddingSize + rtp_header_len))
       .WillOnce(testing::ReturnArg<2>());
   EXPECT_EQ(kPayloadSizes[kNumPayloadSizes - 1] + kMaxPaddingSize,
-            static_cast<size_t>(rtp_sender_->TimeToSendPadding(999)));
+            rtp_sender_->TimeToSendPadding(999));
 }
 
 TEST_F(RtpSenderTest, SendGenericVideo) {
@@ -951,8 +927,8 @@
 
     uint32_t ssrc_;
     StreamDataCounters counters_;
-    bool Matches(uint32_t ssrc, uint32_t bytes, uint32_t header_bytes,
-                 uint32_t padding, uint32_t packets, uint32_t retransmits,
+    bool Matches(uint32_t ssrc, size_t bytes, size_t header_bytes,
+                 size_t padding, uint32_t packets, uint32_t retransmits,
                  uint32_t fec) {
       return ssrc_ == ssrc &&
           counters_.bytes == bytes &&
@@ -1034,8 +1010,8 @@
   const uint8_t* payload_data = GetPayloadData(rtp_header,
       transport_.last_sent_packet_);
 
-  ASSERT_EQ(sizeof(payload), GetPayloadDataLength(rtp_header,
-            transport_.last_sent_packet_len_));
+  ASSERT_EQ(sizeof(payload),
+            GetPayloadDataLength(rtp_header, transport_.last_sent_packet_len_));
 
   EXPECT_EQ(0, memcmp(payload, payload_data, sizeof(payload)));
 }
@@ -1063,8 +1039,8 @@
   const uint8_t* payload_data = GetPayloadData(rtp_header,
                                                transport_.last_sent_packet_);
 
-  ASSERT_EQ(sizeof(payload), GetPayloadDataLength(
-      rtp_header, transport_.last_sent_packet_len_));
+  ASSERT_EQ(sizeof(payload),
+            GetPayloadDataLength(rtp_header, transport_.last_sent_packet_len_));
 
   EXPECT_EQ(0, memcmp(payload, payload_data, sizeof(payload)));
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc
index ec031df..4792dfa 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -100,16 +100,16 @@
 }
 
 int32_t RTPSenderVideo::SendVideoPacket(uint8_t* data_buffer,
-                                        const uint16_t payload_length,
-                                        const uint16_t rtp_header_length,
+                                        const size_t payload_length,
+                                        const size_t rtp_header_length,
                                         const uint32_t capture_timestamp,
                                         int64_t capture_time_ms,
                                         StorageType storage,
                                         bool protect) {
   if (_fecEnabled) {
     int ret = 0;
-    int fec_overhead_sent = 0;
-    int video_sent = 0;
+    size_t fec_overhead_sent = 0;
+    size_t video_sent = 0;
 
     RedPacket* red_packet = producer_fec_.BuildRedPacket(
         data_buffer, payload_length, rtp_header_length, _payloadTypeRED);
@@ -202,7 +202,7 @@
   // RFC 2032
   // 5.2.1.  Full intra-frame Request (FIR) packet
 
-  uint16_t length = 8;
+  size_t length = 8;
   uint8_t data[8];
   data[0] = 0x80;
   data[1] = 192;
@@ -242,7 +242,7 @@
   return 0;
 }
 
-uint16_t RTPSenderVideo::FECPacketOverhead() const {
+size_t RTPSenderVideo::FECPacketOverhead() const {
   if (_fecEnabled) {
     // Overhead is FEC headers plus RED for FEC header plus anything in RTP
     // header beyond the 12 bytes base header (CSRC list, extensions...)
@@ -271,7 +271,7 @@
                                   const uint32_t captureTimeStamp,
                                   int64_t capture_time_ms,
                                   const uint8_t* payloadData,
-                                  const uint32_t payloadSize,
+                                  const size_t payloadSize,
                                   const RTPFragmentationHeader* fragmentation,
                                   VideoCodecInformation* codecInfo,
                                   const RTPVideoTypeHeader* rtpTypeHdr) {
@@ -320,11 +320,11 @@
                           const uint32_t captureTimeStamp,
                           int64_t capture_time_ms,
                           const uint8_t* payloadData,
-                          const uint32_t payloadSize,
+                          const size_t payloadSize,
                           const RTPFragmentationHeader* fragmentation,
                           const RTPVideoTypeHeader* rtpTypeHdr) {
   uint16_t rtp_header_length = _rtpSender.RTPHeaderLength();
-  int32_t payload_bytes_to_send = payloadSize;
+  size_t payload_bytes_to_send = payloadSize;
   const uint8_t* data = payloadData;
   size_t max_payload_length = _rtpSender.MaxDataPayloadLength();
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h
index 250e36b..f043950 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_sender_video.h
@@ -35,7 +35,7 @@
 
   virtual RtpVideoCodecTypes VideoCodecType() const;
 
-  uint16_t FECPacketOverhead() const;
+  size_t FECPacketOverhead() const;
 
   int32_t RegisterVideoPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE],
                                const int8_t payloadType,
@@ -48,7 +48,7 @@
                     const uint32_t captureTimeStamp,
                     int64_t capture_time_ms,
                     const uint8_t* payloadData,
-                    const uint32_t payloadSize,
+                    const size_t payloadSize,
                     const RTPFragmentationHeader* fragmentation,
                     VideoCodecInformation* codecInfo,
                     const RTPVideoTypeHeader* rtpTypeHdr);
@@ -85,8 +85,8 @@
 
  protected:
   virtual int32_t SendVideoPacket(uint8_t* dataBuffer,
-                                  const uint16_t payloadLength,
-                                  const uint16_t rtpHeaderLength,
+                                  const size_t payloadLength,
+                                  const size_t rtpHeaderLength,
                                   const uint32_t capture_timestamp,
                                   int64_t capture_time_ms,
                                   StorageType storage,
@@ -99,7 +99,7 @@
             const uint32_t captureTimeStamp,
             int64_t capture_time_ms,
             const uint8_t* payloadData,
-            const uint32_t payloadSize,
+            const size_t payloadSize,
             const RTPFragmentationHeader* fragmentation,
             const RTPVideoTypeHeader* rtpTypeHdr);
 
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_utility.cc b/webrtc/modules/rtp_rtcp/source/rtp_utility.cc
index 441a9c5..2897fac 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_utility.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_utility.cc
@@ -286,7 +286,7 @@
   }
 
   const uint8_t PT = _ptrRTPDataBegin[1];
-  const uint16_t len = (_ptrRTPDataBegin[2] << 8) + _ptrRTPDataBegin[3];
+  const size_t len = (_ptrRTPDataBegin[2] << 8) + _ptrRTPDataBegin[3];
   const uint8_t* ptr = &_ptrRTPDataBegin[4];
 
   uint32_t SSRC = *ptr++ << 24;
@@ -338,7 +338,7 @@
     return false;
   }
 
-  const uint8_t CSRCocts = CC * 4;
+  const size_t CSRCocts = CC * 4;
 
   if ((ptr + CSRCocts) > _ptrRTPDataEnd) {
     return false;
@@ -352,7 +352,7 @@
   header.numCSRCs       = CC;
   header.paddingLength  = P ? *(_ptrRTPDataEnd - 1) : 0;
 
-  for (unsigned int i = 0; i < CC; ++i) {
+  for (uint8_t i = 0; i < CC; ++i) {
     uint32_t CSRC = *ptr++ << 24;
     CSRC += *ptr++ << 16;
     CSRC += *ptr++ << 8;
@@ -395,11 +395,11 @@
     uint16_t definedByProfile = *ptr++ << 8;
     definedByProfile += *ptr++;
 
-    uint16_t XLen = *ptr++ << 8;
+    size_t XLen = *ptr++ << 8;
     XLen += *ptr++; // in 32 bit words
     XLen *= 4; // in octs
 
-    if (remain < (4 + XLen)) {
+    if (static_cast<size_t>(remain) < (4 + XLen)) {
       return false;
     }
     if (definedByProfile == kRtpOneByteHeaderExtensionId) {
diff --git a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.cc b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.cc
index e62df1f..feed784 100644
--- a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.cc
+++ b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.cc
@@ -19,9 +19,9 @@
 namespace webrtc {
 
 PartitionTreeNode::PartitionTreeNode(PartitionTreeNode* parent,
-                                     const int* size_vector,
-                                     int num_partitions,
-                                     int this_size)
+                                     const size_t* size_vector,
+                                     size_t num_partitions,
+                                     size_t this_size)
     : parent_(parent),
       this_size_(this_size),
       size_vector_(size_vector),
@@ -29,13 +29,14 @@
       max_parent_size_(0),
       min_parent_size_(std::numeric_limits<int>::max()),
       packet_start_(false) {
-  assert(num_partitions >= 0);
+  // If |this_size_| > INT_MAX, Cost() and CreateChildren() won't work properly.
+  assert(this_size_ <= static_cast<size_t>(std::numeric_limits<int>::max()));
   children_[kLeftChild] = NULL;
   children_[kRightChild] = NULL;
 }
 
-PartitionTreeNode* PartitionTreeNode::CreateRootNode(const int* size_vector,
-                                                     int num_partitions) {
+PartitionTreeNode* PartitionTreeNode::CreateRootNode(const size_t* size_vector,
+                                                     size_t num_partitions) {
   PartitionTreeNode* root_node =
       new PartitionTreeNode(NULL, &size_vector[1], num_partitions - 1,
                             size_vector[0]);
@@ -48,20 +49,19 @@
   delete children_[kRightChild];
 }
 
-int PartitionTreeNode::Cost(int penalty) {
-  assert(penalty >= 0);
+int PartitionTreeNode::Cost(size_t penalty) {
   int cost = 0;
   if (num_partitions_ == 0) {
     // This is a solution node.
-    cost = std::max(max_parent_size_, this_size_) -
-        std::min(min_parent_size_, this_size_);
+    cost = std::max(max_parent_size_, this_size_int()) -
+        std::min(min_parent_size_, this_size_int());
   } else {
-    cost = std::max(max_parent_size_, this_size_) - min_parent_size_;
+    cost = std::max(max_parent_size_, this_size_int()) - min_parent_size_;
   }
   return cost + NumPackets() * penalty;
 }
 
-bool PartitionTreeNode::CreateChildren(int max_size) {
+bool PartitionTreeNode::CreateChildren(size_t max_size) {
   assert(max_size > 0);
   bool children_created = false;
   if (num_partitions_ > 0) {
@@ -85,9 +85,9 @@
                                                      num_partitions_ - 1,
                                                      size_vector_[0]);
       children_[kRightChild]->set_max_parent_size(
-          std::max(max_parent_size_, this_size_));
+          std::max(max_parent_size_, this_size_int()));
       children_[kRightChild]->set_min_parent_size(
-          std::min(min_parent_size_, this_size_));
+          std::min(min_parent_size_, this_size_int()));
       // "Right" child starts a new packet.
       children_[kRightChild]->set_packet_start(true);
       children_created = true;
@@ -96,7 +96,7 @@
   return children_created;
 }
 
-int PartitionTreeNode::NumPackets() {
+size_t PartitionTreeNode::NumPackets() {
   if (parent_ == NULL) {
     // Root node is a "right" child by definition.
     return 1;
@@ -110,8 +110,8 @@
   }
 }
 
-PartitionTreeNode* PartitionTreeNode::GetOptimalNode(int max_size,
-                                                     int penalty) {
+PartitionTreeNode* PartitionTreeNode::GetOptimalNode(size_t max_size,
+                                                     size_t penalty) {
   CreateChildren(max_size);
   PartitionTreeNode* left = children_[kLeftChild];
   PartitionTreeNode* right = children_[kRightChild];
@@ -148,12 +148,11 @@
 
 Vp8PartitionAggregator::Vp8PartitionAggregator(
     const RTPFragmentationHeader& fragmentation,
-    int first_partition_idx, int last_partition_idx)
+    size_t first_partition_idx, size_t last_partition_idx)
     : root_(NULL),
       num_partitions_(last_partition_idx - first_partition_idx + 1),
-      size_vector_(new int[num_partitions_]),
+      size_vector_(new size_t[num_partitions_]),
       largest_partition_size_(0) {
-  assert(first_partition_idx >= 0);
   assert(last_partition_idx >= first_partition_idx);
   assert(last_partition_idx < fragmentation.fragmentationVectorSize);
   for (size_t i = 0; i < num_partitions_; ++i) {
@@ -179,17 +178,18 @@
 }
 
 Vp8PartitionAggregator::ConfigVec
-Vp8PartitionAggregator::FindOptimalConfiguration(int max_size, int penalty) {
+Vp8PartitionAggregator::FindOptimalConfiguration(size_t max_size,
+                                                 size_t penalty) {
   assert(root_);
   assert(max_size >= largest_partition_size_);
   PartitionTreeNode* opt = root_->GetOptimalNode(max_size, penalty);
   ConfigVec config_vector(num_partitions_, 0);
   PartitionTreeNode* temp_node = opt;
-  int packet_index = opt->NumPackets() - 1;
-  for (int i = num_partitions_ - 1; i >= 0; --i) {
-    assert(packet_index >= 0);
+  size_t packet_index = opt->NumPackets();
+  for (size_t i = num_partitions_; i > 0; --i) {
+    assert(packet_index > 0);
     assert(temp_node != NULL);
-    config_vector[i] = packet_index;
+    config_vector[i - 1] = packet_index - 1;
     if (temp_node->packet_start()) --packet_index;
     temp_node = temp_node->parent();
   }
@@ -204,51 +204,54 @@
   if (*max_size < 0) {
     *max_size = 0;
   }
-  unsigned int i = 0;
+  size_t i = 0;
   while (i < config.size()) {
-    int this_size = 0;
-    unsigned int j = i;
+    size_t this_size = 0;
+    size_t j = i;
     while (j < config.size() && config[i] == config[j]) {
       this_size += size_vector_[j];
       ++j;
     }
     i = j;
-    if (this_size < *min_size) {
+    if (this_size < static_cast<size_t>(*min_size)) {
       *min_size = this_size;
     }
-    if (this_size > *max_size) {
+    if (this_size > static_cast<size_t>(*max_size)) {
       *max_size = this_size;
     }
   }
 }
 
-int Vp8PartitionAggregator::CalcNumberOfFragments(int large_partition_size,
-                                                  int max_payload_size,
-                                                  int penalty,
-                                                  int min_size,
-                                                  int max_size) {
-  assert(max_size <= max_payload_size);
-  assert(min_size <= max_size);
+size_t Vp8PartitionAggregator::CalcNumberOfFragments(
+    size_t large_partition_size,
+    size_t max_payload_size,
+    size_t penalty,
+    int min_size,
+    int max_size) {
+  assert(large_partition_size > 0);
   assert(max_payload_size > 0);
+  assert(min_size != 0);
+  assert(min_size <= max_size);
+  assert(max_size <= static_cast<int>(max_payload_size));
   // Divisions with rounding up.
-  const int min_number_of_fragments =
+  const size_t min_number_of_fragments =
       (large_partition_size + max_payload_size - 1) / max_payload_size;
   if (min_size < 0 || max_size < 0) {
     // No aggregates produced, so we do not have any size boundaries.
     // Simply split in as few partitions as possible.
     return min_number_of_fragments;
   }
-  const int max_number_of_fragments =
+  const size_t max_number_of_fragments =
       (large_partition_size + min_size - 1) / min_size;
   int num_fragments = -1;
-  int best_cost = std::numeric_limits<int>::max();
-  for (int n = min_number_of_fragments; n <= max_number_of_fragments; ++n) {
+  size_t best_cost = std::numeric_limits<size_t>::max();
+  for (size_t n = min_number_of_fragments; n <= max_number_of_fragments; ++n) {
     // Round up so that we use the largest fragment.
-    int fragment_size = (large_partition_size + n - 1) / n;
-    int cost = 0;
-    if (fragment_size < min_size) {
+    size_t fragment_size = (large_partition_size + n - 1) / n;
+    size_t cost = 0;
+    if (fragment_size < static_cast<size_t>(min_size)) {
       cost = min_size - fragment_size + n * penalty;
-    } else if (fragment_size > max_size) {
+    } else if (fragment_size > static_cast<size_t>(max_size)) {
       cost = fragment_size - max_size + n * penalty;
     } else {
       cost = n * penalty;
diff --git a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h
index cbb1207..67babcb 100644
--- a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h
+++ b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator.h
@@ -24,13 +24,13 @@
  public:
   // Create a tree node.
   PartitionTreeNode(PartitionTreeNode* parent,
-                    const int* size_vector,
-                    int num_partitions,
-                    int this_size);
+                    const size_t* size_vector,
+                    size_t num_partitions,
+                    size_t this_size);
 
   // Create a root node.
-  static PartitionTreeNode* CreateRootNode(const int* size_vector,
-                                           int num_partitions);
+  static PartitionTreeNode* CreateRootNode(const size_t* size_vector,
+                                           size_t num_partitions);
 
   ~PartitionTreeNode();
 
@@ -38,18 +38,18 @@
   // will be the actual cost associated with that solution. If not, the cost
   // will be the cost accumulated so far along the current branch (which is a
   // lower bound for any solution along the branch).
-  int Cost(int penalty);
+  int Cost(size_t penalty);
 
   // Create the two children for this node.
-  bool CreateChildren(int max_size);
+  bool CreateChildren(size_t max_size);
 
   // Get the number of packets for the configuration that this node represents.
-  int NumPackets();
+  size_t NumPackets();
 
   // Find the optimal solution given a maximum packet size and a per-packet
   // penalty. The method will be recursively called while the solver is
   // probing down the tree of nodes.
-  PartitionTreeNode* GetOptimalNode(int max_size, int penalty);
+  PartitionTreeNode* GetOptimalNode(size_t max_size, size_t penalty);
 
   // Setters and getters.
   void set_max_parent_size(int size) { max_parent_size_ = size; }
@@ -57,7 +57,7 @@
   PartitionTreeNode* parent() const { return parent_; }
   PartitionTreeNode* left_child() const { return children_[kLeftChild]; }
   PartitionTreeNode* right_child() const { return children_[kRightChild]; }
-  int this_size() const { return this_size_; }
+  size_t this_size() const { return this_size_; }
   bool packet_start() const { return packet_start_; }
 
  private:
@@ -66,13 +66,14 @@
     kRightChild = 1
   };
 
+  int this_size_int() const { return static_cast<int>(this_size_); }
   void set_packet_start(bool value) { packet_start_ = value; }
 
   PartitionTreeNode* parent_;
   PartitionTreeNode* children_[2];
-  int this_size_;
-  const int* size_vector_;
-  int num_partitions_;
+  size_t this_size_;
+  const size_t* size_vector_;
+  size_t num_partitions_;
   int max_parent_size_;
   int min_parent_size_;
   bool packet_start_;
@@ -84,13 +85,14 @@
 // the maximum packet size.
 class Vp8PartitionAggregator {
  public:
-  typedef std::vector<int> ConfigVec;
+  typedef std::vector<size_t> ConfigVec;
 
   // Constructor. All partitions in the fragmentation header from index
   // first_partition_idx to last_partition_idx must be smaller than
   // maximum packet size to be used in FindOptimalConfiguration.
   Vp8PartitionAggregator(const RTPFragmentationHeader& fragmentation,
-                         int first_partition_idx, int last_partition_idx);
+                         size_t first_partition_idx,
+                         size_t last_partition_idx);
 
   ~Vp8PartitionAggregator();
 
@@ -103,7 +105,7 @@
   // first_partition_idx + 1), where each element indicates the packet index
   // for that partition. Thus, the output vector starts at 0 and is increasing
   // up to the number of packets - 1.
-  ConfigVec FindOptimalConfiguration(int max_size, int penalty);
+  ConfigVec FindOptimalConfiguration(size_t max_size, size_t penalty);
 
   // Calculate minimum and maximum packet sizes for a given aggregation config.
   // The extreme packet sizes of the given aggregation are compared with the
@@ -116,17 +118,17 @@
   // be larger than max_payload_size. Each fragment comes at an overhead cost
   // of penalty bytes. If the size of the fragments fall outside the range
   // [min_size, max_size], an extra cost is inflicted.
-  static int CalcNumberOfFragments(int large_partition_size,
-                                   int max_payload_size,
-                                   int penalty,
-                                   int min_size,
-                                   int max_size);
+  static size_t CalcNumberOfFragments(size_t large_partition_size,
+                                      size_t max_payload_size,
+                                      size_t penalty,
+                                      int min_size,
+                                      int max_size);
 
  private:
   PartitionTreeNode* root_;
   size_t num_partitions_;
-  int* size_vector_;
-  int largest_partition_size_;
+  size_t* size_vector_;
+  size_t largest_partition_size_;
 
   DISALLOW_COPY_AND_ASSIGN(Vp8PartitionAggregator);
 };
diff --git a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator_unittest.cc b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator_unittest.cc
index d4ebd77..4650c94 100644
--- a/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator_unittest.cc
+++ b/webrtc/modules/rtp_rtcp/source/vp8_partition_aggregator_unittest.cc
@@ -16,8 +16,8 @@
 namespace webrtc {
 
 TEST(PartitionTreeNode, CreateAndDelete) {
-  const int kVector[] = {1, 2, 3};
-  const int kNumPartitions = sizeof(kVector) / sizeof(kVector[0]);
+  const size_t kVector[] = {1, 2, 3};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kVector);
   PartitionTreeNode* node1 =
       PartitionTreeNode::CreateRootNode(kVector, kNumPartitions);
   PartitionTreeNode* node2 =
@@ -27,17 +27,17 @@
 }
 
 TEST(PartitionTreeNode, CreateChildrenAndDelete) {
-  const int kVector[] = {1, 2, 3};
-  const int kNumPartitions = sizeof(kVector) / sizeof(kVector[0]);
-  const int kMaxSize = 10;
-  const int kPenalty = 5;
+  const size_t kVector[] = {1, 2, 3};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kVector);
+  const size_t kMaxSize = 10;
+  const size_t kPenalty = 5;
   PartitionTreeNode* root =
       PartitionTreeNode::CreateRootNode(kVector, kNumPartitions);
   EXPECT_TRUE(root->CreateChildren(kMaxSize));
   ASSERT_TRUE(NULL != root->left_child());
   ASSERT_TRUE(NULL != root->right_child());
-  EXPECT_EQ(3, root->left_child()->this_size());
-  EXPECT_EQ(2, root->right_child()->this_size());
+  EXPECT_EQ(3u, root->left_child()->this_size());
+  EXPECT_EQ(2u, root->right_child()->this_size());
   EXPECT_EQ(11, root->right_child()->Cost(kPenalty));
   EXPECT_FALSE(root->left_child()->packet_start());
   EXPECT_TRUE(root->right_child()->packet_start());
@@ -45,17 +45,17 @@
 }
 
 TEST(PartitionTreeNode, FindOptimalConfig) {
-  const int kVector[] = {197, 194, 213, 215, 184, 199, 197, 207};
-  const int kNumPartitions = sizeof(kVector) / sizeof(kVector[0]);
-  const int kMaxSize = 1500;
-  const int kPenalty = 1;
+  const size_t kVector[] = {197, 194, 213, 215, 184, 199, 197, 207};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kVector);
+  const size_t kMaxSize = 1500;
+  const size_t kPenalty = 1;
   PartitionTreeNode* root =
       PartitionTreeNode::CreateRootNode(kVector, kNumPartitions);
   root->set_max_parent_size(500);
   root->set_min_parent_size(300);
   PartitionTreeNode* opt = root->GetOptimalNode(kMaxSize, kPenalty);
   ASSERT_TRUE(opt != NULL);
-  EXPECT_EQ(4, opt->NumPackets());
+  EXPECT_EQ(4u, opt->NumPackets());
   // Expect optimal sequence to be {1, 0, 1, 0, 1, 0, 1, 0}, which corresponds
   // to (right)-left-right-left-right-left-right-left, where the root node is
   // implicitly a "right" node by definition.
@@ -76,23 +76,24 @@
 }
 
 TEST(PartitionTreeNode, FindOptimalConfigSinglePartition) {
-  const int kVector[] = {17};
-  const int kNumPartitions = sizeof(kVector) / sizeof(kVector[0]);
-  const int kMaxSize = 1500;
-  const int kPenalty = 1;
+  const size_t kVector[] = {17};
+  const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kVector);
+  const size_t kMaxSize = 1500;
+  const size_t kPenalty = 1;
   PartitionTreeNode* root =
       PartitionTreeNode::CreateRootNode(kVector, kNumPartitions);
   PartitionTreeNode* opt = root->GetOptimalNode(kMaxSize, kPenalty);
   ASSERT_TRUE(opt != NULL);
-  EXPECT_EQ(1, opt->NumPackets());
+  EXPECT_EQ(1u, opt->NumPackets());
   EXPECT_TRUE(opt == root);
   delete root;
 }
 
-static void VerifyConfiguration(const int* expected_config,
-                                size_t expected_config_len,
-                                const std::vector<int>& opt_config,
-                                const RTPFragmentationHeader& fragmentation) {
+static void VerifyConfiguration(
+    const size_t* expected_config,
+    size_t expected_config_len,
+    const Vp8PartitionAggregator::ConfigVec& opt_config,
+    const RTPFragmentationHeader& fragmentation) {
   ASSERT_EQ(expected_config_len, fragmentation.fragmentationVectorSize);
   EXPECT_EQ(expected_config_len, opt_config.size());
   for (size_t i = 0; i < expected_config_len; ++i) {
@@ -101,7 +102,7 @@
 }
 
 static void VerifyMinMax(const Vp8PartitionAggregator& aggregator,
-                         const std::vector<int>& opt_config,
+                         const Vp8PartitionAggregator::ConfigVec& opt_config,
                          int expected_min,
                          int expected_max) {
   int min_size = -1;
@@ -133,13 +134,12 @@
   Vp8PartitionAggregator* aggregator =
       new Vp8PartitionAggregator(fragmentation, 0, 7);
   aggregator->SetPriorMinMax(300, 500);
-  int kMaxSize = 1500;
-  int kPenalty = 1;
-  std::vector<int> opt_config = aggregator->FindOptimalConfiguration(kMaxSize,
-                                                                     kPenalty);
-  const int kExpectedConfig[] = {0, 0, 1, 1, 2, 2, 3, 3};
-  const size_t kExpectedConfigSize =
-      sizeof(kExpectedConfig) / sizeof(kExpectedConfig[0]);
+  size_t kMaxSize = 1500;
+  size_t kPenalty = 1;
+  Vp8PartitionAggregator::ConfigVec opt_config =
+      aggregator->FindOptimalConfiguration(kMaxSize, kPenalty);
+  const size_t kExpectedConfig[] = {0, 0, 1, 1, 2, 2, 3, 3};
+  const size_t kExpectedConfigSize = GTEST_ARRAY_SIZE_(kExpectedConfig);
   VerifyConfiguration(kExpectedConfig, kExpectedConfigSize, opt_config,
                       fragmentation);
   VerifyMinMax(*aggregator, opt_config, 383, 428);
@@ -166,13 +166,12 @@
   fragmentation.fragmentationLength[7] = 200;
   Vp8PartitionAggregator* aggregator =
       new Vp8PartitionAggregator(fragmentation, 0, 7);
-  int kMaxSize = 1500;
-  int kPenalty = 1;
-  std::vector<int> opt_config = aggregator->FindOptimalConfiguration(kMaxSize,
-                                                                     kPenalty);
-  const int kExpectedConfig[] = {0, 0, 0, 0, 1, 1, 1, 1};
-  const size_t kExpectedConfigSize =
-      sizeof(kExpectedConfig) / sizeof(kExpectedConfig[0]);
+  size_t kMaxSize = 1500;
+  size_t kPenalty = 1;
+  Vp8PartitionAggregator::ConfigVec opt_config =
+      aggregator->FindOptimalConfiguration(kMaxSize, kPenalty);
+  const size_t kExpectedConfig[] = {0, 0, 0, 0, 1, 1, 1, 1};
+  const size_t kExpectedConfigSize = GTEST_ARRAY_SIZE_(kExpectedConfig);
   VerifyConfiguration(kExpectedConfig, kExpectedConfigSize, opt_config,
                       fragmentation);
   VerifyMinMax(*aggregator, opt_config, 800, 800);
@@ -185,13 +184,12 @@
   fragmentation.fragmentationLength[0] = 17;
   Vp8PartitionAggregator* aggregator =
       new Vp8PartitionAggregator(fragmentation, 0, 0);
-  int kMaxSize = 1500;
-  int kPenalty = 1;
-  std::vector<int> opt_config = aggregator->FindOptimalConfiguration(kMaxSize,
-                                                                     kPenalty);
-  const int kExpectedConfig[] = {0};
-  const size_t kExpectedConfigSize =
-      sizeof(kExpectedConfig) / sizeof(kExpectedConfig[0]);
+  size_t kMaxSize = 1500;
+  size_t kPenalty = 1;
+  Vp8PartitionAggregator::ConfigVec opt_config =
+      aggregator->FindOptimalConfiguration(kMaxSize, kPenalty);
+  const size_t kExpectedConfig[] = {0};
+  const size_t kExpectedConfigSize = GTEST_ARRAY_SIZE_(kExpectedConfig);
   VerifyConfiguration(kExpectedConfig, kExpectedConfigSize, opt_config,
                       fragmentation);
   VerifyMinMax(*aggregator, opt_config, 17, 17);
@@ -200,13 +198,13 @@
 
 TEST(Vp8PartitionAggregator, TestCalcNumberOfFragments) {
   const int kMTU = 1500;
-  EXPECT_EQ(2,
+  EXPECT_EQ(2u,
             Vp8PartitionAggregator::CalcNumberOfFragments(
                 1600, kMTU, 1, 300, 900));
-  EXPECT_EQ(3,
+  EXPECT_EQ(3u,
             Vp8PartitionAggregator::CalcNumberOfFragments(
                 1600, kMTU, 1, 300, 798));
-  EXPECT_EQ(2,
+  EXPECT_EQ(2u,
             Vp8PartitionAggregator::CalcNumberOfFragments(
                 1600, kMTU, 1, 900, 1000));
 }
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/BWEStandAlone.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/BWEStandAlone.cc
index 9e706e7..77ee6fb 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/BWEStandAlone.cc
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/BWEStandAlone.cc
@@ -33,12 +33,12 @@
 protected:
     // Inherited from UdpTransportData
     virtual void IncomingRTPPacket(const int8_t* incomingRtpPacket,
-                                   const int32_t rtpPacketLength,
+                                   const size_t rtpPacketLength,
                                    const int8_t* fromIP,
                                    const uint16_t fromPort) OVERRIDE;
 
     virtual void IncomingRTCPPacket(const int8_t* incomingRtcpPacket,
-                                    const int32_t rtcpPacketLength,
+                                    const size_t rtcpPacketLength,
                                     const int8_t* fromIP,
                                     const uint16_t fromPort) OVERRIDE;
 
@@ -47,21 +47,21 @@
 };
 
 void myTransportCB::IncomingRTPPacket(const int8_t* incomingRtpPacket,
-                                      const int32_t rtpPacketLength,
+                                      const size_t rtpPacketLength,
                                       const int8_t* fromIP,
                                       const uint16_t fromPort)
 {
     printf("Receiving RTP from IP %s, port %u\n", fromIP, fromPort);
-    _rtpMod->IncomingPacket((uint8_t *) incomingRtpPacket, static_cast<uint16_t>(rtpPacketLength));
+    _rtpMod->IncomingPacket((uint8_t *) incomingRtpPacket, rtpPacketLength);
 }
 
 void myTransportCB::IncomingRTCPPacket(const int8_t* incomingRtcpPacket,
-                                       const int32_t rtcpPacketLength,
+                                       const size_t rtcpPacketLength,
                                        const int8_t* fromIP,
                                        const uint16_t fromPort)
 {
     printf("Receiving RTCP from IP %s, port %u\n", fromIP, fromPort);
-    _rtpMod->IncomingPacket((uint8_t *) incomingRtcpPacket, static_cast<uint16_t>(rtcpPacketLength));
+    _rtpMod->IncomingPacket((uint8_t *) incomingRtcpPacket, rtcpPacketLength);
 }
 
 
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
index 6a66f26..6b322f7 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
@@ -131,7 +131,7 @@
 
 int TestLoadGenerator::sendPayload (const uint32_t timeStamp,
                                     const uint8_t* payloadData,
-                                    const uint32_t payloadSize,
+                                    const size_t payloadSize,
                                     const webrtc::FrameType frameType /*= webrtc::kVideoFrameDelta*/)
 {
 
@@ -139,7 +139,10 @@
 }
 
 
-CBRGenerator::CBRGenerator (TestSenderReceiver *sender, int32_t payloadSizeBytes, int32_t bitrateKbps, int32_t rtpSampleRate)
+CBRGenerator::CBRGenerator (TestSenderReceiver *sender,
+                            size_t payloadSizeBytes,
+                            int32_t bitrateKbps,
+                            int32_t rtpSampleRate)
 :
 //_eventPtr(NULL),
 _payloadSizeBytes(payloadSizeBytes),
@@ -300,10 +303,10 @@
     return true;
 }
 
-int32_t CBRFixFRGenerator::nextPayloadSize()
+size_t CBRFixFRGenerator::nextPayloadSize()
 {
     const double periodMs = 1000.0 / _frameRateFps;
-    return static_cast<int32_t>(_bitrateKbps * periodMs / 8 + 0.5);
+    return static_cast<size_t>(_bitrateKbps * periodMs / 8 + 0.5);
 }
 
 int CBRFixFRGenerator::generatePayload ( uint32_t timestamp )
@@ -313,7 +316,7 @@
     double factor = ((double) rand() - RAND_MAX/2) / RAND_MAX; // [-0.5; 0.5]
     factor = 1 + 2 * _spreadFactor * factor; // [1 - _spreadFactor ; 1 + _spreadFactor]
 
-    int32_t thisPayloadBytes = static_cast<int32_t>(_payloadSizeBytes * factor);
+    size_t thisPayloadBytes = static_cast<size_t>(_payloadSizeBytes * factor);
     // sanity
     if (thisPayloadBytes > _payloadAllocLen)
     {
@@ -338,15 +341,17 @@
 {
 }
 
-int32_t PeriodicKeyFixFRGenerator::nextPayloadSize()
+size_t PeriodicKeyFixFRGenerator::nextPayloadSize()
 {
     // calculate payload size for a delta frame
-    int32_t payloadSizeBytes = static_cast<int32_t>(1000 * _bitrateKbps / (8.0 * _frameRateFps * (1.0 + (_keyFactor - 1.0) / _keyPeriod)) + 0.5);
+    size_t payloadSizeBytes = static_cast<size_t>(1000 * _bitrateKbps /
+        (8.0 * _frameRateFps * (1.0 + (_keyFactor - 1.0) / _keyPeriod)) + 0.5);
 
     if (_frameCount % _keyPeriod == 0)
     {
         // this is a key frame, scale the payload size
-        payloadSizeBytes = static_cast<int32_t>(_keyFactor * _payloadSizeBytes + 0.5);
+        payloadSizeBytes =
+            static_cast<size_t>(_keyFactor * _payloadSizeBytes + 0.5);
     }
     _frameCount++;
 
@@ -396,7 +401,7 @@
     printf("New frame rate: %d\n", _frameRateFps);
 }
 
-int32_t CBRVarFRGenerator::nextPayloadSize()
+size_t CBRVarFRGenerator::nextPayloadSize()
 {
     ChangeFrameRate();
     return CBRFixFRGenerator::nextPayloadSize();
@@ -416,7 +421,7 @@
 {
 }
 
-int32_t CBRFrameDropGenerator::nextPayloadSize()
+size_t CBRFrameDropGenerator::nextPayloadSize()
 {
     _accBits -= 1000 * _bitrateKbps / _frameRateFps;
     if (_accBits < 0)
@@ -432,8 +437,10 @@
     {
         //printf("keep\n");
         const double periodMs = 1000.0 / _frameRateFps;
-        int32_t frameSize = static_cast<int32_t>(_bitrateKbps * periodMs / 8 + 0.5);
-        frameSize = std::max(frameSize, static_cast<int32_t>(300 * periodMs / 8 + 0.5));
+        size_t frameSize =
+            static_cast<size_t>(_bitrateKbps * periodMs / 8 + 0.5);
+        frameSize =
+            std::max(frameSize, static_cast<size_t>(300 * periodMs / 8 + 0.5));
         _accBits += frameSize * 8;
         return frameSize;
     }
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
index 61ebec8..fafdbf0 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
@@ -39,7 +39,7 @@
     int generatePayload ();
     int sendPayload (const uint32_t timeStamp,
         const uint8_t* payloadData,
-        const uint32_t payloadSize,
+        const size_t payloadSize,
         const webrtc::FrameType frameType = webrtc::kVideoFrameDelta);
 
     webrtc::CriticalSectionWrapper* _critSect;
@@ -55,7 +55,10 @@
 class CBRGenerator : public TestLoadGenerator
 {
 public:
-    CBRGenerator (TestSenderReceiver *sender, int32_t payloadSizeBytes, int32_t bitrateKbps, int32_t rtpSampleRate = 90000);
+    CBRGenerator (TestSenderReceiver *sender,
+                  size_t payloadSizeBytes,
+                  int32_t bitrateKbps,
+                  int32_t rtpSampleRate = 90000);
     virtual ~CBRGenerator ();
 
     virtual int32_t Start () {return (TestLoadGenerator::Start("CBRGenerator"));};
@@ -65,7 +68,7 @@
 protected:
     virtual int generatePayload ( uint32_t timestamp );
 
-    int32_t _payloadSizeBytes;
+    size_t _payloadSizeBytes;
     uint8_t *_payload;
 };
 
@@ -82,12 +85,12 @@
     virtual bool GeneratorLoop ();
 
 protected:
-    virtual int32_t nextPayloadSize ();
+    virtual size_t nextPayloadSize ();
     virtual int generatePayload ( uint32_t timestamp );
 
-    int32_t _payloadSizeBytes;
+    size_t _payloadSizeBytes;
     uint8_t *_payload;
-    int32_t _payloadAllocLen;
+    size_t _payloadAllocLen;
     int32_t _frameRateFps;
     double      _spreadFactor;
 };
@@ -100,7 +103,7 @@
     virtual ~PeriodicKeyFixFRGenerator () {}
 
 protected:
-    virtual int32_t nextPayloadSize ();
+    virtual size_t nextPayloadSize ();
 
     double          _keyFactor;
     uint32_t    _keyPeriod;
@@ -120,7 +123,7 @@
 
 protected:
     virtual void ChangeFrameRate();
-    virtual int32_t nextPayloadSize ();
+    virtual size_t nextPayloadSize ();
 
     double       _avgFrPeriodMs;
     double       _frSpreadFactor;
@@ -138,7 +141,7 @@
     ~CBRFrameDropGenerator();
 
 protected:
-    virtual int32_t nextPayloadSize();
+    virtual size_t nextPayloadSize();
 
     double       _accBits;
 };
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
index a536ebc..50c1981 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
@@ -256,9 +256,9 @@
 
 int32_t TestSenderReceiver::ReceiveBitrateKbps ()
 {
-    uint32_t bytesSent;
+    size_t bytesSent;
     uint32_t packetsSent;
-    uint32_t bytesReceived;
+    size_t bytesReceived;
     uint32_t packetsReceived;
 
     if (_rtp->DataCountersRTP(&bytesSent, &packetsSent, &bytesReceived, &packetsReceived) == 0)
@@ -290,7 +290,7 @@
 
 
 int32_t TestSenderReceiver::OnReceivedPayloadData(const uint8_t* payloadData,
-                                                  const uint16_t payloadSize,
+                                                  const size_t payloadSize,
                                                   const webrtc::WebRtcRTPHeader* rtpHeader)
 {
     //printf("OnReceivedPayloadData\n");
@@ -299,21 +299,21 @@
 
 
 void TestSenderReceiver::IncomingRTPPacket(const int8_t* incomingRtpPacket,
-                                      const int32_t rtpPacketLength,
-                                      const int8_t* fromIP,
-                                      const uint16_t fromPort)
+                                           const size_t rtpPacketLength,
+                                           const int8_t* fromIP,
+                                           const uint16_t fromPort)
 {
-    _rtp->IncomingPacket((uint8_t *) incomingRtpPacket, static_cast<uint16_t>(rtpPacketLength));
+    _rtp->IncomingPacket((uint8_t *) incomingRtpPacket, rtpPacketLength);
 }
 
 
 
 void TestSenderReceiver::IncomingRTCPPacket(const int8_t* incomingRtcpPacket,
-                                       const int32_t rtcpPacketLength,
-                                       const int8_t* fromIP,
-                                       const uint16_t fromPort)
+                                            const size_t rtcpPacketLength,
+                                            const int8_t* fromIP,
+                                            const uint16_t fromPort)
 {
-    _rtp->IncomingPacket((uint8_t *) incomingRtcpPacket, static_cast<uint16_t>(rtcpPacketLength));
+    _rtp->IncomingPacket((uint8_t *) incomingRtcpPacket, rtcpPacketLength);
 }
 
 
@@ -386,7 +386,7 @@
 int32_t
 TestSenderReceiver::SendOutgoingData(const uint32_t timeStamp,
                                      const uint8_t* payloadData,
-                                     const uint32_t payloadSize,
+                                     const size_t payloadSize,
                                      const webrtc::FrameType frameType /*= webrtc::kVideoFrameDelta*/)
 {
     return (_rtp->SendOutgoingData(frameType, _payloadType, timeStamp, payloadData, payloadSize));
diff --git a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
index 3968e65..30a84c9 100644
--- a/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
+++ b/webrtc/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
@@ -90,18 +90,18 @@
     // Inherited from RtpData
     virtual int32_t OnReceivedPayloadData(
         const uint8_t* payloadData,
-        const uint16_t payloadSize,
+        const size_t payloadSize,
         const webrtc::WebRtcRTPHeader* rtpHeader) OVERRIDE;
 
 
     // Inherited from UdpTransportData
     virtual void IncomingRTPPacket(const int8_t* incomingRtpPacket,
-                                   const int32_t rtpPacketLength,
+                                   const size_t rtpPacketLength,
                                    const int8_t* fromIP,
                                    const uint16_t fromPort) OVERRIDE;
 
     virtual void IncomingRTCPPacket(const int8_t* incomingRtcpPacket,
-                                    const int32_t rtcpPacketLength,
+                                    const size_t rtcpPacketLength,
                                     const int8_t* fromIP,
                                     const uint16_t fromPort) OVERRIDE;
 
@@ -118,7 +118,7 @@
 
     int32_t SendOutgoingData(const uint32_t timeStamp,
         const uint8_t* payloadData,
-        const uint32_t payloadSize,
+        const size_t payloadSize,
         const webrtc::FrameType frameType = webrtc::kVideoFrameDelta);
 
     int32_t SetLoadGenerator(TestLoadGenerator *generator);
@@ -150,7 +150,7 @@
     bool _isSender;
     bool _isReceiver;
     SendRecCB * _sendRecCB;
-    uint32_t _lastBytesReceived;
+    size_t _lastBytesReceived;
     int64_t _lastTime;
 
 };
diff --git a/webrtc/modules/rtp_rtcp/test/testAPI/test_api.h b/webrtc/modules/rtp_rtcp/test/testAPI/test_api.h
index bd9d197..0085641 100644
--- a/webrtc/modules/rtp_rtcp/test/testAPI/test_api.h
+++ b/webrtc/modules/rtp_rtcp/test/testAPI/test_api.h
@@ -43,7 +43,7 @@
   void DropEveryNthPacket(int n) {
     _packetLoss = n;
   }
-  virtual int SendPacket(int channel, const void *data, int len) OVERRIDE {
+  virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE {
     _count++;
     if (_packetLoss > 0) {
       if ((_count % _packetLoss) == 0) {
@@ -52,9 +52,7 @@
     }
     RTPHeader header;
     scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
-    if (!parser->Parse(static_cast<const uint8_t*>(data),
-                       static_cast<size_t>(len),
-                       &header)) {
+    if (!parser->Parse(static_cast<const uint8_t*>(data), len, &header)) {
       return -1;
     }
     PayloadUnion payload_specific;
@@ -70,11 +68,13 @@
     }
     return len;
   }
-  virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE {
+  virtual int SendRTCPPacket(int channel,
+                             const void *data,
+                             size_t len) OVERRIDE {
     if (_rtpRtcpModule->IncomingRtcpPacket((const uint8_t*)data, len) < 0) {
       return -1;
     }
-    return len;
+    return static_cast<int>(len);
   }
  private:
   int _count;
@@ -90,7 +90,7 @@
 
   virtual int32_t OnReceivedPayloadData(
       const uint8_t* payloadData,
-      const uint16_t payloadSize,
+      const size_t payloadSize,
       const webrtc::WebRtcRTPHeader* rtpHeader) OVERRIDE {
     EXPECT_LE(payloadSize, sizeof(_payloadData));
     memcpy(_payloadData, payloadData, payloadSize);
@@ -103,7 +103,7 @@
     return _payloadData;
   }
 
-  uint16_t payload_size() const {
+  size_t payload_size() const {
     return _payloadSize;
   }
 
@@ -113,7 +113,7 @@
 
  private:
   uint8_t _payloadData[1500];
-  uint16_t _payloadSize;
+  size_t _payloadSize;
   webrtc::WebRtcRTPHeader _rtpHeader;
 };
 
diff --git a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc
index 0832f63..49ee83a 100644
--- a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc
+++ b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_audio.cc
@@ -27,11 +27,11 @@
  public:
   virtual int32_t OnReceivedPayloadData(
       const uint8_t* payloadData,
-      const uint16_t payloadSize,
+      const size_t payloadSize,
       const webrtc::WebRtcRTPHeader* rtpHeader) OVERRIDE {
     if (rtpHeader->header.payloadType == 98 ||
         rtpHeader->header.payloadType == 99) {
-      EXPECT_EQ(4, payloadSize);
+      EXPECT_EQ(4u, payloadSize);
       char str[5];
       memcpy(str, payloadData, payloadSize);
       str[4] = 0;
@@ -265,10 +265,10 @@
 
   RTPFragmentationHeader fragmentation;
   fragmentation.fragmentationVectorSize = 2;
-  fragmentation.fragmentationLength = new uint32_t[2];
+  fragmentation.fragmentationLength = new size_t[2];
   fragmentation.fragmentationLength[0] = 4;
   fragmentation.fragmentationLength[1] = 4;
-  fragmentation.fragmentationOffset = new uint32_t[2];
+  fragmentation.fragmentationOffset = new size_t[2];
   fragmentation.fragmentationOffset[0] = 0;
   fragmentation.fragmentationOffset[1] = 4;
   fragmentation.fragmentationTimeDiff = new uint16_t[2];
diff --git a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc
index 4c4944d..ddcfa96 100644
--- a/webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc
+++ b/webrtc/modules/rtp_rtcp/test/testAPI/test_api_video.cc
@@ -73,43 +73,42 @@
 
     payload_data_length_ = sizeof(video_frame_);
 
-    for (int n = 0; n < payload_data_length_; n++) {
+    for (size_t n = 0; n < payload_data_length_; n++) {
       video_frame_[n] = n%10;
     }
   }
 
-  int32_t BuildRTPheader(uint8_t* dataBuffer,
-                               uint32_t timestamp,
-                               uint32_t sequence_number) {
+  size_t BuildRTPheader(uint8_t* dataBuffer,
+                         uint32_t timestamp,
+                         uint32_t sequence_number) {
     dataBuffer[0] = static_cast<uint8_t>(0x80);  // version 2
     dataBuffer[1] = static_cast<uint8_t>(kPayloadType);
     RtpUtility::AssignUWord16ToBuffer(dataBuffer + 2, sequence_number);
     RtpUtility::AssignUWord32ToBuffer(dataBuffer + 4, timestamp);
     RtpUtility::AssignUWord32ToBuffer(dataBuffer + 8, 0x1234);  // SSRC.
-    int32_t rtpHeaderLength = 12;
+    size_t rtpHeaderLength = 12;
     return rtpHeaderLength;
   }
 
-  int PaddingPacket(uint8_t* buffer,
-                    uint32_t timestamp,
-                    uint32_t sequence_number,
-                    int32_t bytes) {
+  size_t PaddingPacket(uint8_t* buffer,
+                       uint32_t timestamp,
+                       uint32_t sequence_number,
+                       size_t bytes) {
     // Max in the RFC 3550 is 255 bytes, we limit it to be modulus 32 for SRTP.
-    int max_length = 224;
+    size_t max_length = 224;
 
-    int padding_bytes_in_packet = max_length;
+    size_t padding_bytes_in_packet = max_length;
     if (bytes < max_length) {
       padding_bytes_in_packet = (bytes + 16) & 0xffe0;  // Keep our modulus 32.
     }
     // Correct seq num, timestamp and payload type.
-    int header_length = BuildRTPheader(buffer, timestamp,
-                                       sequence_number);
+    size_t header_length = BuildRTPheader(buffer, timestamp, sequence_number);
     buffer[0] |= 0x20;  // Set padding bit.
     int32_t* data =
         reinterpret_cast<int32_t*>(&(buffer[header_length]));
 
     // Fill data buffer with random data.
-    for (int j = 0; j < (padding_bytes_in_packet >> 2); j++) {
+    for (size_t j = 0; j < (padding_bytes_in_packet >> 2); j++) {
       data[j] = rand();  // NOLINT
     }
     // Set number of padding bytes in the last byte of the packet.
@@ -135,7 +134,7 @@
   uint32_t test_timestamp_;
   uint16_t test_sequence_number_;
   uint8_t  video_frame_[65000];
-  int payload_data_length_;
+  size_t payload_data_length_;
   SimulatedClock fake_clock;
   enum { kPayloadType = 100 };
 };
@@ -150,7 +149,7 @@
 }
 
 TEST_F(RtpRtcpVideoTest, PaddingOnlyFrames) {
-  const int kPadSize = 255;
+  const size_t kPadSize = 255;
   uint8_t padding_packet[kPadSize];
   uint32_t seq_num = 0;
   uint32_t timestamp = 3000;
@@ -165,8 +164,8 @@
                                                      codec.maxBitrate));
   for (int frame_idx = 0; frame_idx < 10; ++frame_idx) {
     for (int packet_idx = 0; packet_idx < 5; ++packet_idx) {
-      int packet_size = PaddingPacket(padding_packet, timestamp, seq_num,
-                                      kPadSize);
+      size_t packet_size = PaddingPacket(padding_packet, timestamp, seq_num,
+                                         kPadSize);
       ++seq_num;
       RTPHeader header;
       scoped_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
@@ -175,11 +174,11 @@
       EXPECT_TRUE(rtp_payload_registry_.GetPayloadSpecifics(header.payloadType,
                                                            &payload_specific));
       const uint8_t* payload = padding_packet + header.headerLength;
-      const int payload_length = packet_size - header.headerLength;
+      const size_t payload_length = packet_size - header.headerLength;
       EXPECT_TRUE(rtp_receiver_->IncomingRtpPacket(header, payload,
                                                    payload_length,
                                                    payload_specific, true));
-      EXPECT_EQ(0, receiver_->payload_size());
+      EXPECT_EQ(0u, receiver_->payload_size());
       EXPECT_EQ(payload_length, receiver_->rtp_header().header.paddingLength);
     }
     timestamp += 3000;
diff --git a/webrtc/modules/rtp_rtcp/test/testFec/test_fec.cc b/webrtc/modules/rtp_rtcp/test/testFec/test_fec.cc
index bdb53af..f1353b8 100644
--- a/webrtc/modules/rtp_rtcp/test/testFec/test_fec.cc
+++ b/webrtc/modules/rtp_rtcp/test/testFec/test_fec.cc
@@ -232,7 +232,7 @@
             for (uint32_t i = 0; i < numMediaPackets; ++i) {
               mediaPacket = new ForwardErrorCorrection::Packet;
               mediaPacketList.push_back(mediaPacket);
-              mediaPacket->length = static_cast<uint16_t>(
+              mediaPacket->length = static_cast<size_t>(
                   (static_cast<float>(rand()) / RAND_MAX) *
                   (IP_PACKET_SIZE - 12 - 28 -
                    ForwardErrorCorrection::PacketOverhead()));
@@ -264,7 +264,7 @@
                                                 timeStamp);
               RtpUtility::AssignUWord32ToBuffer(&mediaPacket->data[8], ssrc);
               // Generate random values for payload
-              for (int32_t j = 12; j < mediaPacket->length; ++j) {
+              for (size_t j = 12; j < mediaPacket->length; ++j) {
                 mediaPacket->data[j] = static_cast<uint8_t>(rand() % 256);
               }
               seqNum++;
diff --git a/webrtc/modules/utility/interface/rtp_dump.h b/webrtc/modules/utility/interface/rtp_dump.h
index 6c2dc7c..df45ae2 100644
--- a/webrtc/modules/utility/interface/rtp_dump.h
+++ b/webrtc/modules/utility/interface/rtp_dump.h
@@ -43,7 +43,7 @@
     // Note: packet should contain the RTP/RTCP part of the packet. I.e. the
     // first bytes of packet should be the RTP/RTCP header.
     virtual int32_t DumpPacket(const uint8_t* packet,
-                               uint16_t packetLength) = 0;
+                               size_t packetLength) = 0;
 
 protected:
     virtual ~RtpDump();
diff --git a/webrtc/modules/utility/source/coder.cc b/webrtc/modules/utility/source/coder.cc
index 11a462a..5a39748 100644
--- a/webrtc/modules/utility/source/coder.cc
+++ b/webrtc/modules/utility/source/coder.cc
@@ -54,7 +54,7 @@
 int32_t AudioCoder::Decode(AudioFrame& decodedAudio,
                            uint32_t sampFreqHz,
                            const int8_t*  incomingPayload,
-                           int32_t  payloadLength)
+                           size_t  payloadLength)
 {
     if (payloadLength > 0)
     {
@@ -79,7 +79,7 @@
 
 int32_t AudioCoder::Encode(const AudioFrame& audio,
                            int8_t* encodedData,
-                           uint32_t& encodedLengthInBytes)
+                           size_t& encodedLengthInBytes)
 {
     // Fake a timestamp in case audio doesn't contain a correct timestamp.
     // Make a local copy of the audio frame since audio is const
@@ -109,7 +109,7 @@
     uint8_t   /* payloadType */,
     uint32_t  /* timeStamp */,
     const uint8_t*  payloadData,
-    uint16_t  payloadSize,
+    size_t  payloadSize,
     const RTPFragmentationHeader* /* fragmentation*/)
 {
     memcpy(_encodedData,payloadData,sizeof(uint8_t) * payloadSize);
diff --git a/webrtc/modules/utility/source/coder.h b/webrtc/modules/utility/source/coder.h
index e04372d..0363690 100644
--- a/webrtc/modules/utility/source/coder.h
+++ b/webrtc/modules/utility/source/coder.h
@@ -34,12 +34,12 @@
         ACMAMRPackingFormat amrFormat = AMRBandwidthEfficient);
 
     int32_t Decode(AudioFrame& decodedAudio, uint32_t sampFreqHz,
-                   const int8_t* incomingPayload, int32_t payloadLength);
+                   const int8_t* incomingPayload, size_t payloadLength);
 
     int32_t PlayoutData(AudioFrame& decodedAudio, uint16_t& sampFreqHz);
 
     int32_t Encode(const AudioFrame& audio, int8_t* encodedData,
-                   uint32_t& encodedLengthInBytes);
+                   size_t& encodedLengthInBytes);
 
 protected:
     virtual int32_t SendData(
@@ -47,7 +47,7 @@
         uint8_t payloadType,
         uint32_t timeStamp,
         const uint8_t* payloadData,
-        uint16_t payloadSize,
+        size_t payloadSize,
         const RTPFragmentationHeader* fragmentation) OVERRIDE;
 
 private:
@@ -57,7 +57,7 @@
 
     uint32_t _encodeTimestamp;
     int8_t*  _encodedData;
-    uint32_t _encodedLengthInBytes;
+    size_t _encodedLengthInBytes;
 
     uint32_t _decodeTimestamp;
 };
diff --git a/webrtc/modules/utility/source/file_player_impl.cc b/webrtc/modules/utility/source/file_player_impl.cc
index 8049245..29f7042 100644
--- a/webrtc/modules/utility/source/file_player_impl.cc
+++ b/webrtc/modules/utility/source/file_player_impl.cc
@@ -124,7 +124,7 @@
         unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq;
 
         // L16 is un-encoded data. Just pull 10 ms.
-        uint32_t lengthInBytes =
+        size_t lengthInBytes =
             sizeof(unresampledAudioFrame.data_);
         if (_fileModule.PlayoutAudioData(
                 (int8_t*)unresampledAudioFrame.data_,
@@ -147,11 +147,11 @@
         // expects a full frame. If the frame size is larger than 10 ms,
         // PlayoutAudioData(..) data should be called proportionally less often.
         int16_t encodedBuffer[MAX_AUDIO_BUFFER_IN_SAMPLES];
-        uint32_t encodedLengthInBytes = 0;
+        size_t encodedLengthInBytes = 0;
         if(++_numberOf10MsInDecoder >= _numberOf10MsPerFrame)
         {
             _numberOf10MsInDecoder = 0;
-            uint32_t bytesFromFile = sizeof(encodedBuffer);
+            size_t bytesFromFile = sizeof(encodedBuffer);
             if (_fileModule.PlayoutAudioData((int8_t*)encodedBuffer,
                                              bytesFromFile) == -1)
             {
@@ -581,7 +581,7 @@
         if(_fileFormat == kFileFormatAviFile)
         {
             // Get next video frame
-            uint32_t encodedBufferLengthInBytes = _encodedData.bufferSize;
+            size_t encodedBufferLengthInBytes = _encodedData.bufferSize;
             if(_fileModule.PlayoutAVIVideoData(
                    reinterpret_cast< int8_t*>(_encodedData.payloadData),
                    encodedBufferLengthInBytes) != 0)
@@ -656,7 +656,7 @@
 
     // Size of unencoded data (I420) should be the largest possible frame size
     // in a file.
-    const uint32_t KReadBufferSize = 3 * video_codec_info_.width *
+    const size_t KReadBufferSize = 3 * video_codec_info_.width *
         video_codec_info_.height / 2;
     _encodedData.VerifyAndAllocate(KReadBufferSize);
     _encodedData.encodedHeight = video_codec_info_.height;
diff --git a/webrtc/modules/utility/source/file_recorder_impl.cc b/webrtc/modules/utility/source/file_recorder_impl.cc
index 264b867..14c5288 100644
--- a/webrtc/modules/utility/source/file_recorder_impl.cc
+++ b/webrtc/modules/utility/source/file_recorder_impl.cc
@@ -227,7 +227,7 @@
     // NOTE: stereo recording is only supported for WAV files.
     // TODO (hellner): WAV expect PCM in little endian byte order. Not
     // "encoding" with PCM coder should be a problem for big endian systems.
-    uint32_t encodedLenInBytes = 0;
+    size_t encodedLenInBytes = 0;
     if (_fileFormat == kFileFormatPreencodedFile ||
         STR_CASE_CMP(codec_info_.plname, "L16") != 0)
     {
@@ -272,9 +272,8 @@
         uint16_t msOfData =
             ptrAudioFrame->samples_per_channel_ /
             uint16_t(ptrAudioFrame->sample_rate_hz_ / 1000);
-        if (WriteEncodedAudioData(_audioBuffer,
-                                  (uint16_t)encodedLenInBytes,
-                                  msOfData, playoutTS) == -1)
+        if (WriteEncodedAudioData(_audioBuffer, encodedLenInBytes, msOfData,
+                                  playoutTS) == -1)
         {
             return -1;
         }
@@ -309,7 +308,7 @@
 
 int32_t FileRecorderImpl::WriteEncodedAudioData(
     const int8_t* audioBuffer,
-    uint16_t bufferLength,
+    size_t bufferLength,
     uint16_t /*millisecondsOfData*/,
     const TickTime* /*playoutTS*/)
 {
@@ -398,7 +397,7 @@
     return FileRecorderImpl::StopRecording();
 }
 
-int32_t AviRecorder::CalcI420FrameSize( ) const
+size_t AviRecorder::CalcI420FrameSize( ) const
 {
     return 3 * _videoCodecInst.width * _videoCodecInst.height / 2;
 }
@@ -641,8 +640,8 @@
 
     if( STR_CASE_CMP(_videoCodecInst.plName, "I420") == 0)
     {
-       int length  = CalcBufferSize(kI420, videoFrame.width(),
-                                    videoFrame.height());
+       size_t length =
+           CalcBufferSize(kI420, videoFrame.width(), videoFrame.height());
         _videoEncodedData.VerifyAndAllocate(length);
 
         // I420 is raw data. No encoding needed (each sample is represented by
@@ -681,7 +680,7 @@
 // happens in AviRecorder::Process().
 int32_t AviRecorder::WriteEncodedAudioData(
     const int8_t* audioBuffer,
-    uint16_t bufferLength,
+    size_t bufferLength,
     uint16_t millisecondsOfData,
     const TickTime* playoutTS)
 {
diff --git a/webrtc/modules/utility/source/file_recorder_impl.h b/webrtc/modules/utility/source/file_recorder_impl.h
index 53fd26b..9e17fd6 100644
--- a/webrtc/modules/utility/source/file_recorder_impl.h
+++ b/webrtc/modules/utility/source/file_recorder_impl.h
@@ -86,7 +86,7 @@
 protected:
     virtual int32_t WriteEncodedAudioData(
         const int8_t* audioBuffer,
-        uint16_t bufferLength,
+        size_t bufferLength,
         uint16_t millisecondsOfData,
         const TickTime* playoutTS);
 
@@ -111,7 +111,7 @@
 {
     public:
        AudioFrameFileInfo(const int8_t* audioData,
-                     const uint16_t audioSize,
+                     const size_t audioSize,
                      const uint16_t audioMS,
                      const TickTime& playoutTS)
            : _audioData(), _audioSize(audioSize), _audioMS(audioMS),
@@ -127,7 +127,7 @@
        };
     // TODO (hellner): either turn into a struct or provide get/set functions.
     int8_t   _audioData[MAX_AUDIO_BUFFER_IN_BYTES];
-    uint16_t _audioSize;
+    size_t   _audioSize;
     uint16_t _audioMS;
     TickTime _playoutTS;
 };
@@ -151,7 +151,7 @@
 protected:
     virtual int32_t WriteEncodedAudioData(
         const int8_t*  audioBuffer,
-        uint16_t bufferLength,
+        size_t bufferLength,
         uint16_t millisecondsOfData,
         const TickTime* playoutTS);
 private:
@@ -165,7 +165,7 @@
     int32_t EncodeAndWriteVideoToFile(I420VideoFrame& videoFrame);
     int32_t ProcessAudio();
 
-    int32_t CalcI420FrameSize() const;
+    size_t CalcI420FrameSize() const;
     int32_t SetUpVideoEncoder();
 
     VideoCodec _videoCodecInst;
@@ -178,7 +178,7 @@
 
     FrameScaler* _frameScaler;
     VideoCoder* _videoEncoder;
-    int32_t _videoMaxPayloadSize;
+    size_t _videoMaxPayloadSize;
     EncodedVideoData _videoEncodedData;
 
     ThreadWrapper* _thread;
diff --git a/webrtc/modules/utility/source/rtp_dump_impl.cc b/webrtc/modules/utility/source/rtp_dump_impl.cc
index 547df33..cab4065 100644
--- a/webrtc/modules/utility/source/rtp_dump_impl.cc
+++ b/webrtc/modules/utility/source/rtp_dump_impl.cc
@@ -12,6 +12,7 @@
 
 #include <assert.h>
 #include <stdio.h>
+#include <limits>
 
 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
 #include "webrtc/system_wrappers/interface/logging.h"
@@ -145,7 +146,7 @@
     return _file.Open();
 }
 
-int32_t RtpDumpImpl::DumpPacket(const uint8_t* packet, uint16_t packetLength)
+int32_t RtpDumpImpl::DumpPacket(const uint8_t* packet, size_t packetLength)
 {
     CriticalSectionScoped lock(_critSect);
     if (!IsActive())
@@ -158,7 +159,9 @@
         return -1;
     }
 
-    if (packetLength < 1)
+    rtpDumpPktHdr_t hdr;
+    size_t total_size = packetLength + sizeof hdr;
+    if (packetLength < 1 || total_size > std::numeric_limits<uint16_t>::max())
     {
         return -1;
     }
@@ -167,11 +170,8 @@
     // considered RTP (without further verification).
     bool isRTCP = RTCP(packet);
 
-    rtpDumpPktHdr_t hdr;
-    uint32_t offset;
-
     // Offset is relative to when recording was started.
-    offset = GetTimeInMS();
+    uint32_t offset = GetTimeInMS();
     if (offset < _startTime)
     {
         // Compensate for wraparound.
@@ -181,7 +181,7 @@
     }
     hdr.offset = RtpDumpHtonl(offset);
 
-    hdr.length = RtpDumpHtons((uint16_t)(packetLength + sizeof(hdr)));
+    hdr.length = RtpDumpHtons((uint16_t)(total_size));
     if (isRTCP)
     {
         hdr.plen = 0;
diff --git a/webrtc/modules/utility/source/rtp_dump_impl.h b/webrtc/modules/utility/source/rtp_dump_impl.h
index 0b72132..5be9cbe 100644
--- a/webrtc/modules/utility/source/rtp_dump_impl.h
+++ b/webrtc/modules/utility/source/rtp_dump_impl.h
@@ -26,7 +26,7 @@
     virtual int32_t Stop() OVERRIDE;
     virtual bool IsActive() const OVERRIDE;
     virtual int32_t DumpPacket(const uint8_t* packet,
-                               uint16_t packetLength) OVERRIDE;
+                               size_t packetLength) OVERRIDE;
 private:
     // Return the system time in ms.
     inline uint32_t GetTimeInMS() const;
diff --git a/webrtc/modules/utility/source/video_coder.cc b/webrtc/modules/utility/source/video_coder.cc
index 5096ace..e0d969d 100644
--- a/webrtc/modules/utility/source/video_coder.cc
+++ b/webrtc/modules/utility/source/video_coder.cc
@@ -113,7 +113,7 @@
     const uint32_t timeStamp,
     int64_t capture_time_ms,
     const uint8_t* payloadData,
-    uint32_t payloadSize,
+    size_t payloadSize,
     const RTPFragmentationHeader& fragmentationHeader,
     const RTPVideoHeader* /*rtpVideoHdr*/)
 {
diff --git a/webrtc/modules/utility/source/video_coder.h b/webrtc/modules/utility/source/video_coder.h
index 03aa511..a1d1a17 100644
--- a/webrtc/modules/utility/source/video_coder.h
+++ b/webrtc/modules/utility/source/video_coder.h
@@ -53,7 +53,7 @@
         uint32_t /*timeStamp*/,
         int64_t capture_time_ms,
         const uint8_t* payloadData,
-        uint32_t payloadSize,
+        size_t payloadSize,
         const RTPFragmentationHeader& /* fragmentationHeader*/,
         const RTPVideoHeader* rtpTypeHdr) OVERRIDE;
 
diff --git a/webrtc/modules/video_capture/android/video_capture_android.cc b/webrtc/modules/video_capture/android/video_capture_android.cc
index 14dda7f..fa4dcda 100644
--- a/webrtc/modules/video_capture/android/video_capture_android.cc
+++ b/webrtc/modules/video_capture/android/video_capture_android.cc
@@ -106,7 +106,7 @@
 }
 
 int32_t VideoCaptureAndroid::OnIncomingFrame(uint8_t* videoFrame,
-                                             int32_t videoFrameLength,
+                                             size_t videoFrameLength,
                                              int32_t degrees,
                                              int64_t captureTime) {
   if (!_captureStarted)
diff --git a/webrtc/modules/video_capture/android/video_capture_android.h b/webrtc/modules/video_capture/android/video_capture_android.h
index f45b726..74de7a9 100644
--- a/webrtc/modules/video_capture/android/video_capture_android.h
+++ b/webrtc/modules/video_capture/android/video_capture_android.h
@@ -31,7 +31,7 @@
   virtual int32_t SetCaptureRotation(VideoCaptureRotation rotation);
 
   int32_t OnIncomingFrame(uint8_t* videoFrame,
-                          int32_t videoFrameLength,
+                          size_t videoFrameLength,
                           int32_t degrees,
                           int64_t captureTime = 0);
 
diff --git a/webrtc/modules/video_capture/include/video_capture_defines.h b/webrtc/modules/video_capture/include/video_capture_defines.h
index 330bfc7..ea7939d 100644
--- a/webrtc/modules/video_capture/include/video_capture_defines.h
+++ b/webrtc/modules/video_capture/include/video_capture_defines.h
@@ -92,7 +92,7 @@
 public:
     // |capture_time| must be specified in the NTP time format in milliseconds.
     virtual int32_t IncomingFrame(uint8_t* videoFrame,
-                                  int32_t videoFrameLength,
+                                  size_t videoFrameLength,
                                   const VideoCaptureCapability& frameInfo,
                                   int64_t captureTime = 0) = 0;
     virtual int32_t IncomingI420VideoFrame(I420VideoFrame* video_frame,
diff --git a/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm b/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm
index b5c53b1..f6302f1 100644
--- a/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm
+++ b/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.mm
@@ -368,13 +368,14 @@
 
   uint8_t* baseAddress =
       (uint8_t*)CVPixelBufferGetBaseAddressOfPlane(videoFrame, kYPlaneIndex);
-  int yPlaneBytesPerRow =
+  size_t yPlaneBytesPerRow =
       CVPixelBufferGetBytesPerRowOfPlane(videoFrame, kYPlaneIndex);
-  int yPlaneHeight = CVPixelBufferGetHeightOfPlane(videoFrame, kYPlaneIndex);
-  int uvPlaneBytesPerRow =
+  size_t yPlaneHeight = CVPixelBufferGetHeightOfPlane(videoFrame, kYPlaneIndex);
+  size_t uvPlaneBytesPerRow =
       CVPixelBufferGetBytesPerRowOfPlane(videoFrame, kUVPlaneIndex);
-  int uvPlaneHeight = CVPixelBufferGetHeightOfPlane(videoFrame, kUVPlaneIndex);
-  int frameSize =
+  size_t uvPlaneHeight =
+      CVPixelBufferGetHeightOfPlane(videoFrame, kUVPlaneIndex);
+  size_t frameSize =
       yPlaneBytesPerRow * yPlaneHeight + uvPlaneBytesPerRow * uvPlaneHeight;
 
   VideoCaptureCapability tempCaptureCapability;
diff --git a/webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_objc.mm b/webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_objc.mm
index 4120335..7cd7407 100644
--- a/webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_objc.mm
+++ b/webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_objc.mm
@@ -237,8 +237,8 @@
   if (CVPixelBufferLockBaseAddress(videoFrame, kFlags) == kCVReturnSuccess) {
     void *baseAddress = CVPixelBufferGetBaseAddress(videoFrame);
     size_t bytesPerRow = CVPixelBufferGetBytesPerRow(videoFrame);
-    int frameHeight = CVPixelBufferGetHeight(videoFrame);
-    int frameSize = bytesPerRow * frameHeight;
+    size_t frameHeight = CVPixelBufferGetHeight(videoFrame);
+    size_t frameSize = bytesPerRow * frameHeight;
 
     VideoCaptureCapability tempCaptureCapability;
     tempCaptureCapability.width = _frameWidth;
diff --git a/webrtc/modules/video_capture/test/video_capture_unittest.cc b/webrtc/modules/video_capture/test/video_capture_unittest.cc
index 59d58e7..8635c9c 100644
--- a/webrtc/modules/video_capture/test/video_capture_unittest.cc
+++ b/webrtc/modules/video_capture/test/video_capture_unittest.cc
@@ -477,9 +477,9 @@
 
 // Test input of external video frames.
 TEST_F(VideoCaptureExternalTest, TestExternalCapture) {
-  unsigned int length = webrtc::CalcBufferSize(webrtc::kI420,
-                                               test_frame_.width(),
-                                               test_frame_.height());
+  size_t length = webrtc::CalcBufferSize(webrtc::kI420,
+                                         test_frame_.width(),
+                                         test_frame_.height());
   webrtc::scoped_ptr<uint8_t[]> test_buffer(new uint8_t[length]);
   webrtc::ExtractBuffer(test_frame_, length, test_buffer.get());
   EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
@@ -563,9 +563,9 @@
   TickTime startTime = TickTime::Now();
 
   while ((TickTime::Now() - startTime).Milliseconds() < testTime * 1000) {
-     unsigned int length = webrtc::CalcBufferSize(webrtc::kI420,
-                                                 test_frame_.width(),
-                                                 test_frame_.height());
+     size_t length = webrtc::CalcBufferSize(webrtc::kI420,
+                                            test_frame_.width(),
+                                            test_frame_.height());
      webrtc::scoped_ptr<uint8_t[]> test_buffer(new uint8_t[length]);
      webrtc::ExtractBuffer(test_frame_, length, test_buffer.get());
      EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
@@ -579,9 +579,9 @@
 
   startTime = TickTime::Now();
   while ((TickTime::Now() - startTime).Milliseconds() < testTime * 1000) {
-    unsigned int length = webrtc::CalcBufferSize(webrtc::kI420,
-                                                 test_frame_.width(),
-                                                 test_frame_.height());
+    size_t length = webrtc::CalcBufferSize(webrtc::kI420,
+                                           test_frame_.width(),
+                                           test_frame_.height());
     webrtc::scoped_ptr<uint8_t[]> test_buffer(new uint8_t[length]);
     webrtc::ExtractBuffer(test_frame_, length, test_buffer.get());
     EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
@@ -597,9 +597,9 @@
 
 TEST_F(VideoCaptureExternalTest, Rotation) {
   EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kCameraRotate0));
-  unsigned int length = webrtc::CalcBufferSize(webrtc::kI420,
-                                               test_frame_.width(),
-                                               test_frame_.height());
+  size_t length = webrtc::CalcBufferSize(webrtc::kI420,
+                                         test_frame_.width(),
+                                         test_frame_.height());
   webrtc::scoped_ptr<uint8_t[]> test_buffer(new uint8_t[length]);
   webrtc::ExtractBuffer(test_frame_, length, test_buffer.get());
   EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(),
diff --git a/webrtc/modules/video_capture/video_capture_impl.cc b/webrtc/modules/video_capture/video_capture_impl.cc
index 6f179e2..dc56ad3 100644
--- a/webrtc/modules/video_capture/video_capture_impl.cc
+++ b/webrtc/modules/video_capture/video_capture_impl.cc
@@ -256,7 +256,7 @@
 
 int32_t VideoCaptureImpl::IncomingFrame(
     uint8_t* videoFrame,
-    int32_t videoFrameLength,
+    size_t videoFrameLength,
     const VideoCaptureCapability& frameInfo,
     int64_t captureTime/*=0*/)
 {
diff --git a/webrtc/modules/video_capture/video_capture_impl.h b/webrtc/modules/video_capture/video_capture_impl.h
index f3a4c64..4e40337 100644
--- a/webrtc/modules/video_capture/video_capture_impl.h
+++ b/webrtc/modules/video_capture/video_capture_impl.h
@@ -84,7 +84,7 @@
     // Implement VideoCaptureExternal
     // |capture_time| must be specified in the NTP time format in milliseconds.
     virtual int32_t IncomingFrame(uint8_t* videoFrame,
-                                  int32_t videoFrameLength,
+                                  size_t videoFrameLength,
                                   const VideoCaptureCapability& frameInfo,
                                   int64_t captureTime = 0);
 
diff --git a/webrtc/modules/video_capture/windows/sink_filter_ds.cc b/webrtc/modules/video_capture/windows/sink_filter_ds.cc
index 2edbe59..f79fe1f 100644
--- a/webrtc/modules/video_capture/windows/sink_filter_ds.cc
+++ b/webrtc/modules/video_capture/windows/sink_filter_ds.cc
@@ -353,7 +353,8 @@
 
     if (SUCCEEDED (hr))
     {
-        const int32_t length = pIMediaSample->GetActualDataLength();
+        const LONG length = pIMediaSample->GetActualDataLength();
+        ASSERT(length >= 0);
 
         unsigned char* pBuffer = NULL;
         if(S_OK != pIMediaSample->GetPointer(&pBuffer))
@@ -364,7 +365,7 @@
 
         // NOTE: filter unlocked within Send call
         reinterpret_cast <CaptureSinkFilter *> (m_pFilter)->ProcessCapturedFrame(
-                                        pBuffer,length,_resultingCapability);
+            pBuffer, static_cast<size_t>(length), _resultingCapability);
     }
     else
     {
@@ -485,9 +486,10 @@
     UnlockFilter();
 }
 
-void CaptureSinkFilter::ProcessCapturedFrame(unsigned char* pBuffer,
-                                         int32_t length,
-                                         const VideoCaptureCapability& frameInfo)
+void CaptureSinkFilter::ProcessCapturedFrame(
+    unsigned char* pBuffer,
+    size_t length,
+    const VideoCaptureCapability& frameInfo)
 {
     //  we have the receiver lock
     if (m_State == State_Running)
diff --git a/webrtc/modules/video_capture/windows/sink_filter_ds.h b/webrtc/modules/video_capture/windows/sink_filter_ds.h
index d1f0ed3..064cd9d 100644
--- a/webrtc/modules/video_capture/windows/sink_filter_ds.h
+++ b/webrtc/modules/video_capture/windows/sink_filter_ds.h
@@ -63,7 +63,7 @@
     //  --------------------------------------------------------------------
     //  class methods
 
-    void ProcessCapturedFrame(unsigned char* pBuffer, int32_t length,
+    void ProcessCapturedFrame(unsigned char* pBuffer, size_t length,
                               const VideoCaptureCapability& frameInfo);
     //  explicit receiver lock aquisition and release
     void LockReceive()  { m_crtRecv.Lock();}
diff --git a/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h b/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h
index 1e99e69..2d41fd0 100644
--- a/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h
+++ b/webrtc/modules/video_coding/codecs/i420/main/interface/i420.h
@@ -18,8 +18,6 @@
 
 namespace webrtc {
 
-enum { kI420HeaderSize = 4 };
-
 class I420Encoder : public VideoEncoder {
  public:
   I420Encoder();
@@ -38,7 +36,7 @@
 //                                <0 - Error
   virtual int InitEncode(const VideoCodec* codecSettings,
                          int /*numberOfCores*/,
-                         uint32_t /*maxPayloadSize*/) OVERRIDE;
+                         size_t /*maxPayloadSize*/) OVERRIDE;
 
 // "Encode" an I420 image (as a part of a video stream). The encoded image
 // will be returned to the user via the encode complete callback.
diff --git a/webrtc/modules/video_coding/codecs/i420/main/source/i420.cc b/webrtc/modules/video_coding/codecs/i420/main/source/i420.cc
index 69cc9e2..bb61f5e 100644
--- a/webrtc/modules/video_coding/codecs/i420/main/source/i420.cc
+++ b/webrtc/modules/video_coding/codecs/i420/main/source/i420.cc
@@ -15,6 +15,10 @@
 
 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
 
+namespace {
+const size_t kI420HeaderSize = 4;
+}
+
 namespace webrtc {
 
 I420Encoder::I420Encoder() : _inited(false), _encodedImage(),
@@ -39,7 +43,7 @@
 
 int I420Encoder::InitEncode(const VideoCodec* codecSettings,
                             int /*numberOfCores*/,
-                            uint32_t /*maxPayloadSize */) {
+                            size_t /*maxPayloadSize */) {
   if (codecSettings == NULL) {
     return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
   }
@@ -53,10 +57,9 @@
     _encodedImage._buffer = NULL;
     _encodedImage._size = 0;
   }
-  const uint32_t newSize = CalcBufferSize(kI420,
-                                          codecSettings->width,
-                                          codecSettings->height)
-                           + kI420HeaderSize;
+  const size_t newSize =
+      CalcBufferSize(kI420, codecSettings->width, codecSettings->height) +
+      kI420HeaderSize;
   uint8_t* newBuffer = new uint8_t[newSize];
   if (newBuffer == NULL) {
     return WEBRTC_VIDEO_CODEC_MEMORY;
@@ -95,9 +98,10 @@
     return WEBRTC_VIDEO_CODEC_ERR_SIZE;
   }
 
-  int req_length = CalcBufferSize(kI420, inputImage.width(),
-                                  inputImage.height()) + kI420HeaderSize;
-  if (_encodedImage._size > static_cast<unsigned int>(req_length)) {
+  size_t req_length =
+      CalcBufferSize(kI420, inputImage.width(), inputImage.height()) +
+      kI420HeaderSize;
+  if (_encodedImage._size > req_length) {
     // Reallocate buffer.
     delete [] _encodedImage._buffer;
 
@@ -194,8 +198,7 @@
   _height = height;
 
   // Verify that the available length is sufficient:
-  uint32_t req_length = CalcBufferSize(kI420, _width, _height)
-                        + kI420HeaderSize;
+  size_t req_length = CalcBufferSize(kI420, _width, _height) + kI420HeaderSize;
 
   if (req_length > inputImage._length) {
     return WEBRTC_VIDEO_CODEC_ERROR;
diff --git a/webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h b/webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h
index 69e99ae..18bf5b8 100644
--- a/webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h
+++ b/webrtc/modules/video_coding/codecs/interface/mock/mock_video_codec_interface.h
@@ -31,7 +31,7 @@
   MOCK_CONST_METHOD2(Version, int32_t(int8_t *version, int32_t length));
   MOCK_METHOD3(InitEncode, int32_t(const VideoCodec* codecSettings,
                                    int32_t numberOfCores,
-                                   uint32_t maxPayloadSize));
+                                   size_t maxPayloadSize));
   MOCK_METHOD3(Encode, int32_t(const I420VideoFrame& inputImage,
                                const CodecSpecificInfo* codecSpecificInfo,
                                const std::vector<VideoFrameType>* frame_types));
diff --git a/webrtc/modules/video_coding/codecs/test/packet_manipulator.cc b/webrtc/modules/video_coding/codecs/test/packet_manipulator.cc
index f4ca92a..6e7139e 100644
--- a/webrtc/modules/video_coding/codecs/test/packet_manipulator.cc
+++ b/webrtc/modules/video_coding/codecs/test/packet_manipulator.cc
@@ -13,6 +13,8 @@
 #include <assert.h>
 #include <stdio.h>
 
+#include "webrtc/base/format_macros.h"
+
 namespace webrtc {
 namespace test {
 
@@ -72,7 +74,7 @@
     // Must set completeFrame to false to inform the decoder about this:
     encoded_image->_completeFrame = false;
     if (verbose_) {
-      printf("Dropped %d packets for frame %d (frame length: %d)\n",
+      printf("Dropped %d packets for frame %d (frame length: %" PRIuS ")\n",
              nbr_packets_dropped, encoded_image->_timeStamp,
              encoded_image->_length);
     }
diff --git a/webrtc/modules/video_coding/codecs/test/packet_manipulator.h b/webrtc/modules/video_coding/codecs/test/packet_manipulator.h
index 0fafa22..69bc35b 100644
--- a/webrtc/modules/video_coding/codecs/test/packet_manipulator.h
+++ b/webrtc/modules/video_coding/codecs/test/packet_manipulator.h
@@ -42,11 +42,11 @@
   }
 
   // Packet size in bytes. Default: 1500 bytes.
-  int packet_size_in_bytes;
+  size_t packet_size_in_bytes;
 
   // Encoder specific setting of maximum size in bytes of each payload.
   // Default: 1440 bytes.
-  int max_payload_size_in_bytes;
+  size_t max_payload_size_in_bytes;
 
   // Packet loss mode. Two different packet loss models are supported:
   // uniform or burst. This setting has no effect unless
diff --git a/webrtc/modules/video_coding/codecs/test/packet_manipulator_unittest.cc b/webrtc/modules/video_coding/codecs/test/packet_manipulator_unittest.cc
index 576d005..ace7bc0 100644
--- a/webrtc/modules/video_coding/codecs/test/packet_manipulator_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/test/packet_manipulator_unittest.cc
@@ -60,11 +60,11 @@
 
   void VerifyPacketLoss(int expected_nbr_packets_dropped,
                         int actual_nbr_packets_dropped,
-                        int expected_packet_data_length,
+                        size_t expected_packet_data_length,
                         uint8_t* expected_packet_data,
                         EncodedImage& actual_image) {
     EXPECT_EQ(expected_nbr_packets_dropped, actual_nbr_packets_dropped);
-    EXPECT_EQ(expected_packet_data_length, static_cast<int>(image_._length));
+    EXPECT_EQ(expected_packet_data_length, image_._length);
     EXPECT_EQ(0, memcmp(expected_packet_data, actual_image._buffer,
                         expected_packet_data_length));
   }
@@ -82,7 +82,7 @@
 }
 
 TEST_F(PacketManipulatorTest, UniformDropNoneSmallFrame) {
-  int data_length = 400;  // smaller than the packet size
+  size_t data_length = 400;  // smaller than the packet size
   image_._length = data_length;
   PacketManipulatorImpl manipulator(&packet_reader_, no_drop_config_, false);
   int nbr_packets_dropped = manipulator.ManipulatePackets(&image_);
@@ -120,7 +120,7 @@
 TEST_F(PacketManipulatorTest, BurstDropNinePackets) {
   // Create a longer packet data structure (10 packets)
   const int kNbrPackets = 10;
-  const int kDataLength = kPacketSizeInBytes * kNbrPackets;
+  const size_t kDataLength = kPacketSizeInBytes * kNbrPackets;
   uint8_t data[kDataLength];
   uint8_t* data_pointer = data;
   // Fill with 0s, 1s and so on to be able to easily verify which were dropped:
diff --git a/webrtc/modules/video_coding/codecs/test/stats.cc b/webrtc/modules/video_coding/codecs/test/stats.cc
index f6605f9..91a2f3c 100644
--- a/webrtc/modules/video_coding/codecs/test/stats.cc
+++ b/webrtc/modules/video_coding/codecs/test/stats.cc
@@ -15,6 +15,8 @@
 
 #include <algorithm>  // min_element, max_element
 
+#include "webrtc/base/format_macros.h"
+
 namespace webrtc {
 namespace test {
 
@@ -70,11 +72,11 @@
   // Calculate min, max, average and total encoding time
   int total_encoding_time_in_us = 0;
   int total_decoding_time_in_us = 0;
-  int total_encoded_frames_lengths = 0;
-  int total_encoded_key_frames_lengths = 0;
-  int total_encoded_nonkey_frames_lengths = 0;
-  int nbr_keyframes = 0;
-  int nbr_nonkeyframes = 0;
+  size_t total_encoded_frames_lengths = 0;
+  size_t total_encoded_key_frames_lengths = 0;
+  size_t total_encoded_nonkey_frames_lengths = 0;
+  size_t nbr_keyframes = 0;
+  size_t nbr_nonkeyframes = 0;
 
   for (FrameStatisticsIterator it = stats_.begin();
       it != stats_.end(); ++it) {
@@ -141,23 +143,24 @@
   printf("Frame sizes:\n");
   frame = std::min_element(stats_.begin(),
                       stats_.end(), LessForEncodedSize);
-  printf("  Min     : %7d bytes (frame %d)\n",
+  printf("  Min     : %7" PRIuS " bytes (frame %d)\n",
          frame->encoded_frame_length_in_bytes, frame->frame_number);
 
   frame = std::max_element(stats_.begin(),
                       stats_.end(), LessForEncodedSize);
-  printf("  Max     : %7d bytes (frame %d)\n",
+  printf("  Max     : %7" PRIuS " bytes (frame %d)\n",
          frame->encoded_frame_length_in_bytes, frame->frame_number);
 
-  printf("  Average : %7d bytes\n",
-         static_cast<int>(total_encoded_frames_lengths / stats_.size()));
+  printf("  Average : %7" PRIuS " bytes\n",
+         total_encoded_frames_lengths / stats_.size());
   if (nbr_keyframes > 0) {
-    printf("  Average key frame size    : %7d bytes (%d keyframes)\n",
-           total_encoded_key_frames_lengths / nbr_keyframes,
-           nbr_keyframes);
+    printf("  Average key frame size    : %7" PRIuS " bytes (%" PRIuS
+           " keyframes)\n",
+           total_encoded_key_frames_lengths / nbr_keyframes, nbr_keyframes);
   }
   if (nbr_nonkeyframes > 0) {
-    printf("  Average non-key frame size: %7d bytes (%d frames)\n",
+    printf("  Average non-key frame size: %7" PRIuS " bytes (%" PRIuS
+           " frames)\n",
            total_encoded_nonkey_frames_lengths / nbr_nonkeyframes,
            nbr_nonkeyframes);
   }
diff --git a/webrtc/modules/video_coding/codecs/test/stats.h b/webrtc/modules/video_coding/codecs/test/stats.h
index 2998773..8dc8f15 100644
--- a/webrtc/modules/video_coding/codecs/test/stats.h
+++ b/webrtc/modules/video_coding/codecs/test/stats.h
@@ -31,14 +31,14 @@
   int frame_number;
   // How many packets were discarded of the encoded frame data (if any).
   int packets_dropped;
-  int total_packets;
+  size_t total_packets;
 
   // Current bit rate. Calculated out of the size divided with the time
   // interval per frame.
   int bit_rate_in_kbps;
 
   // Copied from EncodedImage
-  int encoded_frame_length_in_bytes;
+  size_t encoded_frame_length_in_bytes;
   webrtc::VideoFrameType frame_type;
 };
 
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
index 93738ca..412ec10 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.cc
@@ -30,7 +30,7 @@
       output_dir("out"),
       networking_config(),
       exclude_frame_types(kExcludeOnlyFirstKeyFrame),
-      frame_length_in_bytes(-1),
+      frame_length_in_bytes(0),
       use_single_core(false),
       keyframe_interval(0),
       codec_settings(NULL),
@@ -157,7 +157,7 @@
   num_spatial_resizes_ = 0;
 }
 
-int VideoProcessorImpl::EncodedFrameSize() {
+size_t VideoProcessorImpl::EncodedFrameSize() {
   return encoded_frame_size_;
 }
 
@@ -330,11 +330,12 @@
               frame_number, ret_val);
     }
     // TODO(mikhal): Extracting the buffer for now - need to update test.
-    int length = CalcBufferSize(kI420, up_image.width(), up_image.height());
+    size_t length = CalcBufferSize(kI420, up_image.width(), up_image.height());
     scoped_ptr<uint8_t[]> image_buffer(new uint8_t[length]);
-    length = ExtractBuffer(up_image, length, image_buffer.get());
+    int extracted_length = ExtractBuffer(up_image, length, image_buffer.get());
+    assert(extracted_length > 0);
     // Update our copy of the last successful frame:
-    memcpy(last_successful_frame_buffer_, image_buffer.get(), length);
+    memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length);
     bool write_success = frame_writer_->WriteFrame(image_buffer.get());
     assert(write_success);
     if (!write_success) {
@@ -343,11 +344,11 @@
   } else {  // No resize.
     // Update our copy of the last successful frame:
     // TODO(mikhal): Add as a member function, so won't be allocated per frame.
-    int length = CalcBufferSize(kI420, image.width(), image.height());
+    size_t length = CalcBufferSize(kI420, image.width(), image.height());
     scoped_ptr<uint8_t[]> image_buffer(new uint8_t[length]);
-    length = ExtractBuffer(image, length, image_buffer.get());
-    assert(length > 0);
-    memcpy(last_successful_frame_buffer_, image_buffer.get(), length);
+    int extracted_length = ExtractBuffer(image, length, image_buffer.get());
+    assert(extracted_length > 0);
+    memcpy(last_successful_frame_buffer_, image_buffer.get(), extracted_length);
 
     bool write_success = frame_writer_->WriteFrame(image_buffer.get());
     assert(write_success);
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.h b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
index 20bcab5..2cfde52 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.h
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
@@ -76,7 +76,7 @@
   // The length of a single frame of the input video file. This value is
   // calculated out of the width and height according to the video format
   // specification. Must be set before processing.
-  int frame_length_in_bytes;
+  size_t frame_length_in_bytes;
 
   // Force the encoder and decoder to use a single core for processing.
   // Using a single core is necessary to get a deterministic behavior for the
@@ -144,7 +144,7 @@
 
   // Return the size of the encoded frame in bytes. Dropped frames by the
   // encoder are regarded as zero size.
-  virtual int EncodedFrameSize() = 0;
+  virtual size_t EncodedFrameSize() = 0;
 
   // Return the number of dropped frames.
   virtual int NumberDroppedFrames() = 0;
@@ -178,7 +178,7 @@
   // Updates the encoder with the target bit rate and the frame rate.
   virtual void SetRates(int bit_rate, int frame_rate) OVERRIDE;
   // Return the size of the encoded frame in bytes.
-  virtual int EncodedFrameSize() OVERRIDE;
+  virtual size_t EncodedFrameSize() OVERRIDE;
   // Return the number of dropped frames.
   virtual int NumberDroppedFrames() OVERRIDE;
   // Return the number of spatial resizes.
@@ -206,7 +206,7 @@
   bool last_frame_missing_;
   // If Init() has executed successfully.
   bool initialized_;
-  int encoded_frame_size_;
+  size_t encoded_frame_size_;
   int prev_time_stamp_;
   int num_dropped_frames_;
   int num_spatial_resizes_;
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
index 420ef59..0c423a7 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc
@@ -266,8 +266,7 @@
 
   // For every encoded frame, update the rate control metrics.
   void UpdateRateControlMetrics(int frame_num, VideoFrameType frame_type) {
-    int encoded_frame_size = processor_->EncodedFrameSize();
-    float encoded_size_kbits = encoded_frame_size * 8.0f / 1000.0f;
+    float encoded_size_kbits = processor_->EncodedFrameSize() * 8.0f / 1000.0f;
     // Update layer data.
     // Update rate mismatch relative to per-frame bandwidth for delta frames.
     if (frame_type == kDeltaFrame) {
diff --git a/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.cc b/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.cc
index dcd7479..3ad6ed7 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.cc
+++ b/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.cc
@@ -218,7 +218,7 @@
     return _frameBufferQueue.empty();
 }
 
-uint32_t VideoEncodeCompleteCallback::EncodedBytes()
+size_t VideoEncodeCompleteCallback::EncodedBytes()
 {
     return _encodedBytes;
 }
@@ -251,7 +251,7 @@
     return 0;
 }
 
-uint32_t VideoDecodeCompleteCallback::DecodedBytes()
+size_t VideoDecodeCompleteCallback::DecodedBytes()
 {
     return _decodedBytes;
 }
diff --git a/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h b/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h
index 1e62534..63ac0bf 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h
+++ b/webrtc/modules/video_coding/codecs/test_framework/normal_async_test.h
@@ -153,12 +153,12 @@
     Encoded(webrtc::EncodedImage& encodedImage,
             const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL,
             const webrtc::RTPFragmentationHeader* fragmentation = NULL);
-    uint32_t EncodedBytes();
+    size_t EncodedBytes();
 private:
     FILE*             _encodedFile;
     FrameQueue*       _frameQueue;
     NormalAsyncTest&  _test;
-    uint32_t    _encodedBytes;
+    size_t _encodedBytes;
 };
 
 class VideoDecodeCompleteCallback : public webrtc::DecodedImageCallback
@@ -176,11 +176,11 @@
     ReceivedDecodedReferenceFrame(const uint64_t pictureId);
     virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId);
 
-    uint32_t DecodedBytes();
+    size_t DecodedBytes();
 private:
     FILE* _decodedFile;
     NormalAsyncTest& _test;
-    uint32_t    _decodedBytes;
+    size_t _decodedBytes;
 };
 
 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_FRAMEWORK_NORMAL_ASYNC_TEST_H_
diff --git a/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.cc b/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.cc
index 6bb7bbe..c6315a7 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.cc
+++ b/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.cc
@@ -92,8 +92,8 @@
     _frameQueue.pop_front();
 
     // save image for future freeze-frame
-    unsigned int length = CalcBufferSize(kI420, decodedImage.width(),
-                                         decodedImage.height());
+    size_t length =
+        CalcBufferSize(kI420, decodedImage.width(), decodedImage.height());
     if (_lastFrameLength < length)
     {
         if (_lastFrame) delete [] _lastFrame;
@@ -189,7 +189,7 @@
     newEncBuf.VerifyAndAllocate(_lengthSourceFrame);
     _inBufIdx = 0;
     _outBufIdx = 0;
-    int size = 1;
+    size_t size = 1;
     int kept = 0;
     int thrown = 0;
     while ((size = NextPacket(1500, &packet)) > 0)
@@ -204,7 +204,7 @@
             // Use the ByteLoss function if you want to lose only
             // parts of a packet, and not the whole packet.
 
-            //int size2 = ByteLoss(size, packet, 15);
+            //size_t size2 = ByteLoss(size, packet, 15);
             thrown++;
             //if (size2 != size)
             //{
@@ -227,28 +227,27 @@
     //printf("Encoded left: %d bytes\n", _encodedVideoBuffer.Length());
 }
 
-int PacketLossTest::NextPacket(int mtu, unsigned char **pkg)
+size_t PacketLossTest::NextPacket(size_t mtu, unsigned char **pkg)
 {
     unsigned char *buf = _frameToDecode->_frame->Buffer();
     *pkg = buf + _inBufIdx;
-    if (static_cast<long>(_frameToDecode->_frame->Length()) - _inBufIdx <= mtu)
-    {
-        int size = _frameToDecode->_frame->Length() - _inBufIdx;
-        _inBufIdx = _frameToDecode->_frame->Length();
-        return size;
-    }
-    _inBufIdx += mtu;
-    return mtu;
+    size_t old_idx = _inBufIdx;
+    _inBufIdx = std::min(_inBufIdx + mtu, _frameToDecode->_frame->Length());
+    return _inBufIdx - old_idx;
 }
 
-int PacketLossTest::ByteLoss(int size, unsigned char *pkg, int bytesToLose)
+size_t PacketLossTest::ByteLoss(size_t size,
+                                unsigned char *pkg,
+                                size_t bytesToLose)
 {
     return size;
 }
 
-void PacketLossTest::InsertPacket(VideoFrame *buf, unsigned char *pkg, int size)
+void PacketLossTest::InsertPacket(VideoFrame *buf,
+                                  unsigned char *pkg,
+                                  size_t size)
 {
-    if (static_cast<long>(buf->Size()) - _outBufIdx < size)
+    if ((_outBufIdx + size) > buf->Size())
     {
         printf("InsertPacket error!\n");
         return;
diff --git a/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.h b/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.h
index e917054..48a67a2 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.h
+++ b/webrtc/modules/video_coding/codecs/test_framework/packet_loss_test.h
@@ -34,12 +34,15 @@
     virtual void Teardown();
     virtual void CodecSpecific_InitBitrate();
     virtual int DoPacketLoss();
-    virtual int NextPacket(int size, unsigned char **pkg);
-    virtual int ByteLoss(int size, unsigned char *pkg, int bytesToLose);
-    virtual void InsertPacket(webrtc::VideoFrame *buf, unsigned char *pkg,
-                              int size);
-    int _inBufIdx;
-    int _outBufIdx;
+    virtual size_t NextPacket(size_t mtu, unsigned char **pkg);
+    virtual size_t ByteLoss(size_t size,
+                            unsigned char *pkg,
+                            size_t bytesToLose);
+    virtual void InsertPacket(webrtc::VideoFrame *buf,
+                              unsigned char *pkg,
+                              size_t size);
+    size_t _inBufIdx;
+    size_t _outBufIdx;
 
     // When NACK is being simulated _lossProbabilty is zero,
     // otherwise it is set equal to _lossRate.
@@ -50,10 +53,10 @@
 
     int _totalKept;
     int _totalThrown;
-    int _sumChannelBytes;
+    size_t _sumChannelBytes;
     std::list<uint32_t> _frameQueue;
     uint8_t* _lastFrame;
-    uint32_t _lastFrameLength;
+    size_t _lastFrameLength;
 };
 
 
diff --git a/webrtc/modules/video_coding/codecs/test_framework/test.h b/webrtc/modules/video_coding/codecs/test_framework/test.h
index 7558abe..db891ca 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/test.h
+++ b/webrtc/modules/video_coding/codecs/test_framework/test.h
@@ -48,8 +48,8 @@
 
     webrtc::VideoEncoder*   _encoder;
     webrtc::VideoDecoder*   _decoder;
-    uint32_t          _bitRate;
-    unsigned int            _lengthSourceFrame;
+    uint32_t                _bitRate;
+    size_t                  _lengthSourceFrame;
     unsigned char*          _sourceBuffer;
     webrtc::I420VideoFrame  _inputVideoBuffer;
     // TODO(mikhal): For now using VideoFrame for encodedBuffer, should use a
@@ -61,7 +61,7 @@
     std::string             _inname;
     std::string             _outname;
     std::string             _encodedName;
-    int                     _sumEncBytes;
+    size_t                  _sumEncBytes;
     int                     _width;
     int                     _halfWidth;
     int                     _height;
diff --git a/webrtc/modules/video_coding/codecs/test_framework/unit_test.cc b/webrtc/modules/video_coding/codecs/test_framework/unit_test.cc
index ab8d4d2..1af462c 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/unit_test.cc
+++ b/webrtc/modules/video_coding/codecs/test_framework/unit_test.cc
@@ -146,7 +146,7 @@
     return false;
 }
 
-uint32_t
+size_t
 UnitTest::WaitForEncodedFrame() const
 {
     int64_t startTime = TickTime::MillisecondTimestamp();
@@ -160,7 +160,7 @@
     return 0;
 }
 
-uint32_t
+size_t
 UnitTest::WaitForDecodedFrame() const
 {
     int64_t startTime = TickTime::MillisecondTimestamp();
@@ -225,8 +225,8 @@
     _inst.codecSpecific.VP8.denoisingOn = true;
 
     // Get input frame.
-    ASSERT_TRUE(fread(_refFrame, 1, _lengthSourceFrame, _sourceFile)
-                           == _lengthSourceFrame);
+    ASSERT_EQ(_lengthSourceFrame,
+              fread(_refFrame, 1, _lengthSourceFrame, _sourceFile));
     int size_y = _inst.width * _inst.height;
     int size_uv = ((_inst.width + 1) / 2)  * ((_inst.height + 1) / 2);
     _inputVideoBuffer.CreateFrame(size_y, _refFrame,
@@ -244,7 +244,7 @@
     EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
     _encoder->Encode(_inputVideoBuffer, NULL, NULL);
     _refEncFrameLength = WaitForEncodedFrame();
-    ASSERT_TRUE(_refEncFrameLength > 0);
+    ASSERT_GT(_refEncFrameLength, 0u);
     _refEncFrame = new unsigned char[_refEncFrameLength];
     memcpy(_refEncFrame, _encodedVideoBuffer.Buffer(), _refEncFrameLength);
 
@@ -255,7 +255,7 @@
     EXPECT_TRUE(_decoder->InitDecode(&_inst, 1) == WEBRTC_VIDEO_CODEC_OK);
     ASSERT_FALSE(SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK);
 
-    unsigned int frameLength = 0;
+    size_t frameLength = 0;
     int i = 0;
     _inputVideoBuffer.CreateEmptyFrame(_inst.width, _inst.height, _inst.width,
                                        (_inst.width + 1) / 2,
@@ -266,12 +266,12 @@
         if (i > 0)
         {
             // Insert yet another frame.
-            ASSERT_TRUE(fread(_refFrame, 1, _lengthSourceFrame,
-                _sourceFile) == _lengthSourceFrame);
+            ASSERT_EQ(_lengthSourceFrame,
+                      fread(_refFrame, 1, _lengthSourceFrame, _sourceFile));
             EXPECT_EQ(0, ConvertToI420(kI420, _refFrame, 0, 0, _width, _height,
                           0, kRotateNone, &_inputVideoBuffer));
             _encoder->Encode(_inputVideoBuffer, NULL, NULL);
-            ASSERT_TRUE(WaitForEncodedFrame() > 0);
+            ASSERT_GT(WaitForEncodedFrame(), 0u);
         } else {
             // The first frame is always a key frame.
             encodedImage._frameType = kKeyFrame;
@@ -285,7 +285,7 @@
         i++;
     }
     rewind(_sourceFile);
-    EXPECT_TRUE(frameLength == _lengthSourceFrame);
+    EXPECT_EQ(_lengthSourceFrame, frameLength);
     ExtractBuffer(_decodedVideoBuffer, _lengthSourceFrame, _refDecFrame);
 }
 
@@ -324,9 +324,9 @@
     EncodedImage encodedImage;
     VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
     int ret = _decoder->Decode(encodedImage, 0, NULL);
-    int frameLength = WaitForDecodedFrame();
+    size_t frameLength = WaitForDecodedFrame();
     _encodedVideoBuffer.SetLength(0);
-    return ret == WEBRTC_VIDEO_CODEC_OK ? frameLength : ret;
+    return ret == WEBRTC_VIDEO_CODEC_OK ? static_cast<int>(frameLength) : ret;
 }
 
 int
@@ -343,13 +343,11 @@
     }
 
     int ret = _decoder->Decode(encodedImage, 0, NULL);
-    unsigned int frameLength = WaitForDecodedFrame();
-    assert(ret == WEBRTC_VIDEO_CODEC_OK && (frameLength == 0 || frameLength
-        == _lengthSourceFrame));
-    EXPECT_TRUE(ret == WEBRTC_VIDEO_CODEC_OK && (frameLength == 0 || frameLength
-        == _lengthSourceFrame));
+    size_t frameLength = WaitForDecodedFrame();
+    EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, ret);
+    EXPECT_TRUE(frameLength == 0 || frameLength == _lengthSourceFrame);
     _encodedVideoBuffer.SetLength(0);
-    return ret == WEBRTC_VIDEO_CODEC_OK ? frameLength : ret;
+    return ret == WEBRTC_VIDEO_CODEC_OK ? static_cast<int>(frameLength) : ret;
 }
 
 // Test pure virtual VideoEncoder and VideoDecoder APIs.
@@ -357,7 +355,7 @@
 UnitTest::Perform()
 {
     UnitTest::Setup();
-    int frameLength;
+    size_t frameLength;
     I420VideoFrame inputImage;
     EncodedImage encodedImage;
 
@@ -448,21 +446,21 @@
         std::vector<VideoFrameType> frame_types(1, frame_type);
         EXPECT_TRUE(_encoder->Encode(_inputVideoBuffer, NULL, &frame_types) ==
             WEBRTC_VIDEO_CODEC_OK);
-        EXPECT_TRUE(WaitForEncodedFrame() > 0);
+        EXPECT_GT(WaitForEncodedFrame(), 0u);
     }
 
     // Init then encode.
     _encodedVideoBuffer.SetLength(0);
     EXPECT_TRUE(_encoder->Encode(_inputVideoBuffer, NULL, NULL) ==
         WEBRTC_VIDEO_CODEC_OK);
-    EXPECT_TRUE(WaitForEncodedFrame() > 0);
+    EXPECT_GT(WaitForEncodedFrame(), 0u);
 
     EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
     _encoder->Encode(_inputVideoBuffer, NULL, NULL);
     frameLength = WaitForEncodedFrame();
-    EXPECT_TRUE(frameLength > 0);
+    EXPECT_GT(frameLength, 0u);
     EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
-            _encodedVideoBuffer.Buffer(), frameLength) == true);
+                                _encodedVideoBuffer.Buffer(), frameLength));
 
     // Reset then encode.
     _encodedVideoBuffer.SetLength(0);
@@ -472,9 +470,9 @@
     EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
     _encoder->Encode(_inputVideoBuffer, NULL, NULL);
     frameLength = WaitForEncodedFrame();
-    EXPECT_TRUE(frameLength > 0);
+    EXPECT_GT(frameLength, 0u);
     EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
-        _encodedVideoBuffer.Buffer(), frameLength) == true);
+                                _encodedVideoBuffer.Buffer(), frameLength));
 
     // Release then encode.
     _encodedVideoBuffer.SetLength(0);
@@ -485,9 +483,9 @@
     EXPECT_TRUE(_encoder->InitEncode(&_inst, 1, 1440) == WEBRTC_VIDEO_CODEC_OK);
     _encoder->Encode(_inputVideoBuffer, NULL, NULL);
     frameLength = WaitForEncodedFrame();
-    EXPECT_TRUE(frameLength > 0);
+    EXPECT_GT(frameLength, 0u);
     EXPECT_TRUE(CheckIfBitExact(_refEncFrame, _refEncFrameLength,
-        _encodedVideoBuffer.Buffer(), frameLength) == true);
+                                _encodedVideoBuffer.Buffer(), frameLength));
 
     //----- Decoder parameter tests -----
 
@@ -522,8 +520,8 @@
     ASSERT_FALSE(SetCodecSpecificParameters() != WEBRTC_VIDEO_CODEC_OK);
     for (int i = 0; i < 100; i++)
     {
-        ASSERT_TRUE(fread(tmpBuf, 1, _refEncFrameLength, _sourceFile)
-            == _refEncFrameLength);
+        ASSERT_EQ(_refEncFrameLength,
+                  fread(tmpBuf, 1, _refEncFrameLength, _sourceFile));
         _encodedVideoBuffer.CopyFrame(_refEncFrameLength, tmpBuf);
         VideoEncodedBufferToEncodedImage(_encodedVideoBuffer, encodedImage);
         int ret = _decoder->Decode(encodedImage, false, NULL);
@@ -564,12 +562,12 @@
         _decoder->Decode(encodedImage, false, NULL);
         frameLength = WaitForDecodedFrame();
     }
-    unsigned int length = CalcBufferSize(kI420, width, height);
+    size_t length = CalcBufferSize(kI420, width, height);
     scoped_ptr<uint8_t[]> decoded_buffer(new uint8_t[length]);
     ExtractBuffer(_decodedVideoBuffer, _lengthSourceFrame,
                   decoded_buffer.get());
     EXPECT_TRUE(CheckIfBitExact(decoded_buffer.get(), frameLength, _refDecFrame,
-                                _lengthSourceFrame) == true);
+                                _lengthSourceFrame));
 
     // Reset then decode.
     EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
@@ -583,7 +581,7 @@
     ExtractBuffer(_decodedVideoBuffer, _lengthSourceFrame,
                   decoded_buffer.get());
     EXPECT_TRUE(CheckIfBitExact(decoded_buffer.get(), frameLength,
-                                _refDecFrame, _lengthSourceFrame) == true);
+                                _refDecFrame, _lengthSourceFrame));
 
     // Decode with other size, reset, then decode with original size again
     // to verify that decoder is reset to a "fresh" state upon Reset().
@@ -614,7 +612,7 @@
                               tempInst.width, tmpHalfWidth, tmpHalfWidth);
         _encoder->Encode(tempInput, NULL, NULL);
         frameLength = WaitForEncodedFrame();
-        EXPECT_TRUE(frameLength > 0);
+        EXPECT_GT(frameLength, 0u);
         // Reset then decode.
         EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
         frameLength = 0;
@@ -631,7 +629,7 @@
             WEBRTC_VIDEO_CODEC_OK);
         _encoder->Encode(_inputVideoBuffer, NULL, NULL);
         frameLength = WaitForEncodedFrame();
-        EXPECT_TRUE(frameLength > 0);
+        EXPECT_GT(frameLength, 0u);
 
         // Reset then decode original frame again.
         EXPECT_TRUE(_decoder->Reset() == WEBRTC_VIDEO_CODEC_OK);
@@ -644,11 +642,11 @@
         }
 
         // check that decoded frame matches with reference
-        unsigned int length = CalcBufferSize(kI420, width, height);
+        size_t length = CalcBufferSize(kI420, width, height);
         scoped_ptr<uint8_t[]> decoded_buffer(new uint8_t[length]);
         ExtractBuffer(_decodedVideoBuffer, length, decoded_buffer.get());
         EXPECT_TRUE(CheckIfBitExact(decoded_buffer.get(), length,
-                                    _refDecFrame, _lengthSourceFrame) == true);
+                                    _refDecFrame, _lengthSourceFrame));
     }
 
     // Release then decode.
@@ -664,7 +662,7 @@
     }
     ExtractBuffer(_decodedVideoBuffer, length, decoded_buffer.get());
     EXPECT_TRUE(CheckIfBitExact(decoded_buffer.get(), frameLength,
-                                _refDecFrame, _lengthSourceFrame) == true);
+                                _refDecFrame, _lengthSourceFrame));
     _encodedVideoBuffer.SetLength(0);
 
     delete [] tmpBuf;
@@ -697,8 +695,7 @@
         ASSERT_TRUE(_encoder->Encode(_inputVideoBuffer, NULL, NULL) ==
             WEBRTC_VIDEO_CODEC_OK);
         frameLength = WaitForEncodedFrame();
-        //ASSERT_TRUE(frameLength);
-        EXPECT_TRUE(frameLength > 0);
+        EXPECT_GT(frameLength, 0u);
         encTimeStamp = _encodedVideoBuffer.TimeStamp();
         EXPECT_TRUE(_inputVideoBuffer.timestamp() ==
                 static_cast<unsigned>(encTimeStamp));
@@ -707,8 +704,7 @@
             is_key_frame_ = true;
         }
 
-        frameLength = Decode();
-        if (frameLength == 0)
+        if (Decode() == 0)
         {
             frameDelay++;
         }
@@ -735,7 +731,7 @@
 {
     int frames = 0;
     VideoFrame inputImage;
-    uint32_t frameLength;
+    size_t frameLength;
 
     // Do not specify maxBitRate (as in ViE).
     _inst.maxBitrate = 0;
@@ -754,7 +750,7 @@
     for (int i = 0; i < nBitrates; i++)
     {
         _bitRate = bitRate[i];
-        int totalBytes = 0;
+        size_t totalBytes = 0;
         _inst.startBitrate = _bitRate;
         _encoder->InitEncode(&_inst, 4, 1440);
         _decoder->Reset();
@@ -789,27 +785,26 @@
             ASSERT_EQ(_encoder->Encode(_inputVideoBuffer, NULL, NULL),
                       WEBRTC_VIDEO_CODEC_OK);
             frameLength = WaitForEncodedFrame();
-            ASSERT_GE(frameLength, 0u);
             totalBytes += frameLength;
             frames++;
 
             _encodedVideoBuffer.SetLength(0);
         }
-        uint32_t actualBitrate =
-            (totalBytes  / frames * _inst.maxFramerate * 8)/1000;
-        printf("Target bitrate: %d kbps, actual bitrate: %d kbps\n", _bitRate,
-            actualBitrate);
+        uint32_t actualBitrate = static_cast<uint32_t>(
+            (totalBytes / frames * _inst.maxFramerate * 8) / 1000);
+        printf("Target bitrate: %u kbps, actual bitrate: %u kbps\n", _bitRate,
+               actualBitrate);
         // Test for close match over reasonable range.
-          EXPECT_TRUE(abs(int32_t(actualBitrate - _bitRate)) <
-                      0.12 * _bitRate);
+        EXPECT_LT(abs(static_cast<int32_t>(actualBitrate - _bitRate)),
+                  0.12 * _bitRate);
         ASSERT_TRUE(feof(_sourceFile) != 0);
         rewind(_sourceFile);
     }
 }
 
 bool
-UnitTest::CheckIfBitExact(const void* ptrA, unsigned int aLengthBytes,
-                          const void* ptrB, unsigned int bLengthBytes)
+UnitTest::CheckIfBitExact(const void* ptrA, size_t aLengthBytes,
+                          const void* ptrB, size_t bLengthBytes)
 {
     if (aLengthBytes != bLengthBytes)
     {
diff --git a/webrtc/modules/video_coding/codecs/test_framework/unit_test.h b/webrtc/modules/video_coding/codecs/test_framework/unit_test.h
index 4e2fea0..7e55a90 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/unit_test.h
+++ b/webrtc/modules/video_coding/codecs/test_framework/unit_test.h
@@ -48,11 +48,11 @@
     virtual int DecodeWithoutAssert();
     virtual int SetCodecSpecificParameters() {return 0;};
 
-    virtual bool CheckIfBitExact(const void *ptrA, unsigned int aLengthBytes,
-                                 const void *ptrB, unsigned int bLengthBytes);
+    virtual bool CheckIfBitExact(const void *ptrA, size_t aLengthBytes,
+                                 const void *ptrB, size_t bLengthBytes);
 
-    uint32_t WaitForEncodedFrame() const;
-    uint32_t WaitForDecodedFrame() const;
+    size_t WaitForEncodedFrame() const;
+    size_t WaitForDecodedFrame() const;
 
     int _tests;
     int _errors;
@@ -61,7 +61,7 @@
     unsigned char* _refFrame;
     unsigned char* _refEncFrame;
     unsigned char* _refDecFrame;
-    unsigned int _refEncFrameLength;
+    size_t _refEncFrameLength;
     FILE* _sourceFile;
     bool is_key_frame_;
 
diff --git a/webrtc/modules/video_coding/codecs/test_framework/video_source.cc b/webrtc/modules/video_coding/codecs/test_framework/video_source.cc
index 23fbaa8..7092e45 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/video_source.cc
+++ b/webrtc/modules/video_coding/codecs/test_framework/video_source.cc
@@ -116,7 +116,7 @@
     return kUndefined;
 }
 
-unsigned int
+size_t
 VideoSource::GetFrameLength() const
 {
     return webrtc::CalcBufferSize(_type, _width, _height);
diff --git a/webrtc/modules/video_coding/codecs/test_framework/video_source.h b/webrtc/modules/video_coding/codecs/test_framework/video_source.h
index b3c4e79..44f56ae 100644
--- a/webrtc/modules/video_coding/codecs/test_framework/video_source.h
+++ b/webrtc/modules/video_coding/codecs/test_framework/video_source.h
@@ -71,7 +71,7 @@
 
     VideoSize GetSize() const;
     static VideoSize GetSize(uint16_t width, uint16_t height);
-    unsigned int GetFrameLength() const;
+    size_t GetFrameLength() const;
 
     // Returns a human-readable size string.
     static const char* GetSizeString(VideoSize size);
diff --git a/webrtc/modules/video_coding/codecs/tools/video_quality_measurement.cc b/webrtc/modules/video_coding/codecs/tools/video_quality_measurement.cc
index 7a12446..ced92bc 100644
--- a/webrtc/modules/video_coding/codecs/tools/video_quality_measurement.cc
+++ b/webrtc/modules/video_coding/codecs/tools/video_quality_measurement.cc
@@ -20,6 +20,7 @@
 #endif
 
 #include "gflags/gflags.h"
+#include "webrtc/base/format_macros.h"
 #include "webrtc/common_types.h"
 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
 #include "webrtc/modules/video_coding/codecs/test/stats.h"
@@ -204,7 +205,8 @@
             FLAGS_packet_size);
     return 7;
   }
-  config->networking_config.packet_size_in_bytes = FLAGS_packet_size;
+  config->networking_config.packet_size_in_bytes =
+      static_cast<size_t>(FLAGS_packet_size);
 
   if (FLAGS_max_payload_size <= 0) {
     fprintf(stderr, "Max payload size must be >0 bytes, was: %d\n",
@@ -212,7 +214,7 @@
     return 8;
   }
   config->networking_config.max_payload_size_in_bytes =
-      FLAGS_max_payload_size;
+      static_cast<size_t>(FLAGS_max_payload_size);
 
   // Check the width and height
   if (FLAGS_width <= 0 || FLAGS_height <= 0) {
@@ -290,10 +292,10 @@
   Log("  Input filename   : %s\n", config.input_filename.c_str());
   Log("  Output directory : %s\n", config.output_dir.c_str());
   Log("  Output filename  : %s\n", config.output_filename.c_str());
-  Log("  Frame length       : %d bytes\n", config.frame_length_in_bytes);
-  Log("  Packet size      : %d bytes\n",
+  Log("  Frame length     : %" PRIuS " bytes\n", config.frame_length_in_bytes);
+  Log("  Packet size      : %" PRIuS " bytes\n",
       config.networking_config.packet_size_in_bytes);
-  Log("  Max payload size : %d bytes\n",
+  Log("  Max payload size : %" PRIuS " bytes\n",
       config.networking_config.max_payload_size_in_bytes);
   Log("  Packet loss:\n");
   Log("    Mode           : %s\n",
@@ -320,8 +322,8 @@
     const webrtc::test::FrameStatistic& f = stats.stats_[i];
     const webrtc::test::FrameResult& ssim = ssim_result.frames[i];
     const webrtc::test::FrameResult& psnr = psnr_result.frames[i];
-    printf("%4d, %d, %d, %2d, %2d, %6d, %6d, %5d, %7d, %d, %2d, %2d, "
-           "%5.3f, %5.2f\n",
+    printf("%4d, %d, %d, %2d, %2d, %6d, %6d, %5d, %7" PRIuS ", %d, %2d, %2"
+           PRIuS ", %5.3f, %5.2f\n",
            f.frame_number,
            f.encoding_successful,
            f.decoding_successful,
@@ -352,13 +354,13 @@
          "{'name': 'input_filename',            'value': '%s'},\n"
          "{'name': 'output_filename',           'value': '%s'},\n"
          "{'name': 'output_dir',                'value': '%s'},\n"
-         "{'name': 'packet_size_in_bytes',      'value': '%d'},\n"
-         "{'name': 'max_payload_size_in_bytes', 'value': '%d'},\n"
+         "{'name': 'packet_size_in_bytes',      'value': '%" PRIuS "'},\n"
+         "{'name': 'max_payload_size_in_bytes', 'value': '%" PRIuS "'},\n"
          "{'name': 'packet_loss_mode',          'value': '%s'},\n"
          "{'name': 'packet_loss_probability',   'value': '%f'},\n"
          "{'name': 'packet_loss_burst_length',  'value': '%d'},\n"
          "{'name': 'exclude_frame_types',       'value': '%s'},\n"
-         "{'name': 'frame_length_in_bytes',     'value': '%d'},\n"
+         "{'name': 'frame_length_in_bytes',     'value': '%" PRIuS "'},\n"
          "{'name': 'use_single_core',           'value': '%s'},\n"
          "{'name': 'keyframe_interval;',        'value': '%d'},\n"
          "{'name': 'video_codec_type',          'value': '%s'},\n"
@@ -411,9 +413,9 @@
            "'encoding_successful': %s, 'decoding_successful': %s, "
            "'encode_time': %d, 'decode_time': %d, "
            "'encode_return_code': %d, 'decode_return_code': %d, "
-           "'bit_rate': %d, 'encoded_frame_length': %d, 'frame_type': %s, "
-           "'packets_dropped': %d, 'total_packets': %d, "
-           "'ssim': %f, 'psnr': %f},\n",
+           "'bit_rate': %d, 'encoded_frame_length': %" PRIuS ", "
+           "'frame_type': %s, 'packets_dropped': %d, "
+           "'total_packets': %" PRIuS ", 'ssim': %f, 'psnr': %f},\n",
            f.frame_number,
            f.encoding_successful ? "True " : "False",
            f.decoding_successful ? "True " : "False",
diff --git a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
index 5e0bfc8..6666bab 100644
--- a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
@@ -148,7 +148,7 @@
     EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->InitDecode(&codec_inst_, 1));
   }
 
-  int WaitForEncodedFrame() const {
+  size_t WaitForEncodedFrame() const {
     int64_t startTime = TickTime::MillisecondTimestamp();
     while (TickTime::MillisecondTimestamp() - startTime < kMaxWaitEncTimeMs) {
       if (encode_complete_callback_->EncodeComplete()) {
@@ -158,7 +158,7 @@
     return 0;
   }
 
-  int WaitForDecodedFrame() const {
+  size_t WaitForDecodedFrame() const {
     int64_t startTime = TickTime::MillisecondTimestamp();
     while (TickTime::MillisecondTimestamp() - startTime < kMaxWaitDecTimeMs) {
       if (decode_complete_callback_->DecodeComplete()) {
@@ -188,7 +188,7 @@
   scoped_ptr<VideoDecoder> decoder_;
   VideoFrame encoded_video_frame_;
   I420VideoFrame decoded_video_frame_;
-  unsigned int length_source_frame_;
+  size_t length_source_frame_;
   VideoCodec codec_inst_;
 };
 
@@ -239,14 +239,14 @@
 TEST_F(TestVp8Impl, DISABLED_ON_ANDROID(AlignedStrideEncodeDecode)) {
   SetUpEncodeDecode();
   encoder_->Encode(input_frame_, NULL, NULL);
-  EXPECT_GT(WaitForEncodedFrame(), 0);
+  EXPECT_GT(WaitForEncodedFrame(), 0u);
   EncodedImage encodedImage;
   VideoFrameToEncodedImage(encoded_video_frame_, encodedImage);
   // First frame should be a key frame.
   encodedImage._frameType = kKeyFrame;
   encodedImage.ntp_time_ms_ = kTestNtpTimeMs;
   EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Decode(encodedImage, false, NULL));
-  EXPECT_GT(WaitForDecodedFrame(), 0);
+  EXPECT_GT(WaitForDecodedFrame(), 0u);
   // Compute PSNR on all planes (faster than SSIM).
   EXPECT_GT(I420PSNR(&input_frame_, &decoded_video_frame_), 36);
   EXPECT_EQ(kTestTimestamp, decoded_video_frame_.timestamp());
@@ -256,7 +256,7 @@
 TEST_F(TestVp8Impl, DISABLED_ON_ANDROID(DecodeWithACompleteKeyFrame)) {
   SetUpEncodeDecode();
   encoder_->Encode(input_frame_, NULL, NULL);
-  EXPECT_GT(WaitForEncodedFrame(), 0);
+  EXPECT_GT(WaitForEncodedFrame(), 0u);
   EncodedImage encodedImage;
   VideoFrameToEncodedImage(encoded_video_frame_, encodedImage);
   // Setting complete to false -> should return an error.
diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
index 2a2a9d0..5345c80 100644
--- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
@@ -116,7 +116,7 @@
 
 int VP8EncoderImpl::InitEncode(const VideoCodec* inst,
                                int number_of_cores,
-                               uint32_t /*max_payload_size*/) {
+                               size_t /*max_payload_size*/) {
   if (inst == NULL) {
     return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
   }
@@ -791,7 +791,7 @@
   for (int i = 0; i < fragmentation->fragmentationVectorSize; ++i) {
     const uint8_t* partition = input_image._buffer +
         fragmentation->fragmentationOffset[i];
-    const uint32_t partition_length =
+    const size_t partition_length =
         fragmentation->fragmentationLength[i];
     if (vpx_codec_decode(decoder_,
                          partition,
diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h
index fec53d5..06f2a26 100644
--- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h
+++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.h
@@ -39,7 +39,7 @@
 
   virtual int InitEncode(const VideoCodec* codec_settings,
                          int number_of_cores,
-                         uint32_t max_payload_size);
+                         size_t max_payload_size);
 
   virtual int Encode(const I420VideoFrame& input_image,
                      const CodecSpecificInfo* codec_specific_info,
diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc
index ffa0bcc..992f089 100644
--- a/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc
@@ -30,11 +30,11 @@
               const webrtc::RTPFragmentationHeader*);
   // Returns the encoded image.
   webrtc::EncodedImage encoded_image() { return encoded_image_; }
-  int encoded_bytes() { return encoded_bytes_; }
+  size_t encoded_bytes() { return encoded_bytes_; }
  private:
   webrtc::EncodedImage encoded_image_;
   FILE* encoded_file_;
-  int encoded_bytes_;
+  size_t encoded_bytes_;
 };
 
 Vp8SequenceCoderEncodeCallback::~Vp8SequenceCoderEncodeCallback() {
@@ -141,7 +141,7 @@
   }
   EXPECT_EQ(0, decoder->InitDecode(&inst, 1));
   webrtc::I420VideoFrame input_frame;
-  unsigned int length = webrtc::CalcBufferSize(webrtc::kI420, width, height);
+  size_t length = webrtc::CalcBufferSize(webrtc::kI420, width, height);
   webrtc::scoped_ptr<uint8_t[]> frame_buffer(new uint8_t[length]);
 
   int half_width = (width + 1) / 2;
@@ -175,9 +175,8 @@
   int64_t totalExecutionTime = endtime - starttime;
   printf("Total execution time: %.2lf ms\n",
          static_cast<double>(totalExecutionTime));
-  int sum_enc_bytes = encoder_callback.encoded_bytes();
-  double actual_bit_rate =  8.0 * sum_enc_bytes /
-      (frame_cnt / inst.maxFramerate);
+  double actual_bit_rate =
+      8.0 * encoder_callback.encoded_bytes() / (frame_cnt / inst.maxFramerate);
   printf("Actual bitrate: %f kbps\n", actual_bit_rate / 1000);
   webrtc::test::QualityMetricsResult psnr_result, ssim_result;
   EXPECT_EQ(0, webrtc::test::I420MetricsFromFiles(
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
index 734e73d..fa5b05b 100644
--- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -103,7 +103,7 @@
 
 int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
                                int number_of_cores,
-                               uint32_t /*max_payload_size*/) {
+                               size_t /*max_payload_size*/) {
   if (inst == NULL) {
     return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
   }
@@ -428,7 +428,7 @@
   }
   if (vpx_codec_decode(decoder_,
                        buffer,
-                       input_image._length,
+                       static_cast<unsigned int>(input_image._length),
                        0,
                        VPX_DL_REALTIME)) {
     return WEBRTC_VIDEO_CODEC_ERROR;
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h
index 94788db..355aadf 100644
--- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.h
@@ -34,7 +34,7 @@
 
   virtual int InitEncode(const VideoCodec* codec_settings,
                          int number_of_cores,
-                         uint32_t max_payload_size) OVERRIDE;
+                         size_t max_payload_size) OVERRIDE;
 
   virtual int Encode(const I420VideoFrame& input_image,
                      const CodecSpecificInfo* codec_specific_info,
diff --git a/webrtc/modules/video_coding/main/interface/video_coding.h b/webrtc/modules/video_coding/main/interface/video_coding.h
index ef9209a..d46ac15 100644
--- a/webrtc/modules/video_coding/main/interface/video_coding.h
+++ b/webrtc/modules/video_coding/main/interface/video_coding.h
@@ -467,8 +467,8 @@
     // Return value      : VCM_OK, on success.
     //                     < 0,         on error.
     virtual int32_t IncomingPacket(const uint8_t* incomingPayload,
-                                       uint32_t payloadLength,
-                                       const WebRtcRTPHeader& rtpInfo) = 0;
+                                   size_t payloadLength,
+                                   const WebRtcRTPHeader& rtpInfo) = 0;
 
     // Minimum playout delay (Used for lip-sync). This is the minimum delay required
     // to sync with audio. Not included in  VideoCodingModule::Delay()
diff --git a/webrtc/modules/video_coding/main/interface/video_coding_defines.h b/webrtc/modules/video_coding/main/interface/video_coding_defines.h
index efdc41b..72658a3 100644
--- a/webrtc/modules/video_coding/main/interface/video_coding_defines.h
+++ b/webrtc/modules/video_coding/main/interface/video_coding_defines.h
@@ -75,7 +75,7 @@
       uint32_t timeStamp,
       int64_t capture_time_ms,
       const uint8_t* payloadData,
-      uint32_t payloadSize,
+      size_t payloadSize,
       const RTPFragmentationHeader& fragmentationHeader,
       const RTPVideoHeader* rtpVideoHdr) = 0;
  protected:
diff --git a/webrtc/modules/video_coding/main/source/codec_database.cc b/webrtc/modules/video_coding/main/source/codec_database.cc
index 2fc9246..3bd65d6 100644
--- a/webrtc/modules/video_coding/main/source/codec_database.cc
+++ b/webrtc/modules/video_coding/main/source/codec_database.cc
@@ -25,6 +25,10 @@
 #include "webrtc/modules/video_coding/main/source/internal_defines.h"
 #include "webrtc/system_wrappers/interface/logging.h"
 
+namespace {
+const size_t kDefaultPayloadSize = 1440;
+}
+
 namespace webrtc {
 
 VideoCodecVP8 VideoEncoder::GetDefaultVp8Settings() {
@@ -227,12 +231,12 @@
 bool VCMCodecDataBase::SetSendCodec(
     const VideoCodec* send_codec,
     int number_of_cores,
-    int max_payload_size,
+    size_t max_payload_size,
     VCMEncodedFrameCallback* encoded_frame_callback) {
   if (!send_codec) {
     return false;
   }
-  if (max_payload_size <= 0) {
+  if (max_payload_size == 0) {
     max_payload_size = kDefaultPayloadSize;
   }
   if (number_of_cores <= 0) {
diff --git a/webrtc/modules/video_coding/main/source/codec_database.h b/webrtc/modules/video_coding/main/source/codec_database.h
index f27218f..a31decb 100644
--- a/webrtc/modules/video_coding/main/source/codec_database.h
+++ b/webrtc/modules/video_coding/main/source/codec_database.h
@@ -22,10 +22,6 @@
 
 namespace webrtc {
 
-enum VCMCodecDBProperties {
-  kDefaultPayloadSize = 1440
-};
-
 struct VCMDecoderMapItem {
  public:
   VCMDecoderMapItem(VideoCodec* settings,
@@ -70,7 +66,7 @@
   // Returns true if the codec was successfully registered, false otherwise.
   bool SetSendCodec(const VideoCodec* send_codec,
                     int number_of_cores,
-                    int max_payload_size,
+                    size_t max_payload_size,
                     VCMEncodedFrameCallback* encoded_frame_callback);
 
   // Gets the current send codec. Relevant for internal codecs only.
@@ -175,7 +171,7 @@
       uint8_t payload_type) const;
 
   int number_of_cores_;
-  int max_payload_size_;
+  size_t max_payload_size_;
   bool periodic_key_frames_;
   bool pending_encoder_reset_;
   bool current_enc_is_external_;
diff --git a/webrtc/modules/video_coding/main/source/encoded_frame.h b/webrtc/modules/video_coding/main/source/encoded_frame.h
index dd0f843..4be4e6b 100644
--- a/webrtc/modules/video_coding/main/source/encoded_frame.h
+++ b/webrtc/modules/video_coding/main/source/encoded_frame.h
@@ -56,7 +56,7 @@
     /**
     *   Get frame length
     */
-    uint32_t Length() const {return _length;}
+    size_t Length() const {return _length;}
     /**
     *   Get frame timestamp (90kHz)
     */
diff --git a/webrtc/modules/video_coding/main/source/frame_buffer.cc b/webrtc/modules/video_coding/main/source/frame_buffer.cc
index fce68fb..6dd3554 100644
--- a/webrtc/modules/video_coding/main/source/frame_buffer.cc
+++ b/webrtc/modules/video_coding/main/source/frame_buffer.cc
@@ -268,11 +268,11 @@
             _sessionInfo.BuildVP8FragmentationHeader(_buffer, _length,
                                                      &_fragmentation);
     } else {
-        int bytes_removed = _sessionInfo.MakeDecodable();
+        size_t bytes_removed = _sessionInfo.MakeDecodable();
         _length -= bytes_removed;
     }
 #else
-    int bytes_removed = _sessionInfo.MakeDecodable();
+    size_t bytes_removed = _sessionInfo.MakeDecodable();
     _length -= bytes_removed;
 #endif
     // Transfer frame information to EncodedFrame and create any codec
diff --git a/webrtc/modules/video_coding/main/source/generic_encoder.cc b/webrtc/modules/video_coding/main/source/generic_encoder.cc
index 655f7ac..d6a7bbb 100644
--- a/webrtc/modules/video_coding/main/source/generic_encoder.cc
+++ b/webrtc/modules/video_coding/main/source/generic_encoder.cc
@@ -82,7 +82,7 @@
 int32_t
 VCMGenericEncoder::InitEncode(const VideoCodec* settings,
                               int32_t numberOfCores,
-                              uint32_t maxPayloadSize)
+                              size_t maxPayloadSize)
 {
     _bitRate = settings->startBitrate * 1000;
     _frameRate = settings->maxFramerate;
@@ -218,7 +218,7 @@
 
     FrameType frameType = VCMEncodedFrame::ConvertFrameType(encodedImage._frameType);
 
-    uint32_t encodedBytes = 0;
+    size_t encodedBytes = 0;
     if (_sendCallback != NULL)
     {
         encodedBytes = encodedImage._length;
diff --git a/webrtc/modules/video_coding/main/source/generic_encoder.h b/webrtc/modules/video_coding/main/source/generic_encoder.h
index 9277260..8eb1480 100644
--- a/webrtc/modules/video_coding/main/source/generic_encoder.h
+++ b/webrtc/modules/video_coding/main/source/generic_encoder.h
@@ -84,7 +84,7 @@
     */
     int32_t InitEncode(const VideoCodec* settings,
                        int32_t numberOfCores,
-                       uint32_t maxPayloadSize);
+                       size_t maxPayloadSize);
     /**
     * Encode raw image
     * inputFrame        : Frame containing raw image
diff --git a/webrtc/modules/video_coding/main/source/media_optimization.cc b/webrtc/modules/video_coding/main/source/media_optimization.cc
index 5789480..630f013 100644
--- a/webrtc/modules/video_coding/main/source/media_optimization.cc
+++ b/webrtc/modules/video_coding/main/source/media_optimization.cc
@@ -62,14 +62,14 @@
 }  // namespace
 
 struct MediaOptimization::EncodedFrameSample {
-  EncodedFrameSample(int size_bytes,
+  EncodedFrameSample(size_t size_bytes,
                      uint32_t timestamp,
                      int64_t time_complete_ms)
       : size_bytes(size_bytes),
         timestamp(timestamp),
         time_complete_ms(time_complete_ms) {}
 
-  uint32_t size_bytes;
+  size_t size_bytes;
   uint32_t timestamp;
   int64_t time_complete_ms;
 };
@@ -369,7 +369,7 @@
   return count;
 }
 
-int32_t MediaOptimization::UpdateWithEncodedData(int encoded_length,
+int32_t MediaOptimization::UpdateWithEncodedData(size_t encoded_length,
                                                  uint32_t timestamp,
                                                  FrameType encoded_frame_type) {
   CriticalSectionScoped lock(crit_sect_.get());
@@ -532,7 +532,7 @@
     avg_sent_bit_rate_bps_ = 0;
     return;
   }
-  int framesize_sum = 0;
+  size_t framesize_sum = 0;
   for (FrameSampleList::iterator it = encoded_frame_samples_.begin();
        it != encoded_frame_samples_.end();
        ++it) {
diff --git a/webrtc/modules/video_coding/main/source/media_optimization.h b/webrtc/modules/video_coding/main/source/media_optimization.h
index df3fbb6..af35f01 100644
--- a/webrtc/modules/video_coding/main/source/media_optimization.h
+++ b/webrtc/modules/video_coding/main/source/media_optimization.h
@@ -77,7 +77,7 @@
   void UpdateContentData(const VideoContentMetrics* content_metrics);
 
   // Informs Media Optimization of encoding output: Length and frame type.
-  int32_t UpdateWithEncodedData(int encoded_length,
+  int32_t UpdateWithEncodedData(size_t encoded_length,
                                 uint32_t timestamp,
                                 FrameType encoded_frame_type);
 
diff --git a/webrtc/modules/video_coding/main/source/media_optimization_unittest.cc b/webrtc/modules/video_coding/main/source/media_optimization_unittest.cc
index bacfdc6..df79fb7 100644
--- a/webrtc/modules/video_coding/main/source/media_optimization_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/media_optimization_unittest.cc
@@ -30,12 +30,11 @@
         next_timestamp_(0) {}
 
   // This method mimics what happens in VideoSender::AddVideoFrame.
-  void AddFrameAndAdvanceTime(int bitrate_bps, bool expect_frame_drop) {
-    ASSERT_GE(bitrate_bps, 0);
+  void AddFrameAndAdvanceTime(uint32_t bitrate_bps, bool expect_frame_drop) {
     bool frame_dropped = media_opt_.DropFrame();
     EXPECT_EQ(expect_frame_drop, frame_dropped);
     if (!frame_dropped) {
-      int bytes_per_frame = bitrate_bps * frame_time_ms_ / (8 * 1000);
+      size_t bytes_per_frame = bitrate_bps * frame_time_ms_ / (8 * 1000);
       ASSERT_EQ(VCM_OK, media_opt_.UpdateWithEncodedData(
           bytes_per_frame, next_timestamp_, kVideoFrameDelta));
     }
@@ -54,14 +53,14 @@
   // Enable video suspension with these limits.
   // Suspend the video when the rate is below 50 kbps and resume when it gets
   // above 50 + 10 kbps again.
-  const int kThresholdBps = 50000;
-  const int kWindowBps = 10000;
+  const uint32_t kThresholdBps = 50000;
+  const uint32_t kWindowBps = 10000;
   media_opt_.SuspendBelowMinBitrate(kThresholdBps, kWindowBps);
 
   // The video should not be suspended from the start.
   EXPECT_FALSE(media_opt_.IsVideoSuspended());
 
-  int target_bitrate_kbps = 100;
+  uint32_t target_bitrate_kbps = 100;
   media_opt_.SetTargetRates(target_bitrate_kbps * 1000,
                             0,  // Lossrate.
                             100,
diff --git a/webrtc/modules/video_coding/main/source/packet.cc b/webrtc/modules/video_coding/main/source/packet.cc
index 63dcd63..dd3743f 100644
--- a/webrtc/modules/video_coding/main/source/packet.cc
+++ b/webrtc/modules/video_coding/main/source/packet.cc
@@ -35,7 +35,7 @@
 }
 
 VCMPacket::VCMPacket(const uint8_t* ptr,
-                     const uint32_t size,
+                     const size_t size,
                      const WebRtcRTPHeader& rtpHeader) :
     payloadType(rtpHeader.header.payloadType),
     timestamp(rtpHeader.header.timestamp),
@@ -57,7 +57,11 @@
     CopyCodecSpecifics(rtpHeader.type.Video);
 }
 
-VCMPacket::VCMPacket(const uint8_t* ptr, uint32_t size, uint16_t seq, uint32_t ts, bool mBit) :
+VCMPacket::VCMPacket(const uint8_t* ptr,
+                     size_t size,
+                     uint16_t seq,
+                     uint32_t ts,
+                     bool mBit) :
     payloadType(0),
     timestamp(ts),
     ntp_time_ms_(0),
diff --git a/webrtc/modules/video_coding/main/source/packet.h b/webrtc/modules/video_coding/main/source/packet.h
index 242d3a4..d98b6f6 100644
--- a/webrtc/modules/video_coding/main/source/packet.h
+++ b/webrtc/modules/video_coding/main/source/packet.h
@@ -21,10 +21,10 @@
 public:
     VCMPacket();
     VCMPacket(const uint8_t* ptr,
-              const uint32_t size,
+              const size_t size,
               const WebRtcRTPHeader& rtpHeader);
     VCMPacket(const uint8_t* ptr,
-              uint32_t size,
+              size_t size,
               uint16_t seqNum,
               uint32_t timestamp,
               bool markerBit);
@@ -37,7 +37,7 @@
     int64_t ntp_time_ms_;
     uint16_t          seqNum;
     const uint8_t*    dataPtr;
-    uint32_t          sizeBytes;
+    size_t          sizeBytes;
     bool                    markerBit;
 
     FrameType               frameType;
diff --git a/webrtc/modules/video_coding/main/source/qm_select.cc b/webrtc/modules/video_coding/main/source/qm_select.cc
index 85c5f36..0df61b5 100644
--- a/webrtc/modules/video_coding/main/source/qm_select.cc
+++ b/webrtc/modules/video_coding/main/source/qm_select.cc
@@ -239,11 +239,11 @@
 }
 
 // Update rate data after every encoded frame.
-void VCMQmResolution::UpdateEncodedSize(int encoded_size,
+void VCMQmResolution::UpdateEncodedSize(size_t encoded_size,
                                         FrameType encoded_frame_type) {
   frame_cnt_++;
   // Convert to Kbps.
-  float encoded_size_kbits = static_cast<float>((encoded_size * 8.0) / 1000.0);
+  float encoded_size_kbits = 8.0f * static_cast<float>(encoded_size) / 1000.0f;
 
   // Update the buffer level:
   // Note this is not the actual encoder buffer level.
diff --git a/webrtc/modules/video_coding/main/source/qm_select.h b/webrtc/modules/video_coding/main/source/qm_select.h
index ce57236..a87d502 100644
--- a/webrtc/modules/video_coding/main/source/qm_select.h
+++ b/webrtc/modules/video_coding/main/source/qm_select.h
@@ -216,7 +216,7 @@
 
   // Update with actual bit rate (size of the latest encoded frame)
   // and frame type, after every encoded frame.
-  void UpdateEncodedSize(int encoded_size,
+  void UpdateEncodedSize(size_t encoded_size,
                          FrameType encoded_frame_type);
 
   // Update with new target bitrate, actual encoder sent rate, frame_rate,
diff --git a/webrtc/modules/video_coding/main/source/qm_select_unittest.cc b/webrtc/modules/video_coding/main/source/qm_select_unittest.cc
index 5a7daed..0120f20 100644
--- a/webrtc/modules/video_coding/main/source/qm_select_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/qm_select_unittest.cc
@@ -46,7 +46,7 @@
                         int native_height,
                         int num_layers);
 
-  void UpdateQmEncodedFrame(int* encoded_size, int num_updates);
+  void UpdateQmEncodedFrame(size_t* encoded_size, size_t num_updates);
 
   void UpdateQmRateData(int* target_rate,
                         int* encoder_sent_rate,
@@ -315,8 +315,8 @@
 
   // Update with encoded size over a number of frames.
   // per-frame bandwidth = 15 = 450/30: simulate (decoder) buffer underflow:
-  int encoded_size[] = {200, 100, 50, 30, 60, 40, 20, 30, 20, 40};
-  UpdateQmEncodedFrame(encoded_size, 10);
+  size_t encoded_size[] = {200, 100, 50, 30, 60, 40, 20, 30, 20, 40};
+  UpdateQmEncodedFrame(encoded_size, GTEST_ARRAY_SIZE_(encoded_size));
 
   // Update rates for a sequence of intervals.
   int target_rate[] = {300, 300, 300};
@@ -359,8 +359,8 @@
 
   // Update with encoded size over a number of frames.
   // per-frame bandwidth = 15 = 450/30: simulate stable (decoder) buffer levels.
-  int32_t encoded_size[] = {40, 10, 10, 16, 18, 20, 17, 20, 16, 15};
-  UpdateQmEncodedFrame(encoded_size, 10);
+  size_t encoded_size[] = {40, 10, 10, 16, 18, 20, 17, 20, 16, 15};
+  UpdateQmEncodedFrame(encoded_size, GTEST_ARRAY_SIZE_(encoded_size));
 
   // Update rates for a sequence of intervals.
   int target_rate[] = {350, 350, 350};
@@ -1262,11 +1262,12 @@
   qm_resolution_->UpdateContent(content_metrics_);
 }
 
-void QmSelectTest::UpdateQmEncodedFrame(int* encoded_size, int num_updates) {
+void QmSelectTest::UpdateQmEncodedFrame(size_t* encoded_size,
+                                        size_t num_updates) {
   FrameType frame_type = kVideoFrameDelta;
-  for (int i = 0; i < num_updates; ++i) {
+  for (size_t i = 0; i < num_updates; ++i) {
     // Convert to bytes.
-    int32_t encoded_size_update = 1000 * encoded_size[i] / 8;
+    size_t encoded_size_update = 1000 * encoded_size[i] / 8;
     qm_resolution_->UpdateEncodedSize(encoded_size_update, frame_type);
   }
 }
diff --git a/webrtc/modules/video_coding/main/source/session_info.cc b/webrtc/modules/video_coding/main/source/session_info.cc
index d7d576d..b165d7c 100644
--- a/webrtc/modules/video_coding/main/source/session_info.cc
+++ b/webrtc/modules/video_coding/main/source/session_info.cc
@@ -110,8 +110,8 @@
   last_packet_seq_num_ = -1;
 }
 
-int VCMSessionInfo::SessionLength() const {
-  int length = 0;
+size_t VCMSessionInfo::SessionLength() const {
+  size_t length = 0;
   for (PacketIteratorConst it = packets_.begin(); it != packets_.end(); ++it)
     length += (*it).sizeBytes;
   return length;
@@ -121,13 +121,13 @@
   return packets_.size();
 }
 
-int VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer,
-                                 PacketIterator packet_it) {
+size_t VCMSessionInfo::InsertBuffer(uint8_t* frame_buffer,
+                                    PacketIterator packet_it) {
   VCMPacket& packet = *packet_it;
   PacketIterator it;
 
   // Calculate the offset into the frame buffer for this packet.
-  int offset = 0;
+  size_t offset = 0;
   for (it = packets_.begin(); it != packet_it; ++it)
     offset += (*it).sizeBytes;
 
@@ -145,7 +145,7 @@
     size_t required_length = 0;
     const uint8_t* nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes;
     while (nalu_ptr < packet_buffer + packet.sizeBytes) {
-      uint32_t length = BufferToUWord16(nalu_ptr);
+      size_t length = BufferToUWord16(nalu_ptr);
       required_length +=
           length + (packet.insertStartCode ? kH264StartCodeLengthBytes : 0);
       nalu_ptr += kLengthFieldLength + length;
@@ -154,7 +154,7 @@
     nalu_ptr = packet_buffer + kH264NALHeaderLengthInBytes;
     uint8_t* frame_buffer_ptr = frame_buffer + offset;
     while (nalu_ptr < packet_buffer + packet.sizeBytes) {
-      uint32_t length = BufferToUWord16(nalu_ptr);
+      size_t length = BufferToUWord16(nalu_ptr);
       nalu_ptr += kLengthFieldLength;
       frame_buffer_ptr += Insert(nalu_ptr,
                                  length,
@@ -276,9 +276,9 @@
   return --packet_it;
 }
 
-int VCMSessionInfo::DeletePacketData(PacketIterator start,
-                                     PacketIterator end) {
-  int bytes_to_delete = 0;  // The number of bytes to delete.
+size_t VCMSessionInfo::DeletePacketData(PacketIterator start,
+                                        PacketIterator end) {
+  size_t bytes_to_delete = 0;  // The number of bytes to delete.
   PacketIterator packet_after_end = end;
   ++packet_after_end;
 
@@ -290,20 +290,20 @@
     (*it).dataPtr = NULL;
   }
   if (bytes_to_delete > 0)
-    ShiftSubsequentPackets(end, -bytes_to_delete);
+    ShiftSubsequentPackets(end, -static_cast<int>(bytes_to_delete));
   return bytes_to_delete;
 }
 
-int VCMSessionInfo::BuildVP8FragmentationHeader(
+size_t VCMSessionInfo::BuildVP8FragmentationHeader(
     uint8_t* frame_buffer,
-    int frame_buffer_length,
+    size_t frame_buffer_length,
     RTPFragmentationHeader* fragmentation) {
-  int new_length = 0;
+  size_t new_length = 0;
   // Allocate space for max number of partitions
   fragmentation->VerifyAndAllocateFragmentationHeader(kMaxVP8Partitions);
   fragmentation->fragmentationVectorSize = 0;
   memset(fragmentation->fragmentationLength, 0,
-         kMaxVP8Partitions * sizeof(uint32_t));
+         kMaxVP8Partitions * sizeof(size_t));
   if (packets_.empty())
       return new_length;
   PacketIterator it = FindNextPartitionBeginning(packets_.begin());
@@ -314,11 +314,11 @@
     fragmentation->fragmentationOffset[partition_id] =
         (*it).dataPtr - frame_buffer;
     assert(fragmentation->fragmentationOffset[partition_id] <
-           static_cast<uint32_t>(frame_buffer_length));
+           frame_buffer_length);
     fragmentation->fragmentationLength[partition_id] =
         (*partition_end).dataPtr + (*partition_end).sizeBytes - (*it).dataPtr;
     assert(fragmentation->fragmentationLength[partition_id] <=
-           static_cast<uint32_t>(frame_buffer_length));
+           frame_buffer_length);
     new_length += fragmentation->fragmentationLength[partition_id];
     ++partition_end;
     it = FindNextPartitionBeginning(partition_end);
@@ -385,8 +385,8 @@
           (*packet_it).seqNum));
 }
 
-int VCMSessionInfo::MakeDecodable() {
-  int return_length = 0;
+size_t VCMSessionInfo::MakeDecodable() {
+  size_t return_length = 0;
   if (packets_.empty()) {
     return 0;
   }
@@ -511,13 +511,13 @@
   // The insert operation invalidates the iterator |rit|.
   PacketIterator packet_list_it = packets_.insert(rit.base(), packet);
 
-  int returnLength = InsertBuffer(frame_buffer, packet_list_it);
+  size_t returnLength = InsertBuffer(frame_buffer, packet_list_it);
   UpdateCompleteSession();
   if (decode_error_mode == kWithErrors)
     decodable_ = true;
   else if (decode_error_mode == kSelectiveErrors)
     UpdateDecodableSession(frame_data);
-  return returnLength;
+  return static_cast<int>(returnLength);
 }
 
 void VCMSessionInfo::InformOfEmptyPacket(uint16_t seq_num) {
diff --git a/webrtc/modules/video_coding/main/source/session_info.h b/webrtc/modules/video_coding/main/source/session_info.h
index 25216c7..cd55130 100644
--- a/webrtc/modules/video_coding/main/source/session_info.h
+++ b/webrtc/modules/video_coding/main/source/session_info.h
@@ -56,15 +56,15 @@
   // Builds fragmentation headers for VP8, each fragment being a decodable
   // VP8 partition. Returns the total number of bytes which are decodable. Is
   // used instead of MakeDecodable for VP8.
-  int BuildVP8FragmentationHeader(uint8_t* frame_buffer,
-                                  int frame_buffer_length,
-                                  RTPFragmentationHeader* fragmentation);
+  size_t BuildVP8FragmentationHeader(uint8_t* frame_buffer,
+                                     size_t frame_buffer_length,
+                                     RTPFragmentationHeader* fragmentation);
 
   // Makes the frame decodable. I.e., only contain decodable NALUs. All
   // non-decodable NALUs will be deleted and packets will be moved to in
   // memory to remove any empty space.
   // Returns the number of bytes deleted from the session.
-  int MakeDecodable();
+  size_t MakeDecodable();
 
   // Sets decodable_ to false.
   // Used by the dual decoder. After the mode is changed to kNoErrors from
@@ -72,7 +72,7 @@
   // decodable and are not complete are marked as non-decodable.
   void SetNotDecodableIfIncomplete();
 
-  int SessionLength() const;
+  size_t SessionLength() const;
   int NumPackets() const;
   bool HaveFirstPacket() const;
   bool HaveLastPacket() const;
@@ -114,8 +114,8 @@
   PacketIterator FindPartitionEnd(PacketIterator it) const;
   static bool InSequence(const PacketIterator& it,
                          const PacketIterator& prev_it);
-  int InsertBuffer(uint8_t* frame_buffer,
-                   PacketIterator packetIterator);
+  size_t InsertBuffer(uint8_t* frame_buffer,
+                      PacketIterator packetIterator);
   size_t Insert(const uint8_t* buffer,
                 size_t length,
                 bool insert_start_code,
@@ -124,8 +124,8 @@
   PacketIterator FindNaluEnd(PacketIterator packet_iter) const;
   // Deletes the data of all packets between |start| and |end|, inclusively.
   // Note that this function doesn't delete the actual packets.
-  int DeletePacketData(PacketIterator start,
-                       PacketIterator end);
+  size_t DeletePacketData(PacketIterator start,
+                          PacketIterator end);
   void UpdateCompleteSession();
 
   // When enabled, determine if session is decodable, i.e. incomplete but
diff --git a/webrtc/modules/video_coding/main/source/session_info_unittest.cc b/webrtc/modules/video_coding/main/source/session_info_unittest.cc
index 2fab94d..fae55f4 100644
--- a/webrtc/modules/video_coding/main/source/session_info_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/session_info_unittest.cc
@@ -34,20 +34,20 @@
   }
 
   void FillPacket(uint8_t start_value) {
-    for (int i = 0; i < packet_buffer_size(); ++i)
+    for (size_t i = 0; i < packet_buffer_size(); ++i)
       packet_buffer_[i] = start_value + i;
   }
 
   void VerifyPacket(uint8_t* start_ptr, uint8_t start_value) {
-    for (int j = 0; j < packet_buffer_size(); ++j) {
+    for (size_t j = 0; j < packet_buffer_size(); ++j) {
       ASSERT_EQ(start_value + j, start_ptr[j]);
     }
   }
 
-  int packet_buffer_size() const {
+  size_t packet_buffer_size() const {
     return sizeof(packet_buffer_) / sizeof(packet_buffer_[0]);
   }
-  int frame_buffer_size() const {
+  size_t frame_buffer_size() const {
     return sizeof(frame_buffer_) / sizeof(frame_buffer_[0]);
   }
 
@@ -77,10 +77,10 @@
   bool VerifyPartition(int partition_id,
                        int packets_expected,
                        int start_value) {
-    EXPECT_EQ(static_cast<uint32_t>(packets_expected * packet_buffer_size()),
+    EXPECT_EQ(packets_expected * packet_buffer_size(),
               fragmentation_.fragmentationLength[partition_id]);
     for (int i = 0; i < packets_expected; ++i) {
-      int packet_index = fragmentation_.fragmentationOffset[partition_id] +
+      size_t packet_index = fragmentation_.fragmentationOffset[partition_id] +
           i * packet_buffer_size();
       if (packet_index + packet_buffer_size() > frame_buffer_size())
         return false;
@@ -154,10 +154,8 @@
   packet_.frameType = kVideoFrameKey;
   FillPacket(0);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-            frame_buffer_,
-            kNoErrors,
-            frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   EXPECT_FALSE(session_.HaveLastPacket());
   EXPECT_EQ(kVideoFrameKey, session_.FrameType());
 
@@ -165,10 +163,8 @@
   packet_.markerBit = true;
   packet_.seqNum += 1;
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   EXPECT_TRUE(session_.HaveLastPacket());
   EXPECT_EQ(packet_.seqNum, session_.HighSequenceNumber());
   EXPECT_EQ(0xFFFE, session_.LowSequenceNumber());
@@ -193,31 +189,26 @@
   packet_.isFirstPacket = true;
   packet_.markerBit = false;
   FillPacket(0);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.isFirstPacket = false;
   for (int i = 1; i < 9; ++i) {
     packet_.seqNum += 1;
     FillPacket(i);
-    ASSERT_EQ(session_.InsertPacket(packet_,
-                                    frame_buffer_,
-                                    kNoErrors,
-                                    frame_data),
-              packet_buffer_size());
+    ASSERT_EQ(packet_buffer_size(),
+              static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                        kNoErrors,
+                                                        frame_data)));
   }
 
   packet_.seqNum += 1;
   packet_.markerBit = true;
   FillPacket(9);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   EXPECT_EQ(10 * packet_buffer_size(), session_.SessionLength());
   for (int i = 0; i < 10; ++i) {
@@ -231,11 +222,10 @@
   packet_.isFirstPacket = false;
   packet_.markerBit = false;
   FillPacket(3);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kWithErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kWithErrors,
+                                                      frame_data)));
   EXPECT_TRUE(session_.decodable());
 }
 
@@ -246,21 +236,19 @@
   FillPacket(1);
   frame_data.rolling_average_packets_per_frame = 11;
   frame_data.rtt_ms = 150;
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kSelectiveErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kSelectiveErrors,
+                                                      frame_data)));
   EXPECT_FALSE(session_.decodable());
 
   packet_.seqNum -= 1;
   FillPacket(0);
   packet_.isFirstPacket = true;
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kSelectiveErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kSelectiveErrors,
+                                                      frame_data)));
   EXPECT_TRUE(session_.decodable());
 
   packet_.isFirstPacket = false;
@@ -268,21 +256,19 @@
   for (int i = 2; i < 8; ++i) {
     packet_.seqNum += 1;
     FillPacket(i);
-    EXPECT_EQ(session_.InsertPacket(packet_,
-                                    frame_buffer_,
-                                    kSelectiveErrors,
-                                    frame_data),
-              packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kSelectiveErrors,
+                                                      frame_data)));
     EXPECT_TRUE(session_.decodable());
   }
 
   packet_.seqNum += 1;
   FillPacket(8);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kSelectiveErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kSelectiveErrors,
+                                                      frame_data)));
   EXPECT_TRUE(session_.decodable());
 }
 
@@ -291,11 +277,9 @@
   packet_.isFirstPacket = true;
   packet_.markerBit = true;
   FillPacket(1);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.seqNum = 0x0004;
   packet_.isFirstPacket = true;
@@ -320,11 +304,9 @@
   packet_.isFirstPacket = false;
   packet_.markerBit = true;
   FillPacket(1);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   ++packet_.seqNum;
   packet_.isFirstPacket = true;
   packet_.markerBit = true;
@@ -342,10 +324,8 @@
   packet_.markerBit = false;
   FillPacket(1);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   // Insert an older packet with a first packet set.
   packet_.seqNum = 0x0004;
   packet_.isFirstPacket = true;
@@ -360,10 +340,8 @@
   packet_.markerBit = true;
   FillPacket(1);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   packet_.seqNum = 0x0008;
   packet_.isFirstPacket = false;
   packet_.markerBit = true;
@@ -380,29 +358,23 @@
   packet_.markerBit = false;
   FillPacket(1);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.seqNum = 0x0004;
   packet_.isFirstPacket = false;
   packet_.markerBit = true;
   FillPacket(1);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   packet_.seqNum = 0x0002;
   packet_.isFirstPacket = false;
   packet_.markerBit = false;
   FillPacket(1);
   ASSERT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   packet_.seqNum = 0xFFF0;
   packet_.isFirstPacket = false;
   packet_.markerBit = false;
@@ -431,20 +403,16 @@
   packet_.markerBit = false;
   FillPacket(1);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   // Insert an older packet with a first packet set.
   packet_.seqNum = 0x0005;
   packet_.isFirstPacket = true;
   packet_.markerBit = false;
   FillPacket(1);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   packet_.seqNum = 0x0004;
   packet_.isFirstPacket = false;
   packet_.markerBit = false;
@@ -458,19 +426,15 @@
   packet_.markerBit = false;
   FillPacket(1);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   packet_.seqNum = 0x0008;
   packet_.isFirstPacket = false;
   packet_.markerBit = true;
   FillPacket(1);
   EXPECT_EQ(packet_buffer_size(),
-            session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data));
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.seqNum = 0x0009;
   packet_.isFirstPacket = false;
@@ -493,11 +457,9 @@
   FillPacket(0);
   VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
                                     packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -507,11 +469,9 @@
   packet_header_.header.sequenceNumber += 2;
   FillPacket(2);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -521,18 +481,15 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(3);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   // One packet should be removed (end of partition 0).
-  EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
-                                                 frame_buffer_size(),
-                                                 &fragmentation_),
-            2 * packet_buffer_size());
+  EXPECT_EQ(2 * packet_buffer_size(),
+            session_.BuildVP8FragmentationHeader(
+                frame_buffer_, frame_buffer_size(), &fragmentation_));
   SCOPED_TRACE("Calling VerifyPartition");
   EXPECT_TRUE(VerifyPartition(0, 1, 0));
   SCOPED_TRACE("Calling VerifyPartition");
@@ -550,11 +507,9 @@
   FillPacket(1);
   VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
                                     packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -564,11 +519,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(2);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -578,11 +531,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(3);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -592,18 +543,15 @@
   packet_header_.header.sequenceNumber += 2;
   FillPacket(5);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   // One packet should be removed (end of partition 2), 3 left.
-  EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
-                                                 frame_buffer_size(),
-                                                 &fragmentation_),
-            3 * packet_buffer_size());
+  EXPECT_EQ(3 * packet_buffer_size(),
+            session_.BuildVP8FragmentationHeader(
+                frame_buffer_, frame_buffer_size(), &fragmentation_));
   SCOPED_TRACE("Calling VerifyPartition");
   EXPECT_TRUE(VerifyPartition(0, 2, 1));
   SCOPED_TRACE("Calling VerifyPartition");
@@ -621,11 +569,9 @@
   FillPacket(0);
   VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
                                     packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -635,11 +581,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(1);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -649,11 +593,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(2);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -663,18 +605,15 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(3);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   // No packet should be removed.
-  EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
-                                                 frame_buffer_size(),
-                                                 &fragmentation_),
-            4 * packet_buffer_size());
+  EXPECT_EQ(4 * packet_buffer_size(),
+            session_.BuildVP8FragmentationHeader(
+                frame_buffer_, frame_buffer_size(), &fragmentation_));
   SCOPED_TRACE("Calling VerifyPartition");
   EXPECT_TRUE(VerifyPartition(0, 2, 0));
   SCOPED_TRACE("Calling VerifyPartition");
@@ -692,11 +631,9 @@
   FillPacket(0);
   VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
                                     packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -706,11 +643,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(1);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -720,11 +655,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(2);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -734,18 +667,15 @@
   packet_header_.header.sequenceNumber += 2;
   FillPacket(3);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   // One packet should be removed from the last partition
-  EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
-                                                 frame_buffer_size(),
-                                                 &fragmentation_),
-            3 * packet_buffer_size());
+  EXPECT_EQ(3 * packet_buffer_size(),
+            session_.BuildVP8FragmentationHeader(
+                frame_buffer_, frame_buffer_size(), &fragmentation_));
   SCOPED_TRACE("Calling VerifyPartition");
   EXPECT_TRUE(VerifyPartition(0, 2, 0));
   SCOPED_TRACE("Calling VerifyPartition");
@@ -764,11 +694,9 @@
   FillPacket(1);
   VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
                                     packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -778,11 +706,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(2);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -792,11 +718,9 @@
   packet_header_.header.sequenceNumber += 3;
   FillPacket(5);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -806,18 +730,15 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(6);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   // No packet should be removed.
-  EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
-                                                 frame_buffer_size(),
-                                                 &fragmentation_),
-            4 * packet_buffer_size());
+  EXPECT_EQ(4 * packet_buffer_size(),
+            session_.BuildVP8FragmentationHeader(
+                frame_buffer_, frame_buffer_size(), &fragmentation_));
   SCOPED_TRACE("Calling VerifyPartition");
   EXPECT_TRUE(VerifyPartition(0, 2, 1));
   SCOPED_TRACE("Calling VerifyPartition");
@@ -835,11 +756,9 @@
   FillPacket(1);
   VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
                                     packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -850,11 +769,9 @@
   FillPacket(2);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
                          packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -864,11 +781,9 @@
   packet_header_.header.sequenceNumber += 2;
   FillPacket(4);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -878,11 +793,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(5);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -892,11 +805,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(6);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -906,18 +817,15 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(7);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   // 2 partitions left. 2 packets removed from second partition
-  EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
-                                                 frame_buffer_size(),
-                                                 &fragmentation_),
-            4 * packet_buffer_size());
+  EXPECT_EQ(4 * packet_buffer_size(),
+            session_.BuildVP8FragmentationHeader(
+                frame_buffer_, frame_buffer_size(), &fragmentation_));
   SCOPED_TRACE("Calling VerifyPartition");
   EXPECT_TRUE(VerifyPartition(0, 2, 1));
   SCOPED_TRACE("Calling VerifyPartition");
@@ -935,11 +843,9 @@
   FillPacket(0);
   VCMPacket* packet = new VCMPacket(packet_buffer_, packet_buffer_size(),
                                     packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -949,11 +855,9 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(1);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   packet_header_.type.Video.isFirstPacket = false;
@@ -963,18 +867,15 @@
   packet_header_.header.sequenceNumber += 1;
   FillPacket(2);
   packet = new VCMPacket(packet_buffer_, packet_buffer_size(), packet_header_);
-  EXPECT_EQ(session_.InsertPacket(*packet,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(*packet, frame_buffer_,
+                                                      kNoErrors, frame_data)));
   delete packet;
 
   // No packets removed.
-  EXPECT_EQ(session_.BuildVP8FragmentationHeader(frame_buffer_,
-                                                 frame_buffer_size(),
-                                                 &fragmentation_),
-            3 * packet_buffer_size());
+  EXPECT_EQ(3 * packet_buffer_size(),
+            session_.BuildVP8FragmentationHeader(
+                frame_buffer_, frame_buffer_size(), &fragmentation_));
   SCOPED_TRACE("Calling VerifyPartition");
   EXPECT_TRUE(VerifyPartition(0, 2, 0));
   // This partition is aggregated in partition 0
@@ -996,8 +897,8 @@
                                      kNoErrors,
                                      frame_data));
 
-  EXPECT_EQ(0, session_.MakeDecodable());
-  EXPECT_EQ(0, session_.SessionLength());
+  EXPECT_EQ(0U, session_.MakeDecodable());
+  EXPECT_EQ(0U, session_.SessionLength());
 }
 
 TEST_F(TestNalUnits, OneIsolatedNaluLoss) {
@@ -1006,24 +907,20 @@
   packet_.seqNum = 0;
   packet_.markerBit = false;
   FillPacket(0);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.isFirstPacket = false;
   packet_.completeNALU = kNaluComplete;
   packet_.seqNum += 2;
   packet_.markerBit = true;
   FillPacket(2);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
-  EXPECT_EQ(0, session_.MakeDecodable());
+  EXPECT_EQ(0U, session_.MakeDecodable());
   EXPECT_EQ(2 * packet_buffer_size(), session_.SessionLength());
   SCOPED_TRACE("Calling VerifyNalu");
   EXPECT_TRUE(VerifyNalu(0, 1, 0));
@@ -1037,22 +934,18 @@
   packet_.seqNum = 0;
   packet_.markerBit = false;
   FillPacket(0);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.isFirstPacket = false;
   packet_.completeNALU = kNaluEnd;
   packet_.seqNum += 2;
   packet_.markerBit = true;
   FillPacket(2);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable());
   EXPECT_EQ(packet_buffer_size(), session_.SessionLength());
@@ -1066,22 +959,18 @@
   packet_.seqNum = 0;
   packet_.markerBit = false;
   FillPacket(0);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.isFirstPacket = false;
   packet_.completeNALU = kNaluIncomplete;
   packet_.seqNum += 2;
   packet_.markerBit = false;
   FillPacket(1);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   EXPECT_EQ(packet_buffer_size(), session_.MakeDecodable());
   EXPECT_EQ(packet_buffer_size(), session_.SessionLength());
@@ -1096,35 +985,29 @@
   packet_.seqNum += 1;
   packet_.markerBit = false;
   FillPacket(1);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.isFirstPacket = true;
   packet_.completeNALU = kNaluComplete;
   packet_.seqNum -= 1;
   packet_.markerBit = false;
   FillPacket(0);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.isFirstPacket = false;
   packet_.completeNALU = kNaluEnd;
   packet_.seqNum += 2;
   packet_.markerBit = true;
   FillPacket(2);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
-  EXPECT_EQ(0, session_.MakeDecodable());
+  EXPECT_EQ(0U, session_.MakeDecodable());
   EXPECT_EQ(3 * packet_buffer_size(), session_.SessionLength());
   SCOPED_TRACE("Calling VerifyNalu");
   EXPECT_TRUE(VerifyNalu(0, 1, 0));
@@ -1136,25 +1019,21 @@
   packet_.completeNALU = kNaluIncomplete;
   packet_.markerBit = false;
   FillPacket(1);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.isFirstPacket = false;
   packet_.completeNALU = kNaluEnd;
   packet_.seqNum += 2;
   packet_.markerBit = true;
   FillPacket(2);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable());
-  EXPECT_EQ(0, session_.SessionLength());
+  EXPECT_EQ(0U, session_.SessionLength());
 }
 
 TEST_F(TestNalUnits, ReorderWrapLosses) {
@@ -1165,25 +1044,21 @@
   packet_.seqNum += 2;
   packet_.markerBit = true;
   FillPacket(2);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   packet_.seqNum -= 2;
   packet_.isFirstPacket = false;
   packet_.completeNALU = kNaluIncomplete;
   packet_.markerBit = false;
   FillPacket(1);
-  EXPECT_EQ(session_.InsertPacket(packet_,
-                                  frame_buffer_,
-                                  kNoErrors,
-                                  frame_data),
-            packet_buffer_size());
+  EXPECT_EQ(packet_buffer_size(),
+            static_cast<size_t>(session_.InsertPacket(packet_, frame_buffer_,
+                                                      kNoErrors, frame_data)));
 
   EXPECT_EQ(2 * packet_buffer_size(), session_.MakeDecodable());
-  EXPECT_EQ(0, session_.SessionLength());
+  EXPECT_EQ(0U, session_.SessionLength());
 }
 
 }  // namespace webrtc
diff --git a/webrtc/modules/video_coding/main/source/video_coding_impl.cc b/webrtc/modules/video_coding/main/source/video_coding_impl.cc
index d566731..2dfa99a 100644
--- a/webrtc/modules/video_coding/main/source/video_coding_impl.cc
+++ b/webrtc/modules/video_coding/main/source/video_coding_impl.cc
@@ -301,7 +301,7 @@
   }
 
   virtual int32_t IncomingPacket(const uint8_t* incomingPayload,
-                                 uint32_t payloadLength,
+                                 size_t payloadLength,
                                  const WebRtcRTPHeader& rtpInfo) OVERRIDE {
     return receiver_->IncomingPacket(incomingPayload, payloadLength, rtpInfo);
   }
diff --git a/webrtc/modules/video_coding/main/source/video_coding_impl.h b/webrtc/modules/video_coding/main/source/video_coding_impl.h
index ac7a1f4..90186c7 100644
--- a/webrtc/modules/video_coding/main/source/video_coding_impl.h
+++ b/webrtc/modules/video_coding/main/source/video_coding_impl.h
@@ -160,7 +160,7 @@
   VideoCodecType ReceiveCodec() const;
 
   int32_t IncomingPacket(const uint8_t* incomingPayload,
-                         uint32_t payloadLength,
+                         size_t payloadLength,
                          const WebRtcRTPHeader& rtpInfo);
   int32_t SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs);
   int32_t SetRenderDelay(uint32_t timeMS);
diff --git a/webrtc/modules/video_coding/main/source/video_receiver.cc b/webrtc/modules/video_coding/main/source/video_receiver.cc
index a8de28b..f58d64f 100644
--- a/webrtc/modules/video_coding/main/source/video_receiver.cc
+++ b/webrtc/modules/video_coding/main/source/video_receiver.cc
@@ -631,7 +631,7 @@
 
 // Incoming packet from network parsed and ready for decode, non blocking.
 int32_t VideoReceiver::IncomingPacket(const uint8_t* incomingPayload,
-                                      uint32_t payloadLength,
+                                      size_t payloadLength,
                                       const WebRtcRTPHeader& rtpInfo) {
   if (rtpInfo.frameType == kVideoFrameKey) {
     TRACE_EVENT1("webrtc",
diff --git a/webrtc/modules/video_coding/main/source/video_receiver_unittest.cc b/webrtc/modules/video_coding/main/source/video_receiver_unittest.cc
index 502dfa9..ec5ba93 100644
--- a/webrtc/modules/video_coding/main/source/video_receiver_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/video_receiver_unittest.cc
@@ -49,7 +49,6 @@
   }
 
   void InsertAndVerifyPaddingFrame(const uint8_t* payload,
-                                   int length,
                                    WebRtcRTPHeader* header) {
     ASSERT_TRUE(header != NULL);
     for (int j = 0; j < 5; ++j) {
@@ -63,7 +62,7 @@
   }
 
   void InsertAndVerifyDecodableFrame(const uint8_t* payload,
-                                     int length,
+                                     size_t length,
                                      WebRtcRTPHeader* header) {
     ASSERT_TRUE(header != NULL);
     EXPECT_EQ(0, receiver_->IncomingPacket(payload, length, *header));
@@ -87,7 +86,7 @@
   EXPECT_EQ(0, receiver_->SetVideoProtection(kProtectionNack, true));
   EXPECT_EQ(
       0, receiver_->RegisterPacketRequestCallback(&packet_request_callback_));
-  const unsigned int kPaddingSize = 220;
+  const size_t kPaddingSize = 220;
   const uint8_t payload[kPaddingSize] = {0};
   WebRtcRTPHeader header;
   memset(&header, 0, sizeof(header));
@@ -100,7 +99,7 @@
   header.type.Video.codec = kRtpVideoVp8;
   for (int i = 0; i < 10; ++i) {
     EXPECT_CALL(packet_request_callback_, ResendPackets(_, _)).Times(0);
-    InsertAndVerifyPaddingFrame(payload, 0, &header);
+    InsertAndVerifyPaddingFrame(payload, &header);
     clock_.AdvanceTimeMilliseconds(33);
     header.header.timestamp += 3000;
   }
@@ -110,8 +109,8 @@
   EXPECT_EQ(0, receiver_->SetVideoProtection(kProtectionNack, true));
   EXPECT_EQ(
       0, receiver_->RegisterPacketRequestCallback(&packet_request_callback_));
-  const unsigned int kFrameSize = 1200;
-  const unsigned int kPaddingSize = 220;
+  const size_t kFrameSize = 1200;
+  const size_t kPaddingSize = 220;
   const uint8_t payload[kFrameSize] = {0};
   WebRtcRTPHeader header;
   memset(&header, 0, sizeof(header));
@@ -150,7 +149,7 @@
       } else {
         EXPECT_CALL(packet_request_callback_, ResendPackets(_, _)).Times(0);
       }
-      InsertAndVerifyPaddingFrame(payload, 0, &header);
+      InsertAndVerifyPaddingFrame(payload, &header);
     }
     clock_.AdvanceTimeMilliseconds(33);
     header.header.timestamp += 3000;
@@ -161,8 +160,8 @@
   EXPECT_EQ(0, receiver_->SetVideoProtection(kProtectionNack, true));
   EXPECT_EQ(
       0, receiver_->RegisterPacketRequestCallback(&packet_request_callback_));
-  const unsigned int kFrameSize = 1200;
-  const unsigned int kPaddingSize = 220;
+  const size_t kFrameSize = 1200;
+  const size_t kPaddingSize = 220;
   const uint8_t payload[kFrameSize] = {0};
   WebRtcRTPHeader header;
   memset(&header, 0, sizeof(header));
@@ -195,7 +194,7 @@
     header.type.Video.isFirstPacket = false;
     header.header.markerBit = false;
     for (int j = 0; j < 2; ++j) {
-      // InsertAndVerifyPaddingFrame(payload, 0, &header);
+      // InsertAndVerifyPaddingFrame(payload, &header);
       clock_.AdvanceTimeMilliseconds(33);
       header.header.timestamp += 3000;
     }
diff --git a/webrtc/modules/video_coding/main/source/video_sender_unittest.cc b/webrtc/modules/video_coding/main/source/video_sender_unittest.cc
index 6bc8b80..f689809 100644
--- a/webrtc/modules/video_coding/main/source/video_sender_unittest.cc
+++ b/webrtc/modules/video_coding/main/source/video_sender_unittest.cc
@@ -91,7 +91,7 @@
                            uint32_t timestamp,
                            int64_t capture_time_ms,
                            const uint8_t* payload_data,
-                           uint32_t payload_size,
+                           size_t payload_size,
                            const RTPFragmentationHeader& fragmentation_header,
                            const RTPVideoHeader* rtp_video_header) OVERRIDE {
     assert(rtp_video_header);
@@ -127,10 +127,10 @@
   struct FrameData {
     FrameData() {}
 
-    FrameData(uint32_t payload_size, const RTPVideoHeader& rtp_video_header)
+    FrameData(size_t payload_size, const RTPVideoHeader& rtp_video_header)
         : payload_size(payload_size), rtp_video_header(rtp_video_header) {}
 
-    uint32_t payload_size;
+    size_t payload_size;
     RTPVideoHeader rtp_video_header;
   };
 
@@ -152,8 +152,8 @@
     return frames;
   }
 
-  int SumPayloadBytesWithinTemporalLayer(int temporal_layer) {
-    int payload_size = 0;
+  size_t SumPayloadBytesWithinTemporalLayer(int temporal_layer) {
+    size_t payload_size = 0;
     for (size_t i = 0; i < frame_data_.size(); ++i) {
       EXPECT_EQ(kRtpVideoVp8, frame_data_[i].rtp_video_header.codec);
       const uint8_t temporal_idx =
diff --git a/webrtc/modules/video_coding/main/test/generic_codec_test.cc b/webrtc/modules/video_coding/main/test/generic_codec_test.cc
index 7179c80..2848212 100644
--- a/webrtc/modules/video_coding/main/test/generic_codec_test.cc
+++ b/webrtc/modules/video_coding/main/test/generic_codec_test.cc
@@ -279,8 +279,9 @@
     const float nBitrates = sizeof(bitRate)/sizeof(*bitRate);
     float _bitRate = 0;
     int _frameCnt = 0;
-    float totalBytesOneSec = 0;//, totalBytesTenSec;
-    float totalBytes, actualBitrate;
+    size_t totalBytesOneSec = 0;//, totalBytesTenSec;
+    size_t totalBytes;
+    float actualBitrate;
     VCMFrameCount frameCount; // testing frame type counters
     // start test
     NumberOfCodecs = _vcm->NumberOfCodecs();
@@ -478,7 +479,7 @@
     }
 }
 
-float
+size_t
 GenericCodecTest::WaitForEncodedFrame() const
 {
     int64_t startTime = _clock->TimeInMilliseconds();
@@ -499,17 +500,17 @@
 }
 
 int
-RTPSendCallback_SizeTest::SendPacket(int channel, const void *data, int len)
+RTPSendCallback_SizeTest::SendPacket(int channel, const void *data, size_t len)
 {
     _nPackets++;
     _payloadSizeSum += len;
     // Make sure no payloads (len - header size) are larger than maxPayloadSize
-    TEST(len > 0 && static_cast<uint32_t>(len - 12) <= _maxPayloadSize);
+    TEST(len > 0 && len - 12 <= _maxPayloadSize);
     return 0;
 }
 
 void
-RTPSendCallback_SizeTest::SetMaxPayloadSize(uint32_t maxPayloadSize)
+RTPSendCallback_SizeTest::SetMaxPayloadSize(size_t maxPayloadSize)
 {
     _maxPayloadSize = maxPayloadSize;
 }
@@ -533,12 +534,12 @@
 
 int32_t
 VCMEncComplete_KeyReqTest::SendData(
-        const FrameType frameType,
-        const uint8_t payloadType,
-        const uint32_t timeStamp,
+        FrameType frameType,
+        uint8_t payloadType,
+        uint32_t timeStamp,
         int64_t capture_time_ms,
         const uint8_t* payloadData,
-        const uint32_t payloadSize,
+        size_t payloadSize,
         const RTPFragmentationHeader& /*fragmentationHeader*/,
         const webrtc::RTPVideoHeader* /*videoHdr*/)
 {
diff --git a/webrtc/modules/video_coding/main/test/generic_codec_test.h b/webrtc/modules/video_coding/main/test/generic_codec_test.h
index 841662a..9a450de 100644
--- a/webrtc/modules/video_coding/main/test/generic_codec_test.h
+++ b/webrtc/modules/video_coding/main/test/generic_codec_test.h
@@ -41,7 +41,7 @@
     ~GenericCodecTest();
     static int RunTest(CmdArgs& args);
     int32_t Perform(CmdArgs& args);
-    float WaitForEncodedFrame() const;
+    size_t WaitForEncodedFrame() const;
 
 private:
     void Setup(CmdArgs& args);
@@ -75,14 +75,18 @@
 public:
     // constructor input: (receive side) rtp module to send encoded data to
     RTPSendCallback_SizeTest() : _maxPayloadSize(0), _payloadSizeSum(0), _nPackets(0) {}
-    virtual int SendPacket(int channel, const void *data, int len) OVERRIDE;
-    virtual int SendRTCPPacket(int channel, const void *data, int len) OVERRIDE {return 0;}
-    void SetMaxPayloadSize(uint32_t maxPayloadSize);
+    virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE;
+    virtual int SendRTCPPacket(int channel,
+                               const void *data,
+                               size_t len) OVERRIDE {
+      return 0;
+    }
+    void SetMaxPayloadSize(size_t maxPayloadSize);
     void Reset();
     float AveragePayloadSize() const;
 private:
-    uint32_t         _maxPayloadSize;
-    uint32_t         _payloadSizeSum;
+    size_t           _maxPayloadSize;
+    size_t           _payloadSizeSum;
     uint32_t         _nPackets;
 };
 
@@ -91,12 +95,12 @@
 public:
     VCMEncComplete_KeyReqTest(webrtc::VideoCodingModule &vcm) : _vcm(vcm), _seqNo(0), _timeStamp(0) {}
     virtual int32_t SendData(
-        const webrtc::FrameType frameType,
-        const uint8_t payloadType,
+        webrtc::FrameType frameType,
+        uint8_t payloadType,
         uint32_t timeStamp,
         int64_t capture_time_ms,
         const uint8_t* payloadData,
-        const uint32_t payloadSize,
+        size_t payloadSize,
         const webrtc::RTPFragmentationHeader& fragmentationHeader,
         const webrtc::RTPVideoHeader* videoHdr) OVERRIDE;
 private:
diff --git a/webrtc/modules/video_coding/main/test/media_opt_test.cc b/webrtc/modules/video_coding/main/test/media_opt_test.cc
index a8b8f19..f3b1cf0 100644
--- a/webrtc/modules/video_coding/main/test/media_opt_test.cc
+++ b/webrtc/modules/video_coding/main/test/media_opt_test.cc
@@ -308,7 +308,7 @@
     _vcm->RegisterReceiveCallback(&receiveCallback);
 
     _frameCnt  = 0;
-    _sumEncBytes = 0.0;
+    _sumEncBytes = 0;
     _numFramesDropped = 0;
     int half_width = (_width + 1) / 2;
     int half_height = (_height + 1) / 2;
@@ -338,7 +338,7 @@
             printf ("Decode error in frame # %d",_frameCnt);
         }
 
-        float encBytes = encodeCompleteCallback->EncodedBytes();
+        size_t encBytes = encodeCompleteCallback->EncodedBytes();
         if (encBytes == 0)
         {
             _numFramesDropped += 1;
diff --git a/webrtc/modules/video_coding/main/test/media_opt_test.h b/webrtc/modules/video_coding/main/test/media_opt_test.h
index 5a95276..57398eb 100644
--- a/webrtc/modules/video_coding/main/test/media_opt_test.h
+++ b/webrtc/modules/video_coding/main/test/media_opt_test.h
@@ -80,7 +80,7 @@
     double                           _lossRate;
     uint32_t                   _renderDelayMs;
     int32_t                    _frameCnt;
-    float                            _sumEncBytes;
+    size_t                            _sumEncBytes;
     int32_t                    _numFramesDropped;
     std::string                      _codecName;
     webrtc::VideoCodecType           _sendCodecType;
diff --git a/webrtc/modules/video_coding/main/test/mt_test_common.cc b/webrtc/modules/video_coding/main/test/mt_test_common.cc
index 779ef7a..dec649f 100644
--- a/webrtc/modules/video_coding/main/test/mt_test_common.cc
+++ b/webrtc/modules/video_coding/main/test/mt_test_common.cc
@@ -30,7 +30,7 @@
 }
 
 int
-TransportCallback::SendPacket(int channel, const void *data, int len)
+TransportCallback::SendPacket(int channel, const void *data, size_t len)
 {
     _sendCount++;
     _totalSentLength += len;
diff --git a/webrtc/modules/video_coding/main/test/mt_test_common.h b/webrtc/modules/video_coding/main/test/mt_test_common.h
index be6d9ea..78d73e2 100644
--- a/webrtc/modules/video_coding/main/test/mt_test_common.h
+++ b/webrtc/modules/video_coding/main/test/mt_test_common.h
@@ -52,7 +52,7 @@
     // Add packets to list
     // Incorporate network conditions - delay and packet loss
     // Actual transmission will occur on a separate thread
-    virtual int SendPacket(int channel, const void *data, int len) OVERRIDE;
+    virtual int SendPacket(int channel, const void *data, size_t len) OVERRIDE;
     // Send to the receiver packets which are ready to be submitted
     int TransportPackets();
 };
diff --git a/webrtc/modules/video_coding/main/test/normal_test.cc b/webrtc/modules/video_coding/main/test/normal_test.cc
index 815c3ac..4ab97a1 100644
--- a/webrtc/modules/video_coding/main/test/normal_test.cc
+++ b/webrtc/modules/video_coding/main/test/normal_test.cc
@@ -71,12 +71,12 @@
 
 int32_t
 VCMNTEncodeCompleteCallback::SendData(
-        const FrameType frameType,
-        const uint8_t  payloadType,
-        const uint32_t timeStamp,
+        FrameType frameType,
+        uint8_t  payloadType,
+        uint32_t timeStamp,
         int64_t capture_time_ms,
         const uint8_t* payloadData,
-        const uint32_t payloadSize,
+        size_t payloadSize,
         const RTPFragmentationHeader& /*fragmentationHeader*/,
         const webrtc::RTPVideoHeader* videoHdr)
 
@@ -131,7 +131,7 @@
   _VCMReceiver = vcm;
   return;
 }
- int32_t
+ size_t
 VCMNTEncodeCompleteCallback::EncodedBytes()
 {
   return _encodedBytes;
@@ -144,13 +144,13 @@
 }
 
 // Decoded Frame Callback Implementation
-VCMNTDecodeCompleCallback::~VCMNTDecodeCompleCallback()
+VCMNTDecodeCompleteCallback::~VCMNTDecodeCompleteCallback()
 {
   if (_decodedFile)
   fclose(_decodedFile);
 }
  int32_t
-VCMNTDecodeCompleCallback::FrameToRender(webrtc::I420VideoFrame& videoFrame)
+VCMNTDecodeCompleteCallback::FrameToRender(webrtc::I420VideoFrame& videoFrame)
 {
     if (videoFrame.width() != _currentWidth ||
         videoFrame.height() != _currentHeight)
@@ -167,13 +167,13 @@
     if (PrintI420VideoFrame(videoFrame, _decodedFile) < 0) {
       return -1;
     }
-    _decodedBytes+= webrtc::CalcBufferSize(webrtc::kI420,
-                                   videoFrame.width(), videoFrame.height());
+    _decodedBytes += webrtc::CalcBufferSize(webrtc::kI420, videoFrame.width(),
+                                            videoFrame.height());
     return VCM_OK;
 }
 
- int32_t
-VCMNTDecodeCompleCallback::DecodedBytes()
+ size_t
+VCMNTDecodeCompleteCallback::DecodedBytes()
 {
   return _decodedBytes;
 }
@@ -260,7 +260,7 @@
   // register a decoder (same codec for decoder and encoder )
   TEST(_vcm->RegisterReceiveCodec(&_sendCodec, 1) == VCM_OK);
   /* Callback Settings */
-  VCMNTDecodeCompleCallback _decodeCallback(_outname);
+  VCMNTDecodeCompleteCallback _decodeCallback(_outname);
   _vcm->RegisterReceiveCallback(&_decodeCallback);
   VCMNTEncodeCompleteCallback _encodeCompleteCallback(_encodedFile, *this);
   _vcm->RegisterTransportCallback(&_encodeCompleteCallback);
diff --git a/webrtc/modules/video_coding/main/test/normal_test.h b/webrtc/modules/video_coding/main/test/normal_test.h
index 63e66b3..4d33f3c 100644
--- a/webrtc/modules/video_coding/main/test/normal_test.h
+++ b/webrtc/modules/video_coding/main/test/normal_test.h
@@ -33,12 +33,12 @@
   // process encoded data received from the encoder,
   // pass stream to the VCMReceiver module
   virtual int32_t SendData(
-      const webrtc::FrameType frameType,
-      const uint8_t payloadType,
-      const uint32_t timeStamp,
+      webrtc::FrameType frameType,
+      uint8_t payloadType,
+      uint32_t timeStamp,
       int64_t capture_time_ms,
       const uint8_t* payloadData,
-      const uint32_t payloadSize,
+      size_t payloadSize,
       const webrtc::RTPFragmentationHeader& fragmentationHeader,
       const webrtc::RTPVideoHeader* videoHdr) OVERRIDE;
 
@@ -46,15 +46,15 @@
   // Currently - encode and decode with the same vcm module.
   void RegisterReceiverVCM(webrtc::VideoCodingModule *vcm);
   // Return sum of encoded data (all frames in the sequence)
-  int32_t EncodedBytes();
+  size_t EncodedBytes();
   // return number of encoder-skipped frames
-  uint32_t SkipCnt();;
+  uint32_t SkipCnt();
   // conversion function for payload type (needed for the callback function)
 //    RTPVideoVideoCodecTypes ConvertPayloadType(uint8_t payloadType);
 
  private:
   FILE*                       _encodedFile;
-  uint32_t              _encodedBytes;
+  size_t                _encodedBytes;
   uint32_t              _skipCnt;
   webrtc::VideoCodingModule*  _VCMReceiver;
   webrtc::FrameType           _frameType;
@@ -62,29 +62,29 @@
   NormalTest&                 _test;
 }; // end of VCMEncodeCompleteCallback
 
-class VCMNTDecodeCompleCallback: public webrtc::VCMReceiveCallback
+class VCMNTDecodeCompleteCallback: public webrtc::VCMReceiveCallback
 {
 public:
-    VCMNTDecodeCompleCallback(std::string outname): // or should it get a name?
-        _decodedFile(NULL),
-        _outname(outname),
-        _decodedBytes(0),
-        _currentWidth(0),
-        _currentHeight(0) {}
-    virtual ~VCMNTDecodeCompleCallback();
+    VCMNTDecodeCompleteCallback(std::string outname) // or should it get a name?
+        : _decodedFile(NULL),
+          _outname(outname),
+          _decodedBytes(0),
+          _currentWidth(0),
+          _currentHeight(0) {}
+    virtual ~VCMNTDecodeCompleteCallback();
     void SetUserReceiveCallback(webrtc::VCMReceiveCallback* receiveCallback);
 
     // will write decoded frame into file
     virtual int32_t FrameToRender(webrtc::I420VideoFrame& videoFrame) OVERRIDE;
 
-    int32_t DecodedBytes();
+    size_t DecodedBytes();
 private:
     FILE*             _decodedFile;
     std::string       _outname;
-    int               _decodedBytes;
+    size_t            _decodedBytes;
     int               _currentWidth;
     int               _currentHeight;
-}; // end of VCMDecodeCompleCallback class
+}; // end of VCMNTDecodeCompleteCallback class
 
 class NormalTest
 {
@@ -119,7 +119,7 @@
     std::string                      _inname;
     std::string                      _outname;
     std::string                      _encodedName;
-    int32_t                    _sumEncBytes;
+    size_t                     _sumEncBytes;
     FILE*                            _sourceFile;
     FILE*                            _decodedFile;
     FILE*                            _encodedFile;
diff --git a/webrtc/modules/video_coding/main/test/quality_modes_test.cc b/webrtc/modules/video_coding/main/test/quality_modes_test.cc
index d488fa9..2993e53 100644
--- a/webrtc/modules/video_coding/main/test/quality_modes_test.cc
+++ b/webrtc/modules/video_coding/main/test/quality_modes_test.cc
@@ -212,7 +212,7 @@
   // register a decoder (same codec for decoder and encoder )
   TEST(_vcm->RegisterReceiveCodec(&codec, 2) == VCM_OK);
   /* Callback Settings */
-  VCMQMDecodeCompleCallback  _decodeCallback(
+  VCMQMDecodeCompleteCallback  _decodeCallback(
       _decodedFile, _nativeFrameRate, feature_table_name_);
   _vcm->RegisterReceiveCallback(&_decodeCallback);
   VCMNTEncodeCompleteCallback   _encodeCompleteCallback(_encodedFile, *this);
@@ -449,7 +449,7 @@
 }
 
 // Decoded Frame Callback Implementation
-VCMQMDecodeCompleCallback::VCMQMDecodeCompleCallback(
+VCMQMDecodeCompleteCallback::VCMQMDecodeCompleteCallback(
     FILE* decodedFile, int frame_rate, std::string feature_table_name):
 _decodedFile(decodedFile),
 _decodedBytes(0),
@@ -468,7 +468,7 @@
     //
 }
 
-VCMQMDecodeCompleCallback::~VCMQMDecodeCompleCallback()
+VCMQMDecodeCompleteCallback::~VCMQMDecodeCompleteCallback()
  {
 //     if (_interpolator != NULL)
 //     {
@@ -483,7 +483,7 @@
  }
 
 int32_t
-VCMQMDecodeCompleCallback::FrameToRender(I420VideoFrame& videoFrame)
+VCMQMDecodeCompleteCallback::FrameToRender(I420VideoFrame& videoFrame)
 {
   ++frames_cnt_since_drop_;
 
@@ -537,19 +537,19 @@
   return VCM_OK;
 }
 
-int32_t VCMQMDecodeCompleCallback::DecodedBytes()
+size_t VCMQMDecodeCompleteCallback::DecodedBytes()
 {
   return _decodedBytes;
 }
 
-void VCMQMDecodeCompleCallback::SetOriginalFrameDimensions(int32_t width,
-                                                           int32_t height)
+void VCMQMDecodeCompleteCallback::SetOriginalFrameDimensions(int32_t width,
+                                                             int32_t height)
 {
   _origWidth = width;
   _origHeight = height;
 }
 
-int32_t VCMQMDecodeCompleCallback::buildInterpolator()
+int32_t VCMQMDecodeCompleteCallback::buildInterpolator()
 {
   uint32_t decFrameLength  = _origWidth*_origHeight*3 >> 1;
   if (_decBuffer != NULL)
@@ -569,7 +569,7 @@
 // frame (or several consecutive frames from the end) must have been dropped. If
 // this is the case, the last frame is repeated so that there are as many
 // frames rendered as there are number of frames encoded.
-void VCMQMDecodeCompleCallback::WriteEnd(int input_frame_count)
+void VCMQMDecodeCompleteCallback::WriteEnd(int input_frame_count)
 {
   int num_missing_frames = input_frame_count - _frameCnt;
 
diff --git a/webrtc/modules/video_coding/main/test/quality_modes_test.h b/webrtc/modules/video_coding/main/test/quality_modes_test.h
index 38da78d..26c8229 100644
--- a/webrtc/modules/video_coding/main/test/quality_modes_test.h
+++ b/webrtc/modules/video_coding/main/test/quality_modes_test.h
@@ -51,18 +51,18 @@
 
 }; // end of QualityModesTest class
 
-class VCMQMDecodeCompleCallback: public webrtc::VCMReceiveCallback
+class VCMQMDecodeCompleteCallback: public webrtc::VCMReceiveCallback
 {
 public:
-    VCMQMDecodeCompleCallback(
+    VCMQMDecodeCompleteCallback(
         FILE* decodedFile,
         int frame_rate,
         std::string feature_table_name);
-    virtual ~VCMQMDecodeCompleCallback();
+    virtual ~VCMQMDecodeCompleteCallback();
     void SetUserReceiveCallback(webrtc::VCMReceiveCallback* receiveCallback);
     // will write decoded frame into file
     int32_t FrameToRender(webrtc::I420VideoFrame& videoFrame);
-    int32_t DecodedBytes();
+    size_t DecodedBytes();
     void SetOriginalFrameDimensions(int32_t width, int32_t height);
     int32_t buildInterpolator();
     // Check if last frame is dropped, if so, repeat the last rendered frame.
@@ -70,7 +70,7 @@
 
 private:
     FILE*                _decodedFile;
-    uint32_t       _decodedBytes;
+    size_t               _decodedBytes;
    // QualityModesTest&  _test;
     int                  _origWidth;
     int                  _origHeight;
@@ -86,7 +86,7 @@
 
 
 
-}; // end of VCMQMDecodeCompleCallback class
+}; // end of VCMQMDecodeCompleteCallback class
 
 class QMTestVideoSettingsCallback : public webrtc::VCMQMSettingsCallback
 {
diff --git a/webrtc/modules/video_coding/main/test/receiver_tests.h b/webrtc/modules/video_coding/main/test/receiver_tests.h
index 91b7f8e..de1eb63 100644
--- a/webrtc/modules/video_coding/main/test/receiver_tests.h
+++ b/webrtc/modules/video_coding/main/test/receiver_tests.h
@@ -29,7 +29,7 @@
 
   virtual int32_t OnReceivedPayloadData(
       const uint8_t* payload_data,
-      const uint16_t payload_size,
+      const size_t payload_size,
       const webrtc::WebRtcRTPHeader* rtp_header) OVERRIDE {
     return vcm_->IncomingPacket(payload_data, payload_size, *rtp_header);
   }
diff --git a/webrtc/modules/video_coding/main/test/rtp_player.cc b/webrtc/modules/video_coding/main/test/rtp_player.cc
index 1aea7e0..81295ab 100644
--- a/webrtc/modules/video_coding/main/test/rtp_player.cc
+++ b/webrtc/modules/video_coding/main/test/rtp_player.cc
@@ -41,7 +41,7 @@
 
 class RawRtpPacket {
  public:
-  RawRtpPacket(const uint8_t* data, uint32_t length, uint32_t ssrc,
+  RawRtpPacket(const uint8_t* data, size_t length, uint32_t ssrc,
                uint16_t seq_num)
       : data_(new uint8_t[length]),
         length_(length),
@@ -53,7 +53,7 @@
   }
 
   const uint8_t* data() const { return data_.get(); }
-  uint32_t length() const { return length_; }
+  size_t length() const { return length_; }
   int64_t resend_time_ms() const { return resend_time_ms_; }
   void set_resend_time_ms(int64_t timeMs) { resend_time_ms_ = timeMs; }
   uint32_t ssrc() const { return ssrc_; }
@@ -61,7 +61,7 @@
 
  private:
   scoped_ptr<uint8_t[]> data_;
-  uint32_t length_;
+  size_t length_;
   int64_t resend_time_ms_;
   uint32_t ssrc_;
   uint16_t seq_num_;
@@ -251,7 +251,7 @@
     return 0;
   }
 
-  void IncomingPacket(const uint8_t* data, uint32_t length) {
+  void IncomingPacket(const uint8_t* data, size_t length) {
     for (HandlerMapIt it = handlers_.begin(); it != handlers_.end(); ++it) {
       if (!it->second->rtp_header_parser_->IsRtcp(data, length)) {
         RTPHeader header;
@@ -375,14 +375,10 @@
 
       if (reordering_ && reorder_buffer_.get() == NULL) {
         reorder_buffer_.reset(
-            new RawRtpPacket(next_packet_.data,
-                             static_cast<uint32_t>(next_packet_.length),
-                             0,
-                             0));
+            new RawRtpPacket(next_packet_.data, next_packet_.length, 0, 0));
         return 0;
       }
-      int ret = SendPacket(next_packet_.data,
-                           static_cast<uint32_t>(next_packet_.length));
+      int ret = SendPacket(next_packet_.data, next_packet_.length);
       if (reorder_buffer_.get()) {
         SendPacket(reorder_buffer_->data(), reorder_buffer_->length());
         reorder_buffer_.reset(NULL);
@@ -421,7 +417,7 @@
   }
 
  private:
-  int SendPacket(const uint8_t* data, uint32_t length) {
+  int SendPacket(const uint8_t* data, size_t length) {
     assert(data);
     assert(length > 0);
 
diff --git a/webrtc/modules/video_coding/main/test/test_callbacks.cc b/webrtc/modules/video_coding/main/test/test_callbacks.cc
index d68f994..35aaae1 100644
--- a/webrtc/modules/video_coding/main/test/test_callbacks.cc
+++ b/webrtc/modules/video_coding/main/test/test_callbacks.cc
@@ -57,7 +57,7 @@