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

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

Issue 2830723002: Check if the order of frames becomes ambiguous by inserting a new frame, and if so, clear the Frame… (Closed)
Patch Set: Additional saftey check. Created 3 years, 8 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
« no previous file with comments | « no previous file | webrtc/modules/video_coding/frame_buffer2_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/frame_buffer2.cc
diff --git a/webrtc/modules/video_coding/frame_buffer2.cc b/webrtc/modules/video_coding/frame_buffer2.cc
index fcd523820f0ef7825b7edaacb63b7e33460e8d2c..acc1bb83c5a0e448e030d42b98eab5d25315b0a1 100644
--- a/webrtc/modules/video_coding/frame_buffer2.cc
+++ b/webrtc/modules/video_coding/frame_buffer2.cc
@@ -93,7 +93,8 @@ FrameBuffer::ReturnReason FrameBuffer::NextFrame(
if (continuous_end_it != frames_.end())
++continuous_end_it;
- for (; frame_it != continuous_end_it; ++frame_it) {
+ for (; frame_it != continuous_end_it && frame_it != frames_.end();
+ ++frame_it) {
if (!frame_it->second.continuous ||
frame_it->second.num_missing_decodable > 0) {
continue;
@@ -233,6 +234,17 @@ int FrameBuffer::InsertFrame(std::unique_ptr<FrameObject> frame) {
}
}
+ // Test if inserting this frame would cause the order of the frames to become
+ // ambiguous (covering more than half the interval of 2^16). This can happen
+ // when the picture id make large jumps mid stream.
+ if (!frames_.empty() &&
+ key < frames_.begin()->first &&
+ frames_.rbegin()->first < key) {
+ LOG(LS_WARNING) << "A jump in picture id was detected, clearing buffer.";
+ ClearFramesAndHistory();
+ last_continuous_picture_id = -1;
+ }
+
auto info = frames_.insert(std::make_pair(key, FrameInfo())).first;
if (info->second.frame) {
« no previous file with comments | « no previous file | webrtc/modules/video_coding/frame_buffer2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698