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

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

Issue 3009833002: Avoid calling RtpFrameObject::GetCodecHeader twice in the RtpFrameReferenceFinder. (Closed)
Patch Set: Created 3 years, 3 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // Clean up info about not yet received frames that are too old. 278 // Clean up info about not yet received frames that are too old.
279 uint16_t old_picture_id = 279 uint16_t old_picture_id =
280 Subtract<kPicIdLength>(frame->picture_id, kMaxNotYetReceivedFrames); 280 Subtract<kPicIdLength>(frame->picture_id, kMaxNotYetReceivedFrames);
281 auto clean_frames_to = not_yet_received_frames_.lower_bound(old_picture_id); 281 auto clean_frames_to = not_yet_received_frames_.lower_bound(old_picture_id);
282 not_yet_received_frames_.erase(not_yet_received_frames_.begin(), 282 not_yet_received_frames_.erase(not_yet_received_frames_.begin(),
283 clean_frames_to); 283 clean_frames_to);
284 284
285 if (frame->frame_type() == kVideoFrameKey) { 285 if (frame->frame_type() == kVideoFrameKey) {
286 frame->num_references = 0; 286 frame->num_references = 0;
287 layer_info_[codec_header.tl0PicIdx].fill(-1); 287 layer_info_[codec_header.tl0PicIdx].fill(-1);
288 UpdateLayerInfoVp8(frame); 288 UpdateLayerInfoVp8(frame, codec_header);
289 return kHandOff; 289 return kHandOff;
290 } 290 }
291 291
292 auto layer_info_it = layer_info_.find(codec_header.temporalIdx == 0 292 auto layer_info_it = layer_info_.find(codec_header.temporalIdx == 0
293 ? codec_header.tl0PicIdx - 1 293 ? codec_header.tl0PicIdx - 1
294 : codec_header.tl0PicIdx); 294 : codec_header.tl0PicIdx);
295 295
296 // If we don't have the base layer frame yet, stash this frame. 296 // If we don't have the base layer frame yet, stash this frame.
297 if (layer_info_it == layer_info_.end()) 297 if (layer_info_it == layer_info_.end())
298 return kStash; 298 return kStash;
299 299
300 // A non keyframe base layer frame has been received, copy the layer info 300 // A non keyframe base layer frame has been received, copy the layer info
301 // from the previous base layer frame and set a reference to the previous 301 // from the previous base layer frame and set a reference to the previous
302 // base layer frame. 302 // base layer frame.
303 if (codec_header.temporalIdx == 0) { 303 if (codec_header.temporalIdx == 0) {
304 layer_info_it = 304 layer_info_it =
305 layer_info_ 305 layer_info_
306 .insert(make_pair(codec_header.tl0PicIdx, layer_info_it->second)) 306 .insert(make_pair(codec_header.tl0PicIdx, layer_info_it->second))
307 .first; 307 .first;
308 frame->num_references = 1; 308 frame->num_references = 1;
309 frame->references[0] = layer_info_it->second[0]; 309 frame->references[0] = layer_info_it->second[0];
310 UpdateLayerInfoVp8(frame); 310 UpdateLayerInfoVp8(frame, codec_header);
311 return kHandOff; 311 return kHandOff;
312 } 312 }
313 313
314 // Layer sync frame, this frame only references its base layer frame. 314 // Layer sync frame, this frame only references its base layer frame.
315 if (codec_header.layerSync) { 315 if (codec_header.layerSync) {
316 frame->num_references = 1; 316 frame->num_references = 1;
317 frame->references[0] = layer_info_it->second[0]; 317 frame->references[0] = layer_info_it->second[0];
318 318
319 UpdateLayerInfoVp8(frame); 319 UpdateLayerInfoVp8(frame, codec_header);
320 return kHandOff; 320 return kHandOff;
321 } 321 }
322 322
323 // Find all references for this frame. 323 // Find all references for this frame.
324 frame->num_references = 0; 324 frame->num_references = 0;
325 for (uint8_t layer = 0; layer <= codec_header.temporalIdx; ++layer) { 325 for (uint8_t layer = 0; layer <= codec_header.temporalIdx; ++layer) {
326 // If we have not yet received a previous frame on this temporal layer, 326 // If we have not yet received a previous frame on this temporal layer,
327 // stash this frame. 327 // stash this frame.
328 if (layer_info_it->second[layer] == -1) 328 if (layer_info_it->second[layer] == -1)
329 return kStash; 329 return kStash;
(...skipping 22 matching lines...) Expand all
352 << " and packet range [" << frame->first_seq_num() << ", " 352 << " and packet range [" << frame->first_seq_num() << ", "
353 << frame->last_seq_num() << "] already received, " 353 << frame->last_seq_num() << "] already received, "
354 << " dropping frame."; 354 << " dropping frame.";
355 return kDrop; 355 return kDrop;
356 } 356 }
357 357
358 ++frame->num_references; 358 ++frame->num_references;
359 frame->references[layer] = layer_info_it->second[layer]; 359 frame->references[layer] = layer_info_it->second[layer];
360 } 360 }
361 361
362 UpdateLayerInfoVp8(frame); 362 UpdateLayerInfoVp8(frame, codec_header);
363 return kHandOff; 363 return kHandOff;
364 } 364 }
365 365
366 void RtpFrameReferenceFinder::UpdateLayerInfoVp8(RtpFrameObject* frame) { 366 void RtpFrameReferenceFinder::UpdateLayerInfoVp8(
367 rtc::Optional<RTPVideoTypeHeader> rtp_codec_header = frame->GetCodecHeader(); 367 RtpFrameObject* frame,
368 RTC_DCHECK(rtp_codec_header); 368 const RTPVideoHeaderVP8& codec_header) {
369 const RTPVideoHeaderVP8& codec_header = rtp_codec_header->VP8;
370
371 uint8_t tl0_pic_idx = codec_header.tl0PicIdx; 369 uint8_t tl0_pic_idx = codec_header.tl0PicIdx;
372 uint8_t temporal_index = codec_header.temporalIdx; 370 uint8_t temporal_index = codec_header.temporalIdx;
373 auto layer_info_it = layer_info_.find(tl0_pic_idx); 371 auto layer_info_it = layer_info_.find(tl0_pic_idx);
374 372
375 // Update this layer info and newer. 373 // Update this layer info and newer.
376 while (layer_info_it != layer_info_.end()) { 374 while (layer_info_it != layer_info_.end()) {
377 if (layer_info_it->second[temporal_index] != -1 && 375 if (layer_info_it->second[temporal_index] != -1 &&
378 AheadOf<uint16_t, kPicIdLength>(layer_info_it->second[temporal_index], 376 AheadOf<uint16_t, kPicIdLength>(layer_info_it->second[temporal_index],
379 frame->picture_id)) { 377 frame->picture_id)) {
380 // The frame was not newer, then no subsequent layer info have to be 378 // The frame was not newer, then no subsequent layer info have to be
381 // update. 379 // update.
382 break; 380 break;
383 } 381 }
384 382
385 layer_info_it->second[codec_header.temporalIdx] = frame->picture_id; 383 layer_info_it->second[codec_header.temporalIdx] = frame->picture_id;
386 ++tl0_pic_idx; 384 ++tl0_pic_idx;
387 layer_info_it = layer_info_.find(tl0_pic_idx); 385 layer_info_it = layer_info_.find(tl0_pic_idx);
388 } 386 }
389 not_yet_received_frames_.erase(frame->picture_id); 387 not_yet_received_frames_.erase(frame->picture_id);
390 388
391 UnwrapPictureIds(frame); 389 UnwrapPictureIds(frame);
392 } 390 }
393 391
394 RtpFrameReferenceFinder::FrameDecision RtpFrameReferenceFinder::ManageFrameVp9( 392 RtpFrameReferenceFinder::FrameDecision RtpFrameReferenceFinder::ManageFrameVp9(
395 RtpFrameObject* frame) { 393 RtpFrameObject* frame) {
396 rtc::Optional<RTPVideoTypeHeader> rtp_codec_header = frame->GetCodecHeader(); 394 rtc::Optional<RTPVideoTypeHeader> rtp_codec_header = frame->GetCodecHeader();
397 RTC_DCHECK(rtp_codec_header); 395 if (!rtp_codec_header)
philipel 2017/08/30 08:54:37 I thought I had made this change at some earlier p
396 return kDrop;
397
398 const RTPVideoHeaderVP9& codec_header = rtp_codec_header->VP9; 398 const RTPVideoHeaderVP9& codec_header = rtp_codec_header->VP9;
399 399
400 if (codec_header.picture_id == kNoPictureId || 400 if (codec_header.picture_id == kNoPictureId ||
401 codec_header.temporal_idx == kNoTemporalIdx) { 401 codec_header.temporal_idx == kNoTemporalIdx) {
402 return ManageFrameGeneric(std::move(frame), codec_header.picture_id); 402 return ManageFrameGeneric(std::move(frame), codec_header.picture_id);
403 } 403 }
404 404
405 frame->spatial_layer = codec_header.spatial_idx; 405 frame->spatial_layer = codec_header.spatial_idx;
406 frame->inter_layer_predicted = codec_header.inter_layer_predicted; 406 frame->inter_layer_predicted = codec_header.inter_layer_predicted;
407 frame->picture_id = codec_header.picture_id % kPicIdLength; 407 frame->picture_id = codec_header.picture_id % kPicIdLength;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 if (AheadOf<uint16_t, kPicIdLength>(picture_id, unwrap_truncated)) 598 if (AheadOf<uint16_t, kPicIdLength>(picture_id, unwrap_truncated))
599 last_unwrap_ = Add<1 << 16>(last_unwrap_, diff); 599 last_unwrap_ = Add<1 << 16>(last_unwrap_, diff);
600 else 600 else
601 last_unwrap_ = Subtract<1 << 16>(last_unwrap_, diff); 601 last_unwrap_ = Subtract<1 << 16>(last_unwrap_, diff);
602 602
603 return last_unwrap_; 603 return last_unwrap_;
604 } 604 }
605 605
606 } // namespace video_coding 606 } // namespace video_coding
607 } // namespace webrtc 607 } // 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