From 9fdfa8a955dcf1d7aa617d70a2f3a083a26a76bb Mon Sep 17 00:00:00 2001 From: Oana Pop Rus Date: Tue, 11 Jun 2019 09:52:43 +0300 Subject: [PATCH] Backed out 9 changesets (bug 1554075) for reftest failures in Intervals.h and MP4Interval.h on a CLOSED TREE Backed out changeset d5543a60f833 (bug 1554075) Backed out changeset 1ea15f85c789 (bug 1554075) Backed out changeset a76688ee5b8a (bug 1554075) Backed out changeset 85482315a53c (bug 1554075) Backed out changeset c3f3e9e00279 (bug 1554075) Backed out changeset ac24ec2e0349 (bug 1554075) Backed out changeset b04fc8b0c07a (bug 1554075) Backed out changeset 2cce329d894d (bug 1554075) Backed out changeset 347b7b4eaab1 (bug 1554075) --- dom/media/Intervals.h | 73 ++++++-------------- dom/media/MediaDecoderStateMachine.cpp | 2 +- dom/media/VideoUtils.cpp | 10 +-- dom/media/VideoUtils.h | 3 +- dom/media/mediasource/ContainerParser.cpp | 5 -- dom/media/mediasource/ResourceQueue.cpp | 58 +++++----------- dom/media/mediasource/ResourceQueue.h | 7 +- dom/media/mediasource/SourceBufferResource.h | 4 -- dom/media/mp4/Box.cpp | 69 +----------------- dom/media/mp4/Box.h | 36 ++-------- dom/media/mp4/ByteStream.h | 8 --- dom/media/mp4/MoofParser.cpp | 42 ++--------- dom/media/mp4/MoofParser.h | 14 +--- 13 files changed, 60 insertions(+), 271 deletions(-) diff --git a/dom/media/Intervals.h b/dom/media/Intervals.h index d63a42769718..a876c01ea8ad 100644 --- a/dom/media/Intervals.h +++ b/dom/media/Intervals.h @@ -225,12 +225,6 @@ class Interval { (aOther.mStart - aOther.mFuzz <= mEnd + mFuzz); } - // Returns true if the two intervals intersect with this being on the right - // of aOther, ignoring fuzz. - bool TouchesOnRightStrict(const SelfType& aOther) const { - return aOther.mStart <= mStart && mStart <= aOther.mEnd; - } - T mStart; T mEnd; T mFuzz; @@ -306,12 +300,8 @@ class IntervalSet { } SelfType& Add(const SelfType& aIntervals) { - if (aIntervals.mIntervals.Length() == 1) { - Add(aIntervals.mIntervals[0]); - } else { - mIntervals.AppendElements(aIntervals.mIntervals); - Normalize(); - } + mIntervals.AppendElements(aIntervals.mIntervals); + Normalize(); return *this; } @@ -389,26 +379,12 @@ class IntervalSet { } // Excludes an interval from an IntervalSet. + // This is done by inverting aInterval within the bounds of mIntervals + // and then doing the intersection. SelfType& operator-=(const ElemType& aInterval) { if (aInterval.IsEmpty() || mIntervals.IsEmpty()) { return *this; } - if (mIntervals.Length() == 1 && - mIntervals[0].TouchesOnRightStrict(aInterval)) { - // Fast path when we're removing from the front of a set with a - // single interval. This is common for the buffered time ranges - // we see on Twitch. - if (aInterval.mEnd >= mIntervals[0].mEnd) { - mIntervals.RemoveElementAt(0); - } else { - mIntervals[0].mStart = aInterval.mEnd; - mIntervals[0].mFuzz = std::max(mIntervals[0].mFuzz, aInterval.mFuzz); - } - return *this; - } - - // General case performed by inverting aInterval within the bounds of - // mIntervals and then doing the intersection. T firstEnd = std::max(mIntervals[0].mStart, aInterval.mStart); T secondStart = std::min(mIntervals.LastElement().mEnd, aInterval.mEnd); ElemType startInterval(mIntervals[0].mStart, firstEnd); @@ -633,7 +609,7 @@ class IntervalSet { for (auto& interval : mIntervals) { interval.SetFuzz(aFuzz); } - MergeOverlappingIntervals(); + Normalize(); } static const IndexType NoIndex = IndexType(-1); @@ -677,32 +653,27 @@ class IntervalSet { private: void Normalize() { - if (mIntervals.Length() < 2) { - return; - } - mIntervals.Sort(CompareIntervals()); - MergeOverlappingIntervals(); - } + if (mIntervals.Length() >= 2) { + ContainerType normalized; - void MergeOverlappingIntervals() { - if (mIntervals.Length() < 2) { - return; - } + mIntervals.Sort(CompareIntervals()); - // This merges the intervals in place. - IndexType read = 0; - IndexType write = 0; - while (read < mIntervals.Length()) { - ElemType current(mIntervals[read]); - read++; - while (read < mIntervals.Length() && current.Touches(mIntervals[read])) { - current = current.Span(mIntervals[read]); - read++; + // This merges the intervals. + ElemType current(mIntervals[0]); + for (IndexType i = 1; i < mIntervals.Length(); i++) { + ElemType& interval = mIntervals[i]; + if (current.Touches(interval)) { + current = current.Span(interval); + } else { + normalized.AppendElement(std::move(current)); + current = std::move(interval); + } } - mIntervals[write] = current; - write++; + normalized.AppendElement(std::move(current)); + + mIntervals.Clear(); + mIntervals.AppendElements(std::move(normalized)); } - mIntervals.SetLength(write); } struct CompareIntervals { diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index b46f96e36aad..7f6d01d2cff8 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -2615,7 +2615,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder, mAbstractMainThread(aDecoder->AbstractMainThread()), mFrameStats(&aDecoder->GetFrameStatistics()), mVideoFrameContainer(aDecoder->GetVideoFrameContainer()), - mTaskQueue(new TaskQueue(GetMediaThreadPool(MediaThreadType::MDSM), + mTaskQueue(new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK), "MDSM::mTaskQueue", /* aSupportsTailDispatch = */ true)), mWatchManager(this, mTaskQueue), diff --git a/dom/media/VideoUtils.cpp b/dom/media/VideoUtils.cpp index 7e22f22c17d2..dc0631eae5a9 100644 --- a/dom/media/VideoUtils.cpp +++ b/dom/media/VideoUtils.cpp @@ -206,7 +206,6 @@ bool IsValidVideoRegion(const gfx::IntSize& aFrame, already_AddRefed GetMediaThreadPool(MediaThreadType aType) { const char* name; - uint32_t threads = 4; switch (aType) { case MediaThreadType::PLATFORM_DECODER: name = "MediaPDecoder"; @@ -217,10 +216,6 @@ already_AddRefed GetMediaThreadPool(MediaThreadType aType) { case MediaThreadType::WEBRTC_DECODER: name = "WebRTCPD"; break; - case MediaThreadType::MDSM: - name = "MediaDecoderStateMachine"; - threads = 1; - break; default: MOZ_FALLTHROUGH_ASSERT("Unexpected MediaThreadType"); case MediaThreadType::PLAYBACK: @@ -228,8 +223,9 @@ already_AddRefed GetMediaThreadPool(MediaThreadType aType) { break; } - RefPtr pool = - SharedThreadPool::Get(nsDependentCString(name), threads); + static const uint32_t kMediaThreadPoolDefaultCount = 4; + RefPtr pool = SharedThreadPool::Get( + nsDependentCString(name), kMediaThreadPoolDefaultCount); // Ensure a larger stack for platform decoder threads if (aType == MediaThreadType::PLATFORM_DECODER) { diff --git a/dom/media/VideoUtils.h b/dom/media/VideoUtils.h index 5a076eb16885..4611592d5fdf 100644 --- a/dom/media/VideoUtils.h +++ b/dom/media/VideoUtils.h @@ -184,8 +184,7 @@ enum class MediaThreadType { PLAYBACK, // MediaDecoderStateMachine and MediaFormatReader PLATFORM_DECODER, // MediaDataDecoder MSG_CONTROL, - WEBRTC_DECODER, - MDSM, + WEBRTC_DECODER }; // Returns the thread pool that is shared amongst all decoder state machines // for decoding streams. diff --git a/dom/media/mediasource/ContainerParser.cpp b/dom/media/mediasource/ContainerParser.cpp index 7f2e353b7350..e1afc2d39105 100644 --- a/dom/media/mediasource/ContainerParser.cpp +++ b/dom/media/mediasource/ContainerParser.cpp @@ -329,7 +329,6 @@ class MP4Stream : public ByteStream, public DecoderDoctorLifeLogger { bool CachedReadAt(int64_t aOffset, void* aBuffer, size_t aCount, size_t* aBytesRead) override; bool Length(int64_t* aSize) override; - const uint8_t* GetContiguousAccess(int64_t aOffset, size_t aSize) override; private: RefPtr mResource; @@ -360,10 +359,6 @@ bool MP4Stream::CachedReadAt(int64_t aOffset, void* aBuffer, size_t aCount, return true; } -const uint8_t* MP4Stream::GetContiguousAccess(int64_t aOffset, size_t aSize) { - return mResource->GetContiguousAccess(aOffset, aSize); -} - bool MP4Stream::Length(int64_t* aSize) { if (mResource->GetLength() < 0) return false; *aSize = mResource->GetLength(); diff --git a/dom/media/mediasource/ResourceQueue.cpp b/dom/media/mediasource/ResourceQueue.cpp index 2679e076243e..e7ba74c1a7c9 100644 --- a/dom/media/mediasource/ResourceQueue.cpp +++ b/dom/media/mediasource/ResourceQueue.cpp @@ -24,8 +24,7 @@ extern mozilla::LogModule* GetSourceBufferResourceLog(); namespace mozilla { -ResourceItem::ResourceItem(MediaByteBuffer* aData, uint64_t aOffset) - : mData(aData), mOffset(aOffset) {} +ResourceItem::ResourceItem(MediaByteBuffer* aData) : mData(aData) {} size_t ResourceItem::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { // size including this @@ -50,26 +49,13 @@ uint64_t ResourceQueue::GetOffset() { return mOffset; } uint64_t ResourceQueue::GetLength() { return mLogicalLength; } -const uint8_t* ResourceQueue::GetContiguousAccess(int64_t aOffset, - size_t aSize) { - uint32_t offset = 0; - uint32_t start = GetAtOffset(aOffset, &offset); - if (start >= GetSize()) { - return nullptr; - } - ResourceItem* item = ResourceAt(start); - if (offset + aSize > item->mData->Length()) { - return nullptr; - } - return item->mData->Elements() + offset; -} - void ResourceQueue::CopyData(uint64_t aOffset, uint32_t aCount, char* aDest) { uint32_t offset = 0; uint32_t start = GetAtOffset(aOffset, &offset); - size_t i = start; - while (i < uint32_t(GetSize()) && aCount > 0) { - ResourceItem* item = ResourceAt(i++); + uint32_t end = + std::min(GetAtOffset(aOffset + aCount, nullptr) + 1, uint32_t(GetSize())); + for (uint32_t i = start; i < end; ++i) { + ResourceItem* item = ResourceAt(i); uint32_t bytes = std::min(aCount, uint32_t(item->mData->Length() - offset)); if (bytes != 0) { memcpy(aDest, &(*item->mData)[offset], bytes); @@ -81,9 +67,8 @@ void ResourceQueue::CopyData(uint64_t aOffset, uint32_t aCount, char* aDest) { } void ResourceQueue::AppendItem(MediaByteBuffer* aData) { - uint64_t offset = mLogicalLength; mLogicalLength += aData->Length(); - Push(new ResourceItem(aData, offset)); + Push(new ResourceItem(aData)); } uint32_t ResourceQueue::Evict(uint64_t aOffset, uint32_t aSizeToEvict, @@ -112,7 +97,7 @@ uint32_t ResourceQueue::EvictBefore(uint64_t aOffset, ErrorResult& aRv) { aRv.Throw(NS_ERROR_OUT_OF_MEMORY); return 0; } - item->mOffset += offset; + item->mData = data; break; } @@ -171,29 +156,22 @@ ResourceItem* ResourceQueue::ResourceAt(uint32_t aIndex) const { } uint32_t ResourceQueue::GetAtOffset(uint64_t aOffset, - uint32_t* aResourceOffset) const { + uint32_t* aResourceOffset) { MOZ_RELEASE_ASSERT(aOffset >= mOffset); - - size_t hi = GetSize(); - size_t lo = 0; - while (lo < hi) { - size_t mid = lo + (hi - lo) / 2; - const ResourceItem* resource = ResourceAt(mid); - if (resource->mOffset <= aOffset && - aOffset < resource->mOffset + resource->mData->Length()) { + uint64_t offset = mOffset; + for (uint32_t i = 0; i < uint32_t(GetSize()); ++i) { + ResourceItem* item = ResourceAt(i); + // If the item contains the start of the offset we want to + // break out of the loop. + if (item->mData->Length() + offset > aOffset) { if (aResourceOffset) { - *aResourceOffset = aOffset - resource->mOffset; + *aResourceOffset = aOffset - offset; } - return uint32_t(mid); - } - if (resource->mOffset + resource->mData->Length() <= aOffset) { - lo = mid + 1; - } else { - hi = mid; + return i; } + offset += item->mData->Length(); } - - return uint32_t(GetSize()); + return GetSize(); } ResourceItem* ResourceQueue::PopFront() { diff --git a/dom/media/mediasource/ResourceQueue.h b/dom/media/mediasource/ResourceQueue.h index c42ddd6baf0e..20d57e12769c 100644 --- a/dom/media/mediasource/ResourceQueue.h +++ b/dom/media/mediasource/ResourceQueue.h @@ -26,10 +26,9 @@ class ErrorResult; // timepoint. struct ResourceItem { - ResourceItem(MediaByteBuffer* aData, uint64_t aOffset); + explicit ResourceItem(MediaByteBuffer* aData); size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; RefPtr mData; - uint64_t mOffset; }; class ResourceQueue : private nsDeque { @@ -62,8 +61,6 @@ class ResourceQueue : private nsDeque { void Dump(const char* aPath); #endif - const uint8_t* GetContiguousAccess(int64_t aOffset, size_t aSize); - private: ResourceItem* ResourceAt(uint32_t aIndex) const; @@ -72,7 +69,7 @@ class ResourceQueue : private nsDeque { // the resource at the given index returned if it is not null. If // no such resource exists, returns GetSize() and aOffset is // untouched. - uint32_t GetAtOffset(uint64_t aOffset, uint32_t* aResourceOffset) const; + uint32_t GetAtOffset(uint64_t aOffset, uint32_t* aResourceOffset); ResourceItem* PopFront(); diff --git a/dom/media/mediasource/SourceBufferResource.h b/dom/media/mediasource/SourceBufferResource.h index ead0bbc55635..c7e934f491f1 100644 --- a/dom/media/mediasource/SourceBufferResource.h +++ b/dom/media/mediasource/SourceBufferResource.h @@ -110,10 +110,6 @@ class SourceBufferResource final return mInputBuffer.GetLength() - mInputBuffer.GetOffset(); } - const uint8_t* GetContiguousAccess(int64_t aOffset, size_t aSize) { - return mInputBuffer.GetContiguousAccess(aOffset, aSize); - } - #if defined(DEBUG) void Dump(const char* aPath) { mInputBuffer.Dump(aPath); } #endif diff --git a/dom/media/mp4/Box.cpp b/dom/media/mp4/Box.cpp index 9b6bad9541b2..400631b15fe1 100644 --- a/dom/media/mp4/Box.cpp +++ b/dom/media/mp4/Box.cpp @@ -68,6 +68,7 @@ Box::Box(BoxContext* aContext, uint64_t aOffset, const Box* aParent) bytes != sizeof(header)) { return; } + mHeader.AppendElements(header, sizeof(header)); uint64_t size = BigEndian::readUint32(header); if (size == 1) { @@ -86,6 +87,7 @@ Box::Box(BoxContext* aContext, uint64_t aOffset, const Box* aParent) } size = BigEndian::readUint64(bigLength); mBodyOffset = bigLengthRange.mEnd; + mHeader.AppendElements(bigLength, sizeof(bigLength)); } else if (size == 0) { // box extends to end of file. size = mContext->mByteRanges.LastInterval().mEnd - aOffset; @@ -132,21 +134,6 @@ Box Box::FirstChild() const { return Box(mContext, mChildOffset, this); } -nsTArray Box::ReadCompleteBox() const { - const size_t length = mRange.mEnd - mRange.mStart; - nsTArray out(length); - out.SetLength(length); - size_t bytesRead = 0; - if (!mContext->mSource->CachedReadAt(mRange.mStart, out.Elements(), length, - &bytesRead) || - bytesRead != length) { - // Byte ranges are being reported incorrectly - NS_WARNING("Read failed in mozilla::Box::ReadCompleteBox()"); - return nsTArray(0); - } - return out; -} - nsTArray Box::Read() const { nsTArray out; Unused << Read(&out, mRange); @@ -174,56 +161,4 @@ bool Box::Read(nsTArray* aDest, const MediaByteRange& aRange) const { } return true; } - -ByteSlice Box::ReadAsSlice() { - if (!mContext) { - return ByteSlice{nullptr, 0}; - } - int64_t length; - if (!mContext->mSource->Length(&length)) { - // The HTTP server didn't give us a length to work with. - // Limit the read to kMAX_BOX_READ max. - length = std::min(mRange.mEnd - mChildOffset, kMAX_BOX_READ); - } else { - length = mRange.mEnd - mChildOffset; - } - - const uint8_t* data = - mContext->mSource->GetContiguousAccess(mChildOffset, length); - if (data) { - // We can direct access the underlying storage of the ByteStream. - return ByteSlice{data, size_t(length)}; - } - - uint8_t* p = mContext->mAllocator.Allocate(size_t(length)); - size_t bytes; - if (!mContext->mSource->CachedReadAt(mChildOffset, p, length, &bytes) || - bytes != length) { - // Byte ranges are being reported incorrectly - NS_WARNING("Read failed in mozilla::Box::ReadAsSlice()"); - return ByteSlice{nullptr, 0}; - } - return ByteSlice{p, size_t(length)}; -} - -const size_t BLOCK_CAPACITY = 16 * 1024; - -uint8_t* BumpAllocator::Allocate(size_t aNumBytes) { - if (aNumBytes > BLOCK_CAPACITY) { - mBuffers.AppendElement(nsTArray(aNumBytes)); - mBuffers.LastElement().SetLength(aNumBytes); - return mBuffers.LastElement().Elements(); - } - for (nsTArray& buffer : mBuffers) { - if (buffer.Length() + aNumBytes < BLOCK_CAPACITY) { - size_t offset = buffer.Length(); - buffer.SetLength(buffer.Length() + aNumBytes); - return buffer.Elements() + offset; - } - } - mBuffers.AppendElement(nsTArray(BLOCK_CAPACITY)); - mBuffers.LastElement().SetLength(aNumBytes); - return mBuffers.LastElement().Elements(); -} - } // namespace mozilla diff --git a/dom/media/mp4/Box.h b/dom/media/mp4/Box.h index e63bfbcc9030..06ee73b03424 100644 --- a/dom/media/mp4/Box.h +++ b/dom/media/mp4/Box.h @@ -17,14 +17,6 @@ namespace mozilla { class ByteStream; -class BumpAllocator { - public: - uint8_t* Allocate(size_t aNumBytes); - - private: - nsTArray> mBuffers; -}; - class BoxContext { public: BoxContext(ByteStream* aSource, const MediaByteRangeSet& aByteRanges) @@ -32,12 +24,6 @@ class BoxContext { RefPtr mSource; const MediaByteRangeSet& mByteRanges; - BumpAllocator mAllocator; -}; - -struct ByteSlice { - const uint8_t* mBytes; - size_t mSize; }; class Box { @@ -55,20 +41,12 @@ class Box { Box Next() const; Box FirstChild() const; - // Reads the box contents, excluding the header. nsTArray Read() const; - - // Reads the complete box; its header and body. - nsTArray ReadCompleteBox() const; - - // Reads from the content of the box, excluding header. bool Read(nsTArray* aDest, const MediaByteRange& aRange) const; static const uint64_t kMAX_BOX_READ; - // Returns a slice, pointing to the data of this box. The lifetime of - // the memory this slice points to matches the box's context's lifetime. - ByteSlice ReadAsSlice(); + const nsTArray& Header() const { return mHeader; } private: bool Contains(MediaByteRange aRange) const; @@ -77,22 +55,20 @@ class Box { uint64_t mBodyOffset; uint64_t mChildOffset; AtomType mType; + nsTArray mHeader; const Box* mParent; }; -// BoxReader serves box data through an AutoByteReader. The box data is -// stored either in the box's context's bump allocator, or in the ByteStream -// itself if the ByteStream implements the Access() method. -// NOTE: The data the BoxReader reads may be stored in the Box's BoxContext. -// Ensure that the BoxReader doesn't outlive the BoxContext! +// BoxReader takes a copy of a box contents and serves through an +// AutoByteReader. class MOZ_RAII BoxReader { public: explicit BoxReader(Box& aBox) - : mData(aBox.ReadAsSlice()), mReader(mData.mBytes, mData.mSize) {} + : mBuffer(aBox.Read()), mReader(mBuffer.Elements(), mBuffer.Length()) {} BufferReader* operator->() { return &mReader; } private: - ByteSlice mData; + nsTArray mBuffer; BufferReader mReader; }; } // namespace mozilla diff --git a/dom/media/mp4/ByteStream.h b/dom/media/mp4/ByteStream.h index 48de77e74890..bbfaf6ba2af8 100644 --- a/dom/media/mp4/ByteStream.h +++ b/dom/media/mp4/ByteStream.h @@ -24,14 +24,6 @@ class ByteStream : public DecoderDoctorLifeLogger { virtual void DiscardBefore(int64_t offset) {} - // If this ByteStream's underlying storage of media is in-memory, this - // function returns a pointer to the in-memory storage of data at offset. - // Note that even if a ByteStream stores data in memory, it may not be - // stored contiguously, in which case this returns nullptr. - virtual const uint8_t* GetContiguousAccess(int64_t aOffset, size_t aSize) { - return nullptr; - } - protected: virtual ~ByteStream() {} }; diff --git a/dom/media/mp4/MoofParser.cpp b/dom/media/mp4/MoofParser.cpp index 46a5ae72c57d..db5522d8d348 100644 --- a/dom/media/mp4/MoofParser.cpp +++ b/dom/media/mp4/MoofParser.cpp @@ -36,11 +36,6 @@ namespace mozilla { const uint32_t kKeyIdSize = 16; -// We ensure there are no gaps in samples' CTS between the last sample in a -// Moof, and the first sample in the next Moof, if they're within these many -// Microseconds of each other. -const Microseconds CROSS_MOOF_CTS_MERGE_THRESHOLD = 1; - bool MoofParser::RebuildFragmentedIndex(const MediaByteRangeSet& aByteRanges) { BoxContext context(mSource, aByteRanges); return RebuildFragmentedIndex(context); @@ -76,7 +71,7 @@ bool MoofParser::RebuildFragmentedIndex(BoxContext& aContext) { ParseMoov(box); } else if (box.IsType("moof")) { Moof moof(box, mTrackParseMode, mTrex, mMvhd, mMdhd, mEdts, mSinf, - &mLastDecodeTime, mIsAudio, mTracksEndCts); + &mLastDecodeTime, mIsAudio); if (!moof.IsValid() && !box.Next().IsAvailable()) { // Moof isn't valid abort search for now. @@ -427,8 +422,7 @@ class CtsComparator { Moof::Moof(Box& aBox, const TrackParseMode& aTrackParseMode, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, - uint64_t* aDecodeTime, bool aIsAudio, - nsTArray& aTracksEndCts) + uint64_t* aDecodeTime, bool aIsAudio) : mRange(aBox.Range()), mTfhd(aTrex), mMaxRoundingError(35000) { LOG_DEBUG( Moof, @@ -461,7 +455,8 @@ Moof::Moof(Box& aBox, const TrackParseMode& aTrackParseMode, Trex& aTrex, mPsshes.AppendElement(); } nsTArray& pssh = mPsshes.LastElement(); - pssh.AppendElements(std::move(box.ReadCompleteBox())); + pssh.AppendElements(box.Header()); + pssh.AppendElements(box.Read()); } if (IsValid()) { @@ -478,35 +473,6 @@ Moof::Moof(Box& aBox, const TrackParseMode& aTrackParseMode, Trex& aTrex, ctsOrder[i]->mCompositionRange.start; } - // Ensure that there are no gaps between the first sample in this - // Moof and the preceeding Moof. - if (!ctsOrder.IsEmpty()) { - bool found = false; - // Track ID of the track we're parsing. - const uint32_t trackId = aTrex.mTrackId; - // Find the previous CTS end time of Moof preceeding the Moofs we just - // parsed, for the track we're parsing. - for (auto& prevCts : aTracksEndCts) { - if (prevCts.mTrackId == trackId) { - // We have previously parsed a Moof for this track. Smooth the gap - // between samples for this track across the Moof bounary. - if (ctsOrder[0]->mCompositionRange.start - prevCts.mCtsEndTime <= - CROSS_MOOF_CTS_MERGE_THRESHOLD) { - ctsOrder[0]->mCompositionRange.start = prevCts.mCtsEndTime; - } - prevCts.mCtsEndTime = ctsOrder.LastElement()->mCompositionRange.end; - found = true; - break; - } - } - if (!found) { - // We've not parsed a Moof for this track yet. Save its CTS end - // time for the next Moof we parse. - aTracksEndCts.AppendElement(TrackEndCts( - trackId, ctsOrder.LastElement()->mCompositionRange.end)); - } - } - // In MP4, the duration of a sample is defined as the delta between two // decode timestamps. The operation above has updated the duration of each // sample as a Sample's duration is mCompositionRange.end - diff --git a/dom/media/mp4/MoofParser.h b/dom/media/mp4/MoofParser.h index 772dd3909883..b78675357d62 100644 --- a/dom/media/mp4/MoofParser.h +++ b/dom/media/mp4/MoofParser.h @@ -23,16 +23,6 @@ class BoxContext; class BoxReader; class Moof; -// Used to track the CTS end time of the last sample of a track -// in the preceeding Moof, so that we can smooth tracks' timestamps -// across Moofs. -struct TrackEndCts { - TrackEndCts(uint32_t aTrackId, Microseconds aCtsEndTime) - : mTrackId(aTrackId), mCtsEndTime(aCtsEndTime) {} - uint32_t mTrackId; - Microseconds mCtsEndTime; -}; - class Mvhd : public Atom { public: Mvhd() @@ -244,8 +234,7 @@ class Moof final : public Atom { public: Moof(Box& aBox, const TrackParseMode& aTrackParseMode, Trex& aTrex, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, Sinf& aSinf, - uint64_t* aDecodeTime, bool aIsAudio, - nsTArray& aTracksEndCts); + uint64_t* aDecodeTime, bool aIsAudio); bool GetAuxInfo(AtomType aType, FallibleTArray* aByteRanges); void FixRounding(const Moof& aMoof); @@ -348,7 +337,6 @@ class MoofParser : public DecoderDoctorLifeLogger { void ScanForMetadata(mozilla::MediaByteRange& aMoov); nsTArray mMoofs; nsTArray mMediaRanges; - nsTArray mTracksEndCts; bool mIsAudio; uint64_t mLastDecodeTime; // Either a ParseAllTracks if in multitrack mode, or an integer representing