From f68426954154918ec5bf7e6b3096fa3d7acb0944 Mon Sep 17 00:00:00 2001 From: philipel Date: Fri, 28 Apr 2017 03:29:15 -0700 Subject: [PATCH] Reject re-inserting already decoded frames into FrameBuffer2. BUG=webrtc:7518 Review-Url: https://codereview.webrtc.org/2842133002 Cr-Commit-Position: refs/heads/master@{#17925} --- webrtc/modules/video_coding/frame_buffer2.cc | 2 +- webrtc/modules/video_coding/frame_buffer2_unittest.cc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/webrtc/modules/video_coding/frame_buffer2.cc b/webrtc/modules/video_coding/frame_buffer2.cc index 280dc5a0b0..4dcea53f6a 100644 --- a/webrtc/modules/video_coding/frame_buffer2.cc +++ b/webrtc/modules/video_coding/frame_buffer2.cc @@ -237,7 +237,7 @@ int FrameBuffer::InsertFrame(std::unique_ptr frame) { } if (last_decoded_frame_it_ != frames_.end() && - key < last_decoded_frame_it_->first) { + key <= last_decoded_frame_it_->first) { if (AheadOf(frame->timestamp, last_decoded_frame_timestamp_) && frame->num_references == 0) { // If this frame has a newer timestamp but an earlier picture id then we diff --git a/webrtc/modules/video_coding/frame_buffer2_unittest.cc b/webrtc/modules/video_coding/frame_buffer2_unittest.cc index 04ce5595a5..4f1c6369dc 100644 --- a/webrtc/modules/video_coding/frame_buffer2_unittest.cc +++ b/webrtc/modules/video_coding/frame_buffer2_unittest.cc @@ -516,5 +516,11 @@ TEST_F(TestFrameBuffer2, ForwardJumps) { ExtractFrame(); } +TEST_F(TestFrameBuffer2, DuplicateFrames) { + EXPECT_EQ(22256, InsertFrame(22256, 0, 1, false)); + ExtractFrame(); + EXPECT_EQ(22256, InsertFrame(22256, 0, 1, false)); +} + } // namespace video_coding } // namespace webrtc