Bug 1363276 - discard video output buffers according to presentation time rather than size. r=esawin
authorJohn Lin <jolin@mozilla.com>
Fri, 05 May 2017 16:19:47 +0800
changeset 406624 0eb6bcebaf3d6f3d2b16c877f5a8828041445c16
parent 406623 9c25241fc5f495b26eb33bb3087910a587aa0645
child 406625 1f595ec2b2a260460296adaf3999da88c69af866
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1363276
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1363276 - discard video output buffers according to presentation time rather than size. r=esawin This works around an Android 4.2.2 bug that reports incorrect sizes for hardware buffers. MozReview-Commit-ID: 4rAu8d1RwOJ
dom/media/platforms/android/RemoteDataDecoder.cpp
--- a/dom/media/platforms/android/RemoteDataDecoder.cpp
+++ b/dom/media/platforms/android/RemoteDataDecoder.cpp
@@ -110,33 +110,32 @@ public:
       bool ok = NS_SUCCEEDED(info->Flags(&flags));
 
       int32_t offset;
       ok &= NS_SUCCEEDED(info->Offset(&offset));
 
       int64_t presentationTimeUs;
       ok &= NS_SUCCEEDED(info->PresentationTimeUs(&presentationTimeUs));
 
-      int32_t size;
-      ok &= NS_SUCCEEDED(info->Size(&size));
-
       if (!ok) {
         HandleError(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                                 RESULT_DETAIL("VideoCallBack::HandleOutput")));
         return;
       }
 
-      bool isEOS = !!(flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM);
+
       InputInfo inputInfo;
-      if (!mDecoder->mInputInfos.Find(presentationTimeUs, inputInfo)
-          && !isEOS) {
+      ok = mDecoder->mInputInfos.Find(presentationTimeUs, inputInfo);
+      bool isEOS = !!(flags & MediaCodec::BUFFER_FLAG_END_OF_STREAM);
+      if (!ok && !isEOS) {
+        // Ignore output with no corresponding input.
         return;
       }
 
-      if (size > 0) {
+      if (ok && presentationTimeUs >= 0) {
         RefPtr<layers::Image> img = new SurfaceTextureImage(
           mDecoder->mSurfaceHandle, inputInfo.mImageSize, false /* NOT continuous */,
           gl::OriginPos::BottomLeft);
 
         RefPtr<VideoData> v = VideoData::CreateFromImage(
           inputInfo.mDisplaySize, offset,
           TimeUnit::FromMicroseconds(presentationTimeUs),
           TimeUnit::FromMicroseconds(inputInfo.mDurationUs),