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

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

Issue 2036913003: Use picture id to check continuity between frames. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: No default argument for ManageFrameGeneric. Created 4 years, 6 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 | « webrtc/modules/video_coding/rtp_frame_reference_finder.h ('k') | no next file » | 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 28 matching lines...) Expand all
39 break; 39 break;
40 case kVideoCodecVP8: 40 case kVideoCodecVP8:
41 ManageFrameVp8(std::move(frame)); 41 ManageFrameVp8(std::move(frame));
42 break; 42 break;
43 case kVideoCodecVP9: 43 case kVideoCodecVP9:
44 ManageFrameVp9(std::move(frame)); 44 ManageFrameVp9(std::move(frame));
45 break; 45 break;
46 case kVideoCodecH264: 46 case kVideoCodecH264:
47 case kVideoCodecI420: 47 case kVideoCodecI420:
48 case kVideoCodecGeneric: 48 case kVideoCodecGeneric:
49 ManageFrameGeneric(std::move(frame)); 49 ManageFrameGeneric(std::move(frame), kNoPictureId);
50 break; 50 break;
51 } 51 }
52 } 52 }
53 53
54 void RtpFrameReferenceFinder::RetryStashedFrames() { 54 void RtpFrameReferenceFinder::RetryStashedFrames() {
55 size_t num_stashed_frames = stashed_frames_.size(); 55 size_t num_stashed_frames = stashed_frames_.size();
56 56
57 // Clean up stashed frames if there are too many. 57 // Clean up stashed frames if there are too many.
58 while (stashed_frames_.size() > kMaxStashedFrames) 58 while (stashed_frames_.size() > kMaxStashedFrames)
59 stashed_frames_.pop(); 59 stashed_frames_.pop();
60 60
61 // Since frames are stashed if there is not enough data to determine their 61 // Since frames are stashed if there is not enough data to determine their
62 // frame references we should at most check |stashed_frames_.size()| in 62 // frame references we should at most check |stashed_frames_.size()| in
63 // order to not pop and push frames in and endless loop. 63 // order to not pop and push frames in and endless loop.
64 for (size_t i = 0; i < num_stashed_frames && !stashed_frames_.empty(); ++i) { 64 for (size_t i = 0; i < num_stashed_frames && !stashed_frames_.empty(); ++i) {
65 std::unique_ptr<RtpFrameObject> frame = std::move(stashed_frames_.front()); 65 std::unique_ptr<RtpFrameObject> frame = std::move(stashed_frames_.front());
66 stashed_frames_.pop(); 66 stashed_frames_.pop();
67 ManageFrame(std::move(frame)); 67 ManageFrame(std::move(frame));
68 } 68 }
69 } 69 }
70 70
71 void RtpFrameReferenceFinder::ManageFrameGeneric( 71 void RtpFrameReferenceFinder::ManageFrameGeneric(
72 std::unique_ptr<RtpFrameObject> frame) { 72 std::unique_ptr<RtpFrameObject> frame,
73 int picture_id) {
74 // If |picture_id| is specified then we use that to set the frame references,
75 // otherwise we use sequence number.
76 if (picture_id != kNoPictureId) {
77 if (last_unwrap_ == -1)
78 last_unwrap_ = picture_id;
79
80 frame->picture_id = UnwrapPictureId(picture_id % kPicIdLength);
81 frame->num_references = frame->frame_type() == kVideoFrameKey ? 0 : 1;
82 frame->references[0] = frame->picture_id - 1;
83 frame_callback_->OnCompleteFrame(std::move(frame));
84 return;
85 }
86
73 if (frame->frame_type() == kVideoFrameKey) 87 if (frame->frame_type() == kVideoFrameKey)
74 last_seq_num_gop_[frame->last_seq_num()] = frame->last_seq_num(); 88 last_seq_num_gop_[frame->last_seq_num()] = frame->last_seq_num();
75 89
76 // We have received a frame but not yet a keyframe, stash this frame. 90 // We have received a frame but not yet a keyframe, stash this frame.
77 if (last_seq_num_gop_.empty()) { 91 if (last_seq_num_gop_.empty()) {
78 stashed_frames_.emplace(std::move(frame)); 92 stashed_frames_.emplace(std::move(frame));
79 return; 93 return;
80 } 94 }
81 95
82 // Clean up info for old keyframes but make sure to keep info 96 // Clean up info for old keyframes but make sure to keep info
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 std::unique_ptr<RtpFrameObject> frame) { 132 std::unique_ptr<RtpFrameObject> frame) {
119 RTPVideoTypeHeader* rtp_codec_header = frame->GetCodecHeader(); 133 RTPVideoTypeHeader* rtp_codec_header = frame->GetCodecHeader();
120 if (!rtp_codec_header) 134 if (!rtp_codec_header)
121 return; 135 return;
122 136
123 const RTPVideoHeaderVP8& codec_header = rtp_codec_header->VP8; 137 const RTPVideoHeaderVP8& codec_header = rtp_codec_header->VP8;
124 138
125 if (codec_header.pictureId == kNoPictureId || 139 if (codec_header.pictureId == kNoPictureId ||
126 codec_header.temporalIdx == kNoTemporalIdx || 140 codec_header.temporalIdx == kNoTemporalIdx ||
127 codec_header.tl0PicIdx == kNoTl0PicIdx) { 141 codec_header.tl0PicIdx == kNoTl0PicIdx) {
128 ManageFrameGeneric(std::move(frame)); 142 ManageFrameGeneric(std::move(frame), codec_header.pictureId);
129 return; 143 return;
130 } 144 }
131 145
132 frame->picture_id = codec_header.pictureId % kPicIdLength; 146 frame->picture_id = codec_header.pictureId % kPicIdLength;
133 147
134 if (last_unwrap_ == -1) 148 if (last_unwrap_ == -1)
135 last_unwrap_ = codec_header.pictureId; 149 last_unwrap_ = codec_header.pictureId;
136 150
137 if (last_picture_id_ == -1) 151 if (last_picture_id_ == -1)
138 last_picture_id_ = frame->picture_id; 152 last_picture_id_ = frame->picture_id;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 273 }
260 274
261 void RtpFrameReferenceFinder::ManageFrameVp9( 275 void RtpFrameReferenceFinder::ManageFrameVp9(
262 std::unique_ptr<RtpFrameObject> frame) { 276 std::unique_ptr<RtpFrameObject> frame) {
263 RTPVideoTypeHeader* rtp_codec_header = frame->GetCodecHeader(); 277 RTPVideoTypeHeader* rtp_codec_header = frame->GetCodecHeader();
264 if (!rtp_codec_header) 278 if (!rtp_codec_header)
265 return; 279 return;
266 280
267 const RTPVideoHeaderVP9& codec_header = rtp_codec_header->VP9; 281 const RTPVideoHeaderVP9& codec_header = rtp_codec_header->VP9;
268 282
269 if (codec_header.picture_id == kNoPictureId) { 283 if (codec_header.picture_id == kNoPictureId ||
270 ManageFrameGeneric(std::move(frame)); 284 codec_header.temporal_idx == kNoTemporalIdx) {
285 ManageFrameGeneric(std::move(frame), codec_header.picture_id);
271 return; 286 return;
272 } 287 }
273 288
274 frame->spatial_layer = codec_header.spatial_idx; 289 frame->spatial_layer = codec_header.spatial_idx;
275 frame->inter_layer_predicted = codec_header.inter_layer_predicted; 290 frame->inter_layer_predicted = codec_header.inter_layer_predicted;
276 frame->picture_id = codec_header.picture_id % kPicIdLength; 291 frame->picture_id = codec_header.picture_id % kPicIdLength;
277 292
278 if (last_unwrap_ == -1) 293 if (last_unwrap_ == -1)
279 last_unwrap_ = codec_header.picture_id; 294 last_unwrap_ = codec_header.picture_id;
280 295
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (AheadOf<uint16_t, kPicIdLength>(picture_id, unwrap_truncated)) 492 if (AheadOf<uint16_t, kPicIdLength>(picture_id, unwrap_truncated))
478 last_unwrap_ = Add<1 << 16>(last_unwrap_, diff); 493 last_unwrap_ = Add<1 << 16>(last_unwrap_, diff);
479 else 494 else
480 last_unwrap_ = Subtract<1 << 16>(last_unwrap_, diff); 495 last_unwrap_ = Subtract<1 << 16>(last_unwrap_, diff);
481 496
482 return last_unwrap_; 497 return last_unwrap_;
483 } 498 }
484 499
485 } // namespace video_coding 500 } // namespace video_coding
486 } // namespace webrtc 501 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/rtp_frame_reference_finder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698