Bug 1276184: [MSE] P2. Remove the need to scan the track buffer when frames are being removed. r=kamidphish

The index at which we are removing frames is always the one where we will be inserting the next ones.

MozReview-Commit-ID: DHeJDmwiMS9

--HG--
extra : rebase_source : 3730c0ed7fbdb4d9f8b4157f36aa7bb9d03a6517
This commit is contained in:
Jean-Yves Avenard 2016-06-02 16:59:00 +10:00
Родитель 2089f9d8bb
Коммит c7855950ec
2 изменённых файлов: 15 добавлений и 6 удалений

Просмотреть файл

@ -1630,7 +1630,11 @@ TrackBuffersManager::InsertFrames(TrackBuffer& aSamples,
// so the search for when to start our frames removal can be exhaustive.
trackBuffer.mNextInsertionIndex.reset();
}
RemoveFrames(aIntervals, trackBuffer, trackBuffer.mNextInsertionIndex.refOr(0));
size_t index =
RemoveFrames(aIntervals, trackBuffer, trackBuffer.mNextInsertionIndex.refOr(0));
if (index) {
trackBuffer.mNextInsertionIndex = Some(index);
}
}
// 16. Add the coded frame with the presentation timestamp, decode timestamp, and frame duration to the track buffer.
@ -1667,7 +1671,7 @@ TrackBuffersManager::InsertFrames(TrackBuffer& aSamples,
}
}
void
size_t
TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals,
TrackData& aTrackData,
uint32_t aStartIndex)
@ -1699,7 +1703,7 @@ TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals,
}
if (firstRemovedIndex.isNothing()) {
return;
return 0;
}
// Remove decoding dependencies of the coded frames removed in the previous step:
@ -1763,6 +1767,8 @@ TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals,
data.RemoveElementsAt(firstRemovedIndex.ref(),
lastRemovedIndex - firstRemovedIndex.ref() + 1);
return firstRemovedIndex.ref();
}
void

Просмотреть файл

@ -341,9 +341,12 @@ private:
void InsertFrames(TrackBuffer& aSamples,
const media::TimeIntervals& aIntervals,
TrackData& aTrackData);
void RemoveFrames(const media::TimeIntervals& aIntervals,
TrackData& aTrackData,
uint32_t aStartIndex);
// Remove all frames and their dependencies contained in aIntervals.
// Return the index at which frames were first removed or 0 if no frames
// removed.
size_t RemoveFrames(const media::TimeIntervals& aIntervals,
TrackData& aTrackData,
uint32_t aStartIndex);
// Find index of sample. Return a negative value if not found.
uint32_t FindSampleIndex(const TrackBuffer& aTrackBuffer,
const media::TimeInterval& aInterval);