OLD | NEW |
---|---|
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 != -1) { | |
pbos-webrtc
2016/06/03 13:26:55
Can't this check kNoPictureId?
philipel
2016/06/03 14:17:14
Done.
| |
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 Loading... | |
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 if (codec_header.pictureId != kNoPictureId) |
143 ManageFrameGeneric(std::move(frame), codec_header.pictureId); | |
144 else | |
145 ManageFrameGeneric(std::move(frame)); | |
129 return; | 146 return; |
130 } | 147 } |
131 | 148 |
132 frame->picture_id = codec_header.pictureId % kPicIdLength; | 149 frame->picture_id = codec_header.pictureId % kPicIdLength; |
133 | 150 |
134 if (last_unwrap_ == -1) | 151 if (last_unwrap_ == -1) |
135 last_unwrap_ = codec_header.pictureId; | 152 last_unwrap_ = codec_header.pictureId; |
136 | 153 |
137 if (last_picture_id_ == -1) | 154 if (last_picture_id_ == -1) |
138 last_picture_id_ = frame->picture_id; | 155 last_picture_id_ = frame->picture_id; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 } | 276 } |
260 | 277 |
261 void RtpFrameReferenceFinder::ManageFrameVp9( | 278 void RtpFrameReferenceFinder::ManageFrameVp9( |
262 std::unique_ptr<RtpFrameObject> frame) { | 279 std::unique_ptr<RtpFrameObject> frame) { |
263 RTPVideoTypeHeader* rtp_codec_header = frame->GetCodecHeader(); | 280 RTPVideoTypeHeader* rtp_codec_header = frame->GetCodecHeader(); |
264 if (!rtp_codec_header) | 281 if (!rtp_codec_header) |
265 return; | 282 return; |
266 | 283 |
267 const RTPVideoHeaderVP9& codec_header = rtp_codec_header->VP9; | 284 const RTPVideoHeaderVP9& codec_header = rtp_codec_header->VP9; |
268 | 285 |
269 if (codec_header.picture_id == kNoPictureId) { | 286 if (codec_header.picture_id == kNoPictureId || |
270 ManageFrameGeneric(std::move(frame)); | 287 codec_header.temporal_idx == kNoTemporalIdx) { |
288 if (codec_header.picture_id != kNoPictureId) | |
289 ManageFrameGeneric(std::move(frame), codec_header.picture_id); | |
290 else | |
291 ManageFrameGeneric(std::move(frame)); | |
271 return; | 292 return; |
272 } | 293 } |
273 | 294 |
274 frame->spatial_layer = codec_header.spatial_idx; | 295 frame->spatial_layer = codec_header.spatial_idx; |
275 frame->inter_layer_predicted = codec_header.inter_layer_predicted; | 296 frame->inter_layer_predicted = codec_header.inter_layer_predicted; |
276 frame->picture_id = codec_header.picture_id % kPicIdLength; | 297 frame->picture_id = codec_header.picture_id % kPicIdLength; |
277 | 298 |
278 if (last_unwrap_ == -1) | 299 if (last_unwrap_ == -1) |
279 last_unwrap_ = codec_header.picture_id; | 300 last_unwrap_ = codec_header.picture_id; |
280 | 301 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 if (AheadOf<uint16_t, kPicIdLength>(picture_id, unwrap_truncated)) | 498 if (AheadOf<uint16_t, kPicIdLength>(picture_id, unwrap_truncated)) |
478 last_unwrap_ = Add<1 << 16>(last_unwrap_, diff); | 499 last_unwrap_ = Add<1 << 16>(last_unwrap_, diff); |
479 else | 500 else |
480 last_unwrap_ = Subtract<1 << 16>(last_unwrap_, diff); | 501 last_unwrap_ = Subtract<1 << 16>(last_unwrap_, diff); |
481 | 502 |
482 return last_unwrap_; | 503 return last_unwrap_; |
483 } | 504 } |
484 | 505 |
485 } // namespace video_coding | 506 } // namespace video_coding |
486 } // namespace webrtc | 507 } // namespace webrtc |
OLD | NEW |