Skip to content

Commit

Permalink
Merge r236258 - [MSE] Use some tolerance when deciding whether a fram…
Browse files Browse the repository at this point in the history
…e should be appended to the decode queue

https://bugs.webkit.org/show_bug.cgi?id=189782

Reviewed by Xabier Rodriguez-Calvar.

Ideally, container formats should use exact timestamps and frames
should not overlap. Unfortunately, there are lots of files out there
where this is not always the case.

This is particularly a problem in WebM, where timestamps are expressed
in a power of 10 timescale, which forces some rounding.

This patch makes SourceBuffer allow frames with a small overlaps
(<=1ms) as those usually found in WebM. 1 ms is chosen because it's
the default time scale of WebM files.

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):
  • Loading branch information
ntrrgc authored and aperezdc committed Sep 21, 2018
1 parent 6dffa0b commit a512fb1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,24 @@
2018-09-20 Alicia Boya García <aboya@igalia.com>

[MSE] Use some tolerance when deciding whether a frame should be appended to the decode queue
https://bugs.webkit.org/show_bug.cgi?id=189782

Reviewed by Xabier Rodriguez-Calvar.

Ideally, container formats should use exact timestamps and frames
should not overlap. Unfortunately, there are lots of files out there
where this is not always the case.

This is particularly a problem in WebM, where timestamps are expressed
in a power of 10 timescale, which forces some rounding.

This patch makes SourceBuffer allow frames with a small overlaps
(<=1ms) as those usually found in WebM. 1 ms is chosen because it's
the default time scale of WebM files.

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample):

2018-09-11 Pablo Saavedra <psaavedra@igalia.com>

playbackControlsManagerUpdateTimerFired and
Expand Down
12 changes: 11 additions & 1 deletion Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Expand Up @@ -1610,7 +1610,17 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(MediaSample& sample)
// Add the coded frame with the presentation timestamp, decode timestamp, and frame duration to the track buffer.
trackBuffer.samples.addSample(sample);

if (trackBuffer.lastEnqueuedDecodeEndTime.isInvalid() || decodeTimestamp >= trackBuffer.lastEnqueuedDecodeEndTime) {
// Note: The terminology here is confusing: "enqueuing" means providing a frame to the inner media framework.
// First, frames are inserted in the decode queue; later, at the end of the append all the frames in the decode
// queue are "enqueued" (sent to the inner media framework) in `provideMediaData()`.
//
// In order to check whether a frame should be added to the decode queue we check whether it starts after the
// lastEnqueuedDecodeEndTime or even a bit before that to accomodate files with imprecise timing information.
//
// There are many files out there where the frame times are not perfectly contiguous, therefore a tolerance is needed.
// For instance, most WebM files are muxed rounded to the millisecond (the default TimecodeScale of the format).
const MediaTime contiguousFrameTolerance = MediaTime(1, 1000);
if (trackBuffer.lastEnqueuedDecodeEndTime.isInvalid() || decodeTimestamp >= (trackBuffer.lastEnqueuedDecodeEndTime - contiguousFrameTolerance)) {
DecodeOrderSampleMap::KeyType decodeKey(sample.decodeTime(), sample.presentationTime());
trackBuffer.decodeQueue.insert(DecodeOrderSampleMap::MapType::value_type(decodeKey, &sample));
}
Expand Down

0 comments on commit a512fb1

Please sign in to comment.