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/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,