From 545c53e22f9d75465f34e8b5f7e1ad40bded91ce Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Fri, 31 Jan 2020 18:08:54 +0100 Subject: [PATCH] In RtpFrameReferenceFinder VP8 clean not yet received before filling it To make it generally faster, specially in case of very large picture id gaps. Bug: None Change-Id: Ib0c49c17bd1281190da986def43bea8fc3440c0f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168055 Commit-Queue: Danil Chapovalov Reviewed-by: Philip Eliasson Cr-Commit-Position: refs/heads/master@{#30438} --- .../video_coding/rtp_frame_reference_finder.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/video_coding/rtp_frame_reference_finder.cc b/modules/video_coding/rtp_frame_reference_finder.cc index 3767161e36..013b6e3e31 100644 --- a/modules/video_coding/rtp_frame_reference_finder.cc +++ b/modules/video_coding/rtp_frame_reference_finder.cc @@ -291,6 +291,16 @@ RtpFrameReferenceFinder::FrameDecision RtpFrameReferenceFinder::ManageFrameVp8( if (last_picture_id_ == -1) last_picture_id_ = frame->id.picture_id; + // Clean up info about not yet received frames that are too old. + uint16_t old_picture_id = + Subtract(frame->id.picture_id, kMaxNotYetReceivedFrames); + auto clean_frames_to = not_yet_received_frames_.lower_bound(old_picture_id); + not_yet_received_frames_.erase(not_yet_received_frames_.begin(), + clean_frames_to); + // Avoid re-adding picture ids that were just erased. + if (AheadOf(old_picture_id, last_picture_id_)) { + last_picture_id_ = old_picture_id; + } // Find if there has been a gap in fully received frames and save the picture // id of those frames in |not_yet_received_frames_|. if (AheadOf(frame->id.picture_id, last_picture_id_)) { @@ -307,13 +317,6 @@ RtpFrameReferenceFinder::FrameDecision RtpFrameReferenceFinder::ManageFrameVp8( auto clean_layer_info_to = layer_info_.lower_bound(old_tl0_pic_idx); layer_info_.erase(layer_info_.begin(), clean_layer_info_to); - // Clean up info about not yet received frames that are too old. - uint16_t old_picture_id = - Subtract(frame->id.picture_id, kMaxNotYetReceivedFrames); - auto clean_frames_to = not_yet_received_frames_.lower_bound(old_picture_id); - not_yet_received_frames_.erase(not_yet_received_frames_.begin(), - clean_frames_to); - if (frame->frame_type() == VideoFrameType::kVideoFrameKey) { if (codec_header.temporalIdx != 0) { return kDrop;