diff options
author | Dale Curtis <dalecurtis@chromium.org> | 2015-05-11 14:40:50 -0700 |
---|---|---|
committer | Dale Curtis <dalecurtis@chromium.org> | 2015-05-11 21:41:39 +0000 |
commit | c06fe33e8d4b1c0940bf71091ea01fb02858b861 (patch) | |
tree | 78741619e8d12435bc6c8421b0f083c619c9cebc /media | |
parent | f1e479334250fd53ddeb8ef9614a77e0a538b6cb (diff) | |
download | chromium_src-c06fe33e8d4b1c0940bf71091ea01fb02858b861.zip chromium_src-c06fe33e8d4b1c0940bf71091ea01fb02858b861.tar.gz chromium_src-c06fe33e8d4b1c0940bf71091ea01fb02858b861.tar.bz2 |
Merge to M43: "Disable splices for overlap of less than a millisecond."
There appear to be frequent cases where YT is overlapping appends by a
few hundred microseconds which are not actually overlapped. I believe
this to be a limitation of the muxed timestamps, i.e. we frequently see
things with only millisecond granularity.
To avoid glitches and pops in these cases, disable splice frames unless
we have at least a millisecond of data available.
BUG=484414
TEST=new unittest. No glitches on YT or Play Music.
TBR=chcunningham,sandersd
Review URL: https://codereview.chromium.org/1134533004
Cr-Commit-Position: refs/heads/master@{#329063}
(cherry picked from commit 62a5bb3d60f9863666194da9446d467c69fe3280)
Review URL: https://codereview.chromium.org/1138113002
Cr-Commit-Position: refs/branch-heads/2357@{#356}
Cr-Branched-From: 59d4494849b405682265ed5d3f5164573b9a939b-refs/heads/master@{#323860}
Diffstat (limited to 'media')
-rw-r--r-- | media/filters/source_buffer_stream.cc | 15 | ||||
-rw-r--r-- | media/filters/source_buffer_stream_unittest.cc | 27 |
2 files changed, 37 insertions, 5 deletions
diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc index fb699db..3d81409 100644 --- a/media/filters/source_buffer_stream.cc +++ b/media/filters/source_buffer_stream.cc @@ -1536,14 +1536,16 @@ void SourceBufferStream::GenerateSpliceFrame(const BufferQueue& new_buffers) { } } - // Don't generate splice frames which represent less than two frames, since we - // need at least that much to generate a crossfade. Per the spec, make this - // check using the sample rate of the overlapping buffers. + // Don't generate splice frames which represent less than a millisecond (which + // is frequently the extent of timestamp resolution for poorly encoded media) + // or less than two frames (need at least two to crossfade). const base::TimeDelta splice_duration = pre_splice_buffers.back()->timestamp() + pre_splice_buffers.back()->duration() - splice_timestamp; - const base::TimeDelta minimum_splice_duration = base::TimeDelta::FromSecondsD( - 2.0 / audio_configs_[append_config_index_].samples_per_second()); + const base::TimeDelta minimum_splice_duration = std::max( + base::TimeDelta::FromMilliseconds(1), + base::TimeDelta::FromSecondsD( + 2.0 / audio_configs_[append_config_index_].samples_per_second())); if (splice_duration < minimum_splice_duration) { DVLOG(1) << "Can't generate splice: not enough samples for crossfade; have " << splice_duration.InMicroseconds() << " us, but need " @@ -1551,6 +1553,9 @@ void SourceBufferStream::GenerateSpliceFrame(const BufferQueue& new_buffers) { return; } + DVLOG(1) << "Generating splice frame @ " << new_buffers.front()->timestamp() + << ", splice duration: " << splice_duration.InMicroseconds() + << " us"; new_buffers.front()->ConvertToSpliceBuffer(pre_splice_buffers); } diff --git a/media/filters/source_buffer_stream_unittest.cc b/media/filters/source_buffer_stream_unittest.cc index 87509c2..f3914b4 100644 --- a/media/filters/source_buffer_stream_unittest.cc +++ b/media/filters/source_buffer_stream_unittest.cc @@ -3909,6 +3909,33 @@ TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoTinySplices) { CheckNoNextBuffer(); } +TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_NoMillisecondSplices) { + video_config_ = TestVideoConfig::Invalid(); + audio_config_.Initialize(kCodecVorbis, kSampleFormatPlanarF32, + CHANNEL_LAYOUT_STEREO, 4000, NULL, 0, false, false, + base::TimeDelta(), 0); + stream_.reset(new SourceBufferStream(audio_config_, log_cb(), true)); + // Equivalent to 0.5ms per frame. + SetStreamInfo(2000, 2000); + Seek(0); + + // Append four buffers with a 0.5ms duration each. + NewSegmentAppend(0, 4); + CheckExpectedRangesByTimestamp("{ [0,2) }"); + + // Overlap the range [0, 2) with [1.25, 2); this results in an overlap of + // 0.75ms between the ranges. + NewSegmentAppend_OffsetFirstBuffer(2, 2, + base::TimeDelta::FromMillisecondsD(0.25)); + CheckExpectedRangesByTimestamp("{ [0,2) }"); + + // A splice frame should not be generated (indicated by the lack of a config + // change in the expected buffer string) since it requires at least 1ms of + // data to crossfade. + CheckExpectedBuffers("0K 0K 1K 1K 1K"); + CheckNoNextBuffer(); +} + TEST_F(SourceBufferStreamTest, Audio_SpliceFrame_Preroll) { SetAudioStream(); Seek(0); |