Modified: trunk/Source/WebCore/ChangeLog (291100 => 291101)
--- trunk/Source/WebCore/ChangeLog 2022-03-10 11:38:43 UTC (rev 291100)
+++ trunk/Source/WebCore/ChangeLog 2022-03-10 12:03:07 UTC (rev 291101)
@@ -1,3 +1,19 @@
+2022-03-10 Enrique Ocaña González <[email protected]>
+
+ [MSE][SourceBuffer] Fix creating float PTS/DTS when dividing sample
+ https://bugs.webkit.org/show_bug.cgi?id=237528
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ The timestamps used for sample division in SourceBuffer aren't being
+ aligned with the same rounding margin used in
+ SourceBuffer::sourceBufferPrivateDidReceiveSample().
+
+ This patch is authored by Eugene Mutavchi <[email protected]>
+ See: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/797
+
+ * platform/graphics/SourceBufferPrivate.cpp: Extracted roundTowardsTimeScaleWithRoundingMargin lambda as a function and used it from removeCodedFrames(), on top of the current usage from sourceBufferPrivateDidReceiveSample().
+
2022-03-09 Antoine Quint <[email protected]>
[web-animations] fill-rule should support discrete animation
Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp (291100 => 291101)
--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2022-03-10 11:38:43 UTC (rev 291100)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivate.cpp 2022-03-10 12:03:07 UTC (rev 291101)
@@ -44,6 +44,18 @@
namespace WebCore {
+static inline MediaTime roundTowardsTimeScaleWithRoundingMargin(const MediaTime& time, uint32_t timeScale, const MediaTime& roundingMargin)
+{
+ while (true) {
+ MediaTime roundedTime = time.toTimeScale(timeScale);
+ if (abs(roundedTime - time) < roundingMargin || timeScale >= MediaTime::MaximumTimeScale)
+ return roundedTime;
+
+ if (!WTF::safeMultiply(timeScale, 2, timeScale) || timeScale > MediaTime::MaximumTimeScale)
+ timeScale = MediaTime::MaximumTimeScale;
+ }
+};
+
// Do not enqueue samples spanning a significant unbuffered gap.
// NOTE: one second is somewhat arbitrary. MediaSource::monitorSourceBuffers() is run
// on the playbackTimer, which is effectively every 350ms. Allowing > 350ms gap between
@@ -559,7 +571,9 @@
RefPtr<MediaSample> sample = sampleIterator->second;
if (!sample->isDivisable())
return;
- std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> replacementSamples = sample->divide(time);
+ MediaTime microsecond(1, 1000000);
+ MediaTime roundedTime = roundTowardsTimeScaleWithRoundingMargin(time, sample->presentationTime().timeScale(), microsecond);
+ std::pair<RefPtr<MediaSample>, RefPtr<MediaSample>> replacementSamples = sample->divide(roundedTime);
if (!replacementSamples.first || !replacementSamples.second)
return;
DEBUG_LOG(LOGIDENTIFIER, "splitting sample ", *sample, " into ", *replacementSamples.first, " and ", *replacementSamples.second);
@@ -926,17 +940,6 @@
MediaTime microsecond(1, 1000000);
- auto roundTowardsTimeScaleWithRoundingMargin = [] (const MediaTime& time, uint32_t timeScale, const MediaTime& roundingMargin) {
- while (true) {
- MediaTime roundedTime = time.toTimeScale(timeScale);
- if (abs(roundedTime - time) < roundingMargin || timeScale >= MediaTime::MaximumTimeScale)
- return roundedTime;
-
- if (!WTF::safeMultiply(timeScale, 2, timeScale) || timeScale > MediaTime::MaximumTimeScale)
- timeScale = MediaTime::MaximumTimeScale;
- }
- };
-
// 1.4 If timestampOffset is not 0, then run the following steps:
if (m_timestampOffset) {
if (!trackBuffer.roundedTimestampOffset.isValid() || presentationTimestamp.timeScale() != trackBuffer.lastFrameTimescale) {