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

Side by Side Diff: webrtc/modules/video_coding/frame_buffer2.cc

Issue 2848283002: Check if the order of frames becomes ambiguous if we were to insert the incoming frame, and if so, … (Closed)
Patch Set: Created 3 years, 7 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 frame_it = last_decoded_frame_it_; 83 frame_it = last_decoded_frame_it_;
84 ++frame_it; 84 ++frame_it;
85 } 85 }
86 86
87 // |continuous_end_it| points to the first frame after the 87 // |continuous_end_it| points to the first frame after the
88 // |last_continuous_frame_it_|. 88 // |last_continuous_frame_it_|.
89 auto continuous_end_it = last_continuous_frame_it_; 89 auto continuous_end_it = last_continuous_frame_it_;
90 if (continuous_end_it != frames_.end()) 90 if (continuous_end_it != frames_.end())
91 ++continuous_end_it; 91 ++continuous_end_it;
92 92
93 for (; frame_it != continuous_end_it; ++frame_it) { 93 for (; frame_it != continuous_end_it && frame_it != frames_.end();
94 ++frame_it) {
94 if (!frame_it->second.continuous || 95 if (!frame_it->second.continuous ||
95 frame_it->second.num_missing_decodable > 0) { 96 frame_it->second.num_missing_decodable > 0) {
96 continue; 97 continue;
97 } 98 }
98 99
99 FrameObject* frame = frame_it->second.frame.get(); 100 FrameObject* frame = frame_it->second.frame.get();
100 next_frame_it_ = frame_it; 101 next_frame_it_ = frame_it;
101 if (frame->RenderTime() == -1) 102 if (frame->RenderTime() == -1)
102 frame->SetRenderTime(timing_->RenderTimeMs(frame->timestamp, now_ms)); 103 frame->SetRenderTime(timing_->RenderTimeMs(frame->timestamp, now_ms));
103 wait_ms = timing_->MaxWaitingTime(frame->RenderTime(), now_ms); 104 wait_ms = timing_->MaxWaitingTime(frame->RenderTime(), now_ms);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 << static_cast<int>(key.spatial_layer) 216 << static_cast<int>(key.spatial_layer)
216 << ") inserted after frame (" 217 << ") inserted after frame ("
217 << last_decoded_frame_it_->first.picture_id << ":" 218 << last_decoded_frame_it_->first.picture_id << ":"
218 << static_cast<int>( 219 << static_cast<int>(
219 last_decoded_frame_it_->first.spatial_layer) 220 last_decoded_frame_it_->first.spatial_layer)
220 << ") was handed off for decoding, dropping frame."; 221 << ") was handed off for decoding, dropping frame.";
221 return last_continuous_picture_id; 222 return last_continuous_picture_id;
222 } 223 }
223 } 224 }
224 225
226 // Test if inserting this frame would cause the order of the frames to become
227 // ambiguous (covering more than half the interval of 2^16). This can happen
228 // when the picture id make large jumps mid stream.
229 if (!frames_.empty() &&
230 key < frames_.begin()->first &&
231 frames_.rbegin()->first < key) {
232 LOG(LS_WARNING) << "A jump in picture id was detected, clearing buffer.";
233 ClearFramesAndHistory();
234 last_continuous_picture_id = -1;
235 }
236
225 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first; 237 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first;
226 238
227 if (info->second.frame) { 239 if (info->second.frame) {
228 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id 240 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id
229 << ":" << static_cast<int>(key.spatial_layer) 241 << ":" << static_cast<int>(key.spatial_layer)
230 << ") already inserted, dropping frame."; 242 << ") already inserted, dropping frame.";
231 return last_continuous_picture_id; 243 return last_continuous_picture_id;
232 } 244 }
233 245
234 if (!UpdateFrameInfoWithIncomingFrame(*frame, info)) 246 if (!UpdateFrameInfoWithIncomingFrame(*frame, info))
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 frames_.clear(); 423 frames_.clear();
412 last_decoded_frame_it_ = frames_.end(); 424 last_decoded_frame_it_ = frames_.end();
413 last_continuous_frame_it_ = frames_.end(); 425 last_continuous_frame_it_ = frames_.end();
414 next_frame_it_ = frames_.end(); 426 next_frame_it_ = frames_.end();
415 num_frames_history_ = 0; 427 num_frames_history_ = 0;
416 num_frames_buffered_ = 0; 428 num_frames_buffered_ = 0;
417 } 429 }
418 430
419 } // namespace video_coding 431 } // namespace video_coding
420 } // namespace webrtc 432 } // 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