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

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

Issue 2951033003: [EXPERIMENTAL] Generic stereo codec with index header sending single frames
Patch Set: Rebase and add external codec support. Created 3 years, 2 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
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 FrameBuffer::ReturnReason FrameBuffer::NextFrame( 60 FrameBuffer::ReturnReason FrameBuffer::NextFrame(
61 int64_t max_wait_time_ms, 61 int64_t max_wait_time_ms,
62 std::unique_ptr<FrameObject>* frame_out, 62 std::unique_ptr<FrameObject>* frame_out,
63 bool keyframe_required) { 63 bool keyframe_required) {
64 TRACE_EVENT0("webrtc", "FrameBuffer::NextFrame"); 64 TRACE_EVENT0("webrtc", "FrameBuffer::NextFrame");
65 int64_t latest_return_time_ms = 65 int64_t latest_return_time_ms =
66 clock_->TimeInMilliseconds() + max_wait_time_ms; 66 clock_->TimeInMilliseconds() + max_wait_time_ms;
67 int64_t wait_ms = max_wait_time_ms; 67 int64_t wait_ms = max_wait_time_ms;
68 int64_t now_ms = 0; 68 int64_t now_ms = 0;
69
70 do { 69 do {
71 now_ms = clock_->TimeInMilliseconds(); 70 now_ms = clock_->TimeInMilliseconds();
72 { 71 {
73 rtc::CritScope lock(&crit_); 72 rtc::CritScope lock(&crit_);
74 new_continuous_frame_event_.Reset(); 73 new_continuous_frame_event_.Reset();
75 if (stopped_) 74 if (stopped_) {
76 return kStopped; 75 return kStopped;
76 }
77 77
78 wait_ms = max_wait_time_ms; 78 wait_ms = max_wait_time_ms;
79 79
80 // Need to hold |crit_| in order to use |frames_|, therefore we 80 // Need to hold |crit_| in order to use |frames_|, therefore we
81 // set it here in the loop instead of outside the loop in order to not 81 // set it here in the loop instead of outside the loop in order to not
82 // acquire the lock unnecesserily. 82 // acquire the lock unnecesserily.
83 next_frame_it_ = frames_.end(); 83 next_frame_it_ = frames_.end();
84 84
85 // |frame_it| points to the first frame after the 85 // |frame_it| points to the first frame after the
86 // |last_decoded_frame_it_|. 86 // |last_decoded_frame_it_|.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Sanity check for RTP timestamp monotonicity. 165 // Sanity check for RTP timestamp monotonicity.
166 if (last_decoded_frame_it_ != frames_.end()) { 166 if (last_decoded_frame_it_ != frames_.end()) {
167 const FrameKey& last_decoded_frame_key = last_decoded_frame_it_->first; 167 const FrameKey& last_decoded_frame_key = last_decoded_frame_it_->first;
168 const FrameKey& frame_key = next_frame_it_->first; 168 const FrameKey& frame_key = next_frame_it_->first;
169 169
170 const bool frame_is_higher_spatial_layer_of_last_decoded_frame = 170 const bool frame_is_higher_spatial_layer_of_last_decoded_frame =
171 last_decoded_frame_timestamp_ == frame->timestamp && 171 last_decoded_frame_timestamp_ == frame->timestamp &&
172 last_decoded_frame_key.picture_id == frame_key.picture_id && 172 last_decoded_frame_key.picture_id == frame_key.picture_id &&
173 last_decoded_frame_key.spatial_layer < frame_key.spatial_layer; 173 last_decoded_frame_key.spatial_layer < frame_key.spatial_layer;
174 174
175 if (AheadOrAt(last_decoded_frame_timestamp_, frame->timestamp) && 175 if (AheadOf(last_decoded_frame_timestamp_, frame->timestamp) &&
176 !frame_is_higher_spatial_layer_of_last_decoded_frame) { 176 !frame_is_higher_spatial_layer_of_last_decoded_frame) {
177 // TODO(brandtr): Consider clearing the entire buffer when we hit 177 // TODO(brandtr): Consider clearing the entire buffer when we hit
178 // these conditions. 178 // these conditions.
179 LOG(LS_WARNING) << "Frame with (timestamp:picture_id:spatial_id) (" 179 LOG(LS_WARNING) << "Frame with (timestamp:picture_id:spatial_id) ("
180 << frame->timestamp << ":" << frame->picture_id << ":" 180 << frame->timestamp << ":" << frame->picture_id << ":"
181 << static_cast<int>(frame->spatial_layer) << ")" 181 << static_cast<int>(frame->spatial_layer) << ")"
182 << " sent to decoder after frame with" 182 << " sent to decoder after frame with"
183 << " (timestamp:picture_id:spatial_id) (" 183 << " (timestamp:picture_id:spatial_id) ("
184 << last_decoded_frame_timestamp_ << ":" 184 << last_decoded_frame_timestamp_ << ":"
185 << last_decoded_frame_key.picture_id << ":" 185 << last_decoded_frame_key.picture_id << ":"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // Test if inserting this frame would cause the order of the frames to become 342 // Test if inserting this frame would cause the order of the frames to become
343 // ambiguous (covering more than half the interval of 2^16). This can happen 343 // ambiguous (covering more than half the interval of 2^16). This can happen
344 // when the picture id make large jumps mid stream. 344 // when the picture id make large jumps mid stream.
345 if (!frames_.empty() && 345 if (!frames_.empty() &&
346 key < frames_.begin()->first && 346 key < frames_.begin()->first &&
347 frames_.rbegin()->first < key) { 347 frames_.rbegin()->first < key) {
348 LOG(LS_WARNING) << "A jump in picture id was detected, clearing buffer."; 348 LOG(LS_WARNING) << "A jump in picture id was detected, clearing buffer.";
349 ClearFramesAndHistory(); 349 ClearFramesAndHistory();
350 last_continuous_picture_id = -1; 350 last_continuous_picture_id = -1;
351 } 351 }
352
353 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first; 352 auto info = frames_.insert(std::make_pair(key, FrameInfo())).first;
354 353
355 if (info->second.frame) { 354 if (info->second.frame) {
356 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id 355 LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) (" << key.picture_id
357 << ":" << static_cast<int>(key.spatial_layer) 356 << ":" << static_cast<int>(key.spatial_layer)
358 << ") already inserted, dropping frame."; 357 << ") already inserted, dropping frame.";
359 return last_continuous_picture_id; 358 return last_continuous_picture_id;
360 } 359 }
361 360
362 if (!UpdateFrameInfoWithIncomingFrame(*frame, info)) 361 if (!UpdateFrameInfoWithIncomingFrame(*frame, info))
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 414 }
416 415
417 void FrameBuffer::PropagateDecodability(const FrameInfo& info) { 416 void FrameBuffer::PropagateDecodability(const FrameInfo& info) {
418 TRACE_EVENT0("webrtc", "FrameBuffer::PropagateDecodability"); 417 TRACE_EVENT0("webrtc", "FrameBuffer::PropagateDecodability");
419 RTC_CHECK(info.num_dependent_frames < FrameInfo::kMaxNumDependentFrames); 418 RTC_CHECK(info.num_dependent_frames < FrameInfo::kMaxNumDependentFrames);
420 for (size_t d = 0; d < info.num_dependent_frames; ++d) { 419 for (size_t d = 0; d < info.num_dependent_frames; ++d) {
421 auto ref_info = frames_.find(info.dependent_frames[d]); 420 auto ref_info = frames_.find(info.dependent_frames[d]);
422 RTC_DCHECK(ref_info != frames_.end()); 421 RTC_DCHECK(ref_info != frames_.end());
423 // TODO(philipel): Look into why we've seen this happen. 422 // TODO(philipel): Look into why we've seen this happen.
424 if (ref_info != frames_.end()) { 423 if (ref_info != frames_.end()) {
425 RTC_DCHECK_GT(ref_info->second.num_missing_decodable, 0U); 424 // RTC_DCHECK_GT(ref_info->second.num_missing_decodable, 0U);
426 --ref_info->second.num_missing_decodable; 425 --ref_info->second.num_missing_decodable;
427 } 426 }
428 } 427 }
429 } 428 }
430 429
431 void FrameBuffer::AdvanceLastDecodedFrame(FrameMap::iterator decoded) { 430 void FrameBuffer::AdvanceLastDecodedFrame(FrameMap::iterator decoded) {
432 TRACE_EVENT0("webrtc", "FrameBuffer::AdvanceLastDecodedFrame"); 431 TRACE_EVENT0("webrtc", "FrameBuffer::AdvanceLastDecodedFrame");
433 if (last_decoded_frame_it_ == frames_.end()) { 432 if (last_decoded_frame_it_ == frames_.end()) {
434 last_decoded_frame_it_ = frames_.begin(); 433 last_decoded_frame_it_ = frames_.begin();
435 } else { 434 } else {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 frames_.clear(); 570 frames_.clear();
572 last_decoded_frame_it_ = frames_.end(); 571 last_decoded_frame_it_ = frames_.end();
573 last_continuous_frame_it_ = frames_.end(); 572 last_continuous_frame_it_ = frames_.end();
574 next_frame_it_ = frames_.end(); 573 next_frame_it_ = frames_.end();
575 num_frames_history_ = 0; 574 num_frames_history_ = 0;
576 num_frames_buffered_ = 0; 575 num_frames_buffered_ = 0;
577 } 576 }
578 577
579 } // namespace video_coding 578 } // namespace video_coding
580 } // namespace webrtc 579 } // namespace webrtc
OLDNEW
« no previous file with comments | « modules/video_coding/encoded_frame.cc ('k') | modules/video_coding/include/video_codec_initializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698