Skip to content

Commit

Permalink
MSE: Reduce spurious discontinuities caused by partial append window …
Browse files Browse the repository at this point in the history
…start overlaps

If a frame overlaps appendWindowStart, partial append window filtering
is supported for the track, and the frame is appended to the track
buffer, this change updates the track buffer's last frame duration with
the frame's original duration instead of the possibly trimmed duration.
If the trimmed duration were used, then the discontinuity detection
logic could detect a discontinuity on the next frame for the track where
there would otherwise not be a discontinuity.

BUG=381114
R=acolwell@chromium.org
TEST=FrameProcessorTest.PartialAppendWindowFilterNoDiscontinuity

Review URL: https://codereview.chromium.org/344513002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277976 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
wolenetz@chromium.org committed Jun 18, 2014
1 parent e7e0234 commit 04e3518
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
8 changes: 5 additions & 3 deletions media/filters/frame_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,15 @@ bool FrameProcessor::ProcessFrame(
if (frame->timestamp() != presentation_timestamp && !sequence_mode_)
*new_media_segment = true;

// |frame| has been partially trimmed or had preroll added.
// |frame| has been partially trimmed or had preroll added. Though
// |frame|'s duration may have changed, do not update |frame_duration|
// here, so |track_buffer|'s last frame duration update uses original
// frame duration and reduces spurious discontinuity detection.
decode_timestamp = frame->GetDecodeTimestamp();
presentation_timestamp = frame->timestamp();
frame_duration = frame->duration();

// The end timestamp of the frame should be unchanged.
DCHECK(frame_end_timestamp == presentation_timestamp + frame_duration);
DCHECK(frame_end_timestamp == presentation_timestamp + frame->duration());
}

if (presentation_timestamp < append_window_start ||
Expand Down
19 changes: 19 additions & 0 deletions media/filters/frame_processor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,25 @@ TEST_P(FrameProcessorTest, AllowNegativeFramePTSAndDTSBeforeOffsetAdjustment) {
}
}

TEST_P(FrameProcessorTest, PartialAppendWindowFilterNoDiscontinuity) {
// Tests that spurious discontinuity is not introduced by a partially
// trimmed frame.
InSequence s;
AddTestTracks(HAS_AUDIO);
new_media_segment_ = true;
if (GetParam())
frame_processor_->SetSequenceMode(true);
EXPECT_CALL(callbacks_,
PossibleDurationIncrease(base::TimeDelta::FromMilliseconds(29)));

append_window_start_ = base::TimeDelta::FromMilliseconds(7);
ProcessFrames("0K 19K", "");

EXPECT_EQ(base::TimeDelta(), timestamp_offset_);
CheckExpectedRangesByTimestamp(audio_.get(), "{ [7,29) }");
CheckReadsThenReadStalls(audio_.get(), "7:0 19");
}

INSTANTIATE_TEST_CASE_P(SequenceMode, FrameProcessorTest, Values(true));
INSTANTIATE_TEST_CASE_P(SegmentsMode, FrameProcessorTest, Values(false));

Expand Down

0 comments on commit 04e3518

Please sign in to comment.