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/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) {