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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/video_coding/frame_buffer2_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 frame_it = last_decoded_frame_it_; 86 frame_it = last_decoded_frame_it_;
87 ++frame_it; 87 ++frame_it;
88 } 88 }
89 89
90 // |continuous_end_it| points to the first frame after the 90 // |continuous_end_it| points to the first frame after the
91 // |last_continuous_frame_it_|. 91 // |last_continuous_frame_it_|.
92 auto continuous_end_it = last_continuous_frame_it_; 92 auto continuous_end_it = last_continuous_frame_it_;
93 if (continuous_end_it != frames_.end()) 93 if (continuous_end_it != frames_.end())
94 ++continuous_end_it; 94 ++continuous_end_it;
95 95
96 for (; frame_it != continuous_end_it; ++frame_it) { 96 for (; frame_it != continuous_end_it && frame_it != frames_.end();
97 ++frame_it) {
97 if (!frame_it->second.continuous || 98 if (!frame_it->second.continuous ||
98 frame_it->second.num_missing_decodable > 0) { 99 frame_it->second.num_missing_decodable > 0) {
99 continue; 100 continue;
100 } 101 }
101 102
102 FrameObject* frame = frame_it->second.frame.get(); 103 FrameObject* frame = frame_it->second.frame.get();
103 next_frame_it_ = frame_it; 104 next_frame_it_ = frame_it;
104 if (frame->RenderTime() == -1) 105 if (frame->RenderTime() == -1)
105 frame->SetRenderTime(timing_->RenderTimeMs(frame->timestamp, now_ms)); 106 frame->SetRenderTime(timing_->RenderTimeMs(frame->timestamp, now_ms));
106 wait_ms = timing_->MaxWaitingTime(frame->RenderTime(), now_ms); 107 wait_ms = timing_->MaxWaitingTime(frame->RenderTime(), now_ms);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 << static_cast<int>(key.spatial_layer) 227 << static_cast<int>(key.spatial_layer)
227 << ") inserted after frame (" 228 << ") inserted after frame ("
228 << last_decoded_frame_it_->first.picture_id << ":" 229 << last_decoded_frame_it_->first.picture_id << ":"
229 << static_cast<int>( 230 << static_cast<int>(
230 last_decoded_frame_it_->first.spatial_layer) 231 last_decoded_frame_it_->first.spatial_layer)
231 << ") was handed off for decoding, dropping frame."; 232 << ") was handed off for decoding, dropping frame.";
232 return last_continuous_picture_id; 233 return last_continuous_picture_id;
233 } 234 }
234 } 235 }
235 236
237 // Test if inserting this frame would cause the order of the frames to become
238 // ambiguous (covering more than half the interval of 2^16). This can happen
239 // when the picture id make large jumps mid stream.
240 if (!frames_.empty() &&
241 key < frames_.begin()->first &&
242 frames_.rbegin()->first < key) {
243 LOG(LS_WARNING) << "A jump in picture id was detected, clearing buffer.";
244 ClearFramesAndHistory();
245 last_continuous_picture_id = -1;
246 }
247
236 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first; 248 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first;
237 249
238 if (info->second.frame) { 250 if (info->second.frame) {
239 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id 251 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id
240 << ":" << static_cast<int>(key.spatial_layer) 252 << ":" << static_cast<int>(key.spatial_layer)
241 << ") already inserted, dropping frame."; 253 << ") already inserted, dropping frame.";
242 return last_continuous_picture_id; 254 return last_continuous_picture_id;
243 } 255 }
244 256
245 if (!UpdateFrameInfoWithIncomingFrame(*frame, info)) 257 if (!UpdateFrameInfoWithIncomingFrame(*frame, info))
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 frames_.clear(); 440 frames_.clear();
429 last_decoded_frame_it_ = frames_.end(); 441 last_decoded_frame_it_ = frames_.end();
430 last_continuous_frame_it_ = frames_.end(); 442 last_continuous_frame_it_ = frames_.end();
431 next_frame_it_ = frames_.end(); 443 next_frame_it_ = frames_.end();
432 num_frames_history_ = 0; 444 num_frames_history_ = 0;
433 num_frames_buffered_ = 0; 445 num_frames_buffered_ = 0;
434 } 446 }
435 447
436 } // namespace video_coding 448 } // namespace video_coding
437 } // namespace webrtc 449 } // namespace webrtc
OLDNEW
« 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