Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Unified Diff: webrtc/modules/video_coding/packet_buffer.cc

Issue 2990183002: Revert of Fix off-by-one bugs in video_coding::PacketBuffer when the buffer is filled with a single frame. (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/packet_buffer.cc
diff --git a/webrtc/modules/video_coding/packet_buffer.cc b/webrtc/modules/video_coding/packet_buffer.cc
index 715a173e9c3b926952df55559f1094be68fd58c4..8b6de047ca5bb6aa3e7f542dacdd8f48cf6c5559 100644
--- a/webrtc/modules/video_coding/packet_buffer.cc
+++ b/webrtc/modules/video_coding/packet_buffer.cc
@@ -251,14 +251,14 @@
// Find the start index by searching backward until the packet with
// the |frame_begin| flag is set.
int start_index = index;
- size_t tested_packets = 0;
bool is_h264 = data_buffer_[start_index].codec == kVideoCodecH264;
bool is_h264_keyframe = false;
int64_t frame_timestamp = data_buffer_[start_index].timestamp;
- while (true) {
- ++tested_packets;
+ // Since packet at |data_buffer_[index]| is already part of the frame
+ // we will have at most |size_ - 1| packets left to check.
+ for (size_t j = 0; j < size_ - 1; ++j) {
frame_size += data_buffer_[start_index].sizeBytes;
max_nack_count =
std::max(max_nack_count, data_buffer_[start_index].timesNacked);
@@ -277,9 +277,6 @@
}
}
}
-
- if (tested_packets == size_)
- break;
start_index = start_index > 0 ? start_index - 1 : size_ - 1;
@@ -348,30 +345,19 @@
size_t index = frame.first_seq_num() % size_;
size_t end = (frame.last_seq_num() + 1) % size_;
uint16_t seq_num = frame.first_seq_num();
- uint8_t* destination_end = destination + frame.size();
-
- do {
+ while (index != end) {
if (!sequence_buffer_[index].used ||
sequence_buffer_[index].seq_num != seq_num) {
return false;
}
- RTC_DCHECK_EQ(data_buffer_[index].seqNum, sequence_buffer_[index].seq_num);
+ const uint8_t* source = data_buffer_[index].dataPtr;
size_t length = data_buffer_[index].sizeBytes;
- if (destination + length > destination_end) {
- LOG(LS_WARNING) << "Frame (" << frame.picture_id << ":"
- << static_cast<int>(frame.spatial_layer) << ")"
- << " bitstream buffer is not large enough.";
- return false;
- }
-
- const uint8_t* source = data_buffer_[index].dataPtr;
memcpy(destination, source, length);
destination += length;
index = (index + 1) % size_;
++seq_num;
- } while (index != end);
-
+ }
return true;
}
« no previous file with comments | « webrtc/modules/video_coding/frame_object.cc ('k') | webrtc/modules/video_coding/video_packet_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698