Bug 1380244 - trigger skip-to-next-key-frame quicker; r?jya draft
authorKaku Kuo <kaku@mozilla.com>
Wed, 12 Jul 2017 16:16:49 +0800
changeset 607969 7bd3f5e77736d03de5a4af973ed06aa6b6d64cc8
parent 606958 6fec4855b5345eb63fef57089e61829b88f5f4eb
child 608019 2521e938e1de4db38498746321dca82f1bb5e437
push id68147
push userbmo:kaku@mozilla.com
push dateThu, 13 Jul 2017 01:56:15 +0000
reviewersjya
bugs1380244
milestone56.0a1
Bug 1380244 - trigger skip-to-next-key-frame quicker; r?jya This patch is going to loose the criteria of skip-to-next-key-frame. The original rules are here: http://searchfox.org/mozilla-central/rev/31311070d9860b24fe4a7a36976c14b328c16208/dom/media/MediaFormatReader.cpp#1559 Skip-to-next-key-frame is triggered if the playback position is LARGER than the next key frame time. But, from the video-track point of view, when the skip-to-next-key-frame is triggered, it skips to the next-next key frame. Here is an example, say, we are playing a media file with its playback position at time _a_, and its video decoding is falling behind at time _v_. The next key frame is at time _k1_ and next-next key frame is at time _k2_. a ----|---------|---------|-------------|----------------> time v k1 k2 When the playback position _a_ passes _k1_ (_a_ > _k1_), the skip-to-next-key-frame is triggered, and the demuxer jumps to _k2_ directly. The idea here is to give a chance when (_a_ == _k1_), let demuxer jump to _k1_ and see if the video decoding could catch up. MozReview-Commit-ID: 6aRSYDOI1ds
dom/media/MediaFormatReader.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1551,17 +1551,17 @@ MediaFormatReader::ShouldSkip(TimeUnit a
 
   TimeUnit nextKeyframe;
   nsresult rv = mVideo.mTrackDemuxer->GetNextRandomAccessPoint(&nextKeyframe);
   if (NS_FAILED(rv)) {
     // Only OggTrackDemuxer with video type gets into here.
     // We don't support skip-to-next-frame for this case.
     return false;
   }
-  return (nextKeyframe < aTimeThreshold
+  return (nextKeyframe <= aTimeThreshold
           || (mVideo.mTimeThreshold
               && mVideo.mTimeThreshold.ref().EndTime() < aTimeThreshold))
          && nextKeyframe.ToMicroseconds() >= 0
          && !nextKeyframe.IsInfinite();
 }
 
 RefPtr<MediaDecoderReader::VideoDataPromise>
 MediaFormatReader::RequestVideoData(const TimeUnit& aTimeThreshold)