Bug 1363276 - Discard video output buffers according to presentation time rather than size. r=esawin, a=gchang
authorJohn Lin <jolin@mozilla.com>
Fri, 05 May 2017 16:19:47 +0800
changeset 585363 8349864eb2bb21f679b4be9da7f8f9c418b6a290
parent 585362 5c8364be9b424103db60a00a8105f0ca8928d3f3
child 585364 1094b15fa46efd628f614fd20c03b3d3b4dd741f
push id61106
push userbmo:dkeeler@mozilla.com
push dateFri, 26 May 2017 21:26:31 +0000
reviewersesawin, gchang
bugs1363276
milestone54.0
Bug 1363276 - Discard video output buffers according to presentation time rather than size. r=esawin, a=gchang 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
@@ -175,33 +175,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->mSurfaceTexture.get(), inputInfo.mImageSize,
           gl::OriginPos::BottomLeft);
 
         RefPtr<VideoData> v = VideoData::CreateFromImage(
           inputInfo.mDisplaySize, offset, presentationTimeUs, inputInfo.mDurationUs,
           img, !!(flags & MediaCodec::BUFFER_FLAG_SYNC_FRAME),
           presentationTimeUs);