[Webkit-unassigned] [Bug 179690] [MSE] Use correct range end checks in sourceBufferPrivateDidReceiveSample()

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 14 14:28:44 PST 2017


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

--- Comment #4 from Jer Noble <jer.noble at apple.com> ---
So I think I remember why we no longer seem to use the SampleIsLessThanMediaTimeComparator objects. We used to, when this was originally implemented, by using std::lower_bound(m_samples.begin(), m_samples.end(), SampleIsGreaterThanMediaTimeComparator).  But std::lower_bound doesn't actually do a binary search; it can't, because map::iterators aren't random access.  map::lower_bound does do a binary search, but it can't take a comparator, because it can't guarantee that the map is sorted in comparator order.  So we re-wrote all the algorithms to use the map::lower_bound (et. all.) algorithms, since those are O(log(n)) rather than the O(n) of the std::lower_bound functions.

I think we can still implement this using the map functions though, even accounting for duration.

Given a sample whose PTS is /pS/ and whose duration is /d/ and whose presentation end time is /pS/ + /d/ = /pE/, the end of the removal range is the first sample whose PTS > /pE/, and the start of the removal range is the first sample whose /pE'/ > /pS/.  Finding the end of the range is easy, it's map.upper_bound(/pE/). Finding the start is harder, because it requires a comparator.  But because our sample map is (supposed to be) non-overlapping, we can just find the first sample whose PTS > /ps/, and then look at the previous sample. If its PTS + duration > /pS/, the previous sample is the start, otherwise the current sample is.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20171114/c33733dc/attachment.html>


More information about the webkit-unassigned mailing list