Skip to content

Commit

Permalink
Handle empty GOF.
Browse files Browse the repository at this point in the history
Assume that stream has single temporal layer if number of frames in GOF
is set to zero (valid case).

(cherry picked from commit 2f864fb)

[email protected]

Bug: chromium:879584
Change-Id: I7ced082190e40c1bf4cc1468babfd98b0a61f0dd
Reviewed-on: https://webrtc-review.googlesource.com/98800
Reviewed-by: Philip Eliasson <[email protected]>
Commit-Queue: Sergey Silkin <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#24622}
Reviewed-on: https://webrtc-review.googlesource.com/98861
Reviewed-by: Sergey Silkin <[email protected]>
Cr-Commit-Position: refs/branch-heads/70@{open-webrtc-toolkit#4}
Cr-Branched-From: f18b352-refs/heads/master@{#24472}
  • Loading branch information
Sergey Silkin committed Sep 11, 2018
1 parent 22e555c commit 80dd170
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modules/video_coding/rtp_frame_reference_finder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,19 @@ RtpFrameReferenceFinder::FrameDecision RtpFrameReferenceFinder::ManageFrameVp9(
RTC_LOG(LS_WARNING) << "Received scalability structure on a non base "
"layer frame. Scalability structure ignored.";
} else {
current_ss_idx_ = Add<kMaxGofSaved>(current_ss_idx_, 1);
if (codec_header.gof.num_frames_in_gof == 0 ||
codec_header.gof.num_frames_in_gof > kMaxVp9FramesInGof) {
if (codec_header.gof.num_frames_in_gof > kMaxVp9FramesInGof) {
return kDrop;
}

scalability_structures_[current_ss_idx_] = codec_header.gof;
GofInfoVP9 gof = codec_header.gof;
if (gof.num_frames_in_gof == 0) {
RTC_LOG(LS_WARNING) << "Number of frames in GOF is zero. Assume "
"that stream has only one temporal layer.";
gof.SetGofInfoVP9(kTemporalStructureMode1);
}

current_ss_idx_ = Add<kMaxGofSaved>(current_ss_idx_, 1);
scalability_structures_[current_ss_idx_] = gof;
scalability_structures_[current_ss_idx_].pid_start = frame->id.picture_id;
gof_info_.emplace(unwrapped_tl0,
GofInfo(&scalability_structures_[current_ss_idx_],
Expand Down
14 changes: 14 additions & 0 deletions modules/video_coding/rtp_frame_reference_finder_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1360,5 +1360,19 @@ TEST_F(TestRtpFrameReferenceFinder, Vp9GofTidTooHigh) {
CheckReferencesVp9(0, 0);
}

TEST_F(TestRtpFrameReferenceFinder, Vp9GofZeroFrames) {
uint16_t pid = Rand();
uint16_t sn = Rand();
GofInfoVP9 ss;
ss.num_frames_in_gof = 0;

InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss);
InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 0, 1);

ASSERT_EQ(2UL, frames_from_callback_.size());
CheckReferencesVp9(0, 0);
CheckReferencesVp9(1, 0, 0);
}

} // namespace video_coding
} // namespace webrtc

0 comments on commit 80dd170

Please sign in to comment.