Bug 1383580 - Pad estimated CDM frame sizes. r=gerald draft
authorChris Pearce <cpearce@mozilla.com>
Mon, 24 Jul 2017 16:56:24 +1200
changeset 614136 a27793b033c4f50f6e15d874558dc50e1410c8be
parent 614135 6c7201a74dbf202d0ef8c2269292a80a7ad95dff
child 638794 398c3006e3e5504ee6d7402f5b873eef3edc4e98
push id69934
push userbmo:cpearce@mozilla.com
push dateMon, 24 Jul 2017 07:53:51 +0000
reviewersgerald
bugs1383580
milestone56.0a1
Bug 1383580 - Pad estimated CDM frame sizes. r=gerald The new video decoder in CDM version 1.4.8.970 seems to calculate its frame size as about 1.5X of the optimal size. So increase our estimate of CDM video frame buffer sizes by more than that so that our pre-allocated buffers should be big enough to accomodate the allocations that the CDM requests. This means we should be more likely to avoid the slow fallback path where we have to transfer frames from the CDM to the content process using the non-shmem path. MozReview-Commit-ID: 6PT8XVCAL3E
dom/media/gmp/ChromiumCDMParent.cpp
--- a/dom/media/gmp/ChromiumCDMParent.cpp
+++ b/dom/media/gmp/ChromiumCDMParent.cpp
@@ -942,18 +942,25 @@ ChromiumCDMParent::InitializeVideoDecode
 {
   if (mIsShutdown) {
     return MediaDataDecoder::InitPromise::CreateAndReject(
       MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                   RESULT_DETAIL("ChromiumCDMParent is shutdown")),
       __func__);
   }
 
+  // The Widevine CDM version 1.4.8.970 and above contain a video decoder that
+  // does not optimally allocate video frames; it requests buffers much larger
+  // than required. The exact formula the CDM uses to calculate their frame
+  // sizes isn't obvious, but they normally request around or slightly more
+  // than 1.5X the optimal amount. So pad the size of buffers we allocate so
+  // that we're likely to have buffers big enough to accomodate the CDM's weird
+  // frame size calculation.
   const size_t bufferSize =
-    I420FrameBufferSizePadded(aInfo.mImage.width, aInfo.mImage.height);
+    1.7 * I420FrameBufferSizePadded(aInfo.mImage.width, aInfo.mImage.height);
   if (bufferSize <= 0) {
     return MediaDataDecoder::InitPromise::CreateAndReject(
       MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
                   RESULT_DETAIL("Video frame buffer size is invalid.")),
       __func__);
   }
 
   if (!EnsureSufficientShmems(bufferSize)) {