[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser] 36/73: Bug 1767360 - use correct image size retrieved from the output type to create video frames buffer. r=media-playback-reviewers, jolin a=RyanVM



This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch geckoview-102.3.0esr-12.0-1
in repository tor-browser.

commit 3f81dec850ee679b4da8067c2b5315a74776fa4a
Author: alwu <alwu@xxxxxxxxxxx>
AuthorDate: Wed Aug 31 01:34:44 2022 +0000

    Bug 1767360 - use correct image size retrieved from the output type to create video frames buffer. r=media-playback-reviewers,jolin a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D154310
---
 dom/media/platforms/wmf/WMFVideoMFTManager.cpp | 38 ++++++++++++++++----------
 dom/media/platforms/wmf/WMFVideoMFTManager.h   | 11 +++++++-
 2 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
index 5ca21d9e906ef..31bc6d5d6aa42 100644
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -130,7 +130,8 @@ WMFVideoMFTManager::WMFVideoMFTManager(
       mImageSize(aConfig.mImage),
       mStreamType(
           WMFDecoderModule::GetStreamTypeFromMimeType(aConfig.mMimeType)),
-      mDecodedImageSize(aConfig.mImage),
+      mSoftwareImageSize(aConfig.mImage),
+      mSoftwarePictureSize(aConfig.mImage),
       mVideoStride(0),
       mColorSpace(aConfig.mColorSpace),
       mColorRange(aConfig.mColorRange),
@@ -150,8 +151,8 @@ WMFVideoMFTManager::WMFVideoMFTManager(
   // The V and U planes are stored 16-row-aligned, so we need to add padding
   // to the row heights to ensure the Y'CbCr planes are referenced properly.
   // This value is only used with software decoder.
-  if (mDecodedImageSize.height % 16 != 0) {
-    mDecodedImageSize.height += 16 - (mDecodedImageSize.height % 16);
+  if (mSoftwareImageSize.height % 16 != 0) {
+    mSoftwareImageSize.height += 16 - (mSoftwareImageSize.height % 16);
   }
 }
 
@@ -665,8 +666,8 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
   // https://docs.microsoft.com/en-us/windows/desktop/medfound/10-bit-and-16-bit-yuv-video-formats
   VideoData::YCbCrBuffer b;
 
-  uint32_t videoWidth = mImageSize.width;
-  uint32_t videoHeight = mImageSize.height;
+  const uint32_t videoWidth = mSoftwareImageSize.width;
+  const uint32_t videoHeight = mSoftwareImageSize.height;
 
   // Y (Y') plane
   b.mPlanes[0].mData = data;
@@ -675,13 +676,13 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
   b.mPlanes[0].mWidth = videoWidth;
   b.mPlanes[0].mSkip = 0;
 
-  MOZ_DIAGNOSTIC_ASSERT(mDecodedImageSize.height % 16 == 0,
+  MOZ_DIAGNOSTIC_ASSERT(mSoftwareImageSize.height % 16 == 0,
                         "decoded height must be 16 bytes aligned");
-  uint32_t y_size = stride * mDecodedImageSize.height;
-  uint32_t v_size = stride * mDecodedImageSize.height / 4;
-  uint32_t halfStride = (stride + 1) / 2;
-  uint32_t halfHeight = (videoHeight + 1) / 2;
-  uint32_t halfWidth = (videoWidth + 1) / 2;
+  const uint32_t y_size = stride * mSoftwareImageSize.height;
+  const uint32_t v_size = stride * mSoftwareImageSize.height / 4;
+  const uint32_t halfStride = (stride + 1) / 2;
+  const uint32_t halfHeight = (videoHeight + 1) / 2;
+  const uint32_t halfWidth = (videoWidth + 1) / 2;
 
   if (subType == MFVideoFormat_YV12) {
     // U plane (Cb)
@@ -725,8 +726,8 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
   NS_ENSURE_TRUE(pts.IsValid(), E_FAIL);
   TimeUnit duration = GetSampleDurationOrLastKnownDuration(aSample);
   NS_ENSURE_TRUE(duration.IsValid(), E_FAIL);
-  gfx::IntRect pictureRegion =
-      mVideoInfo.ScaledImageRect(videoWidth, videoHeight);
+  gfx::IntRect pictureRegion = mVideoInfo.ScaledImageRect(
+      mSoftwarePictureSize.width, mSoftwarePictureSize.height);
 
   if (colorDepth != gfx::ColorDepth::COLOR_8 || !mKnowsCompositor ||
       !mKnowsCompositor->SupportsD3D11() || !mIMFUsable) {
@@ -853,7 +854,16 @@ WMFVideoMFTManager::Output(int64_t aStreamOffset, RefPtr<MediaData>& aOutData) {
         NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
         NS_ENSURE_TRUE(width <= MAX_VIDEO_WIDTH, E_FAIL);
         NS_ENSURE_TRUE(height <= MAX_VIDEO_HEIGHT, E_FAIL);
-        mDecodedImageSize = gfx::IntSize(width, height);
+        mSoftwareImageSize = gfx::IntSize(width, height);
+
+        gfx::IntRect picture;
+        hr = GetPictureRegion(outputType, picture);
+        NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+        MOZ_ASSERT(picture.width != 0 && picture.height != 0);
+        mSoftwarePictureSize = gfx::IntSize(picture.width, picture.height);
+        LOG("Output stream change, image size=[%ux%u], picture=[%u,%u]",
+            mSoftwareImageSize.width, mSoftwareImageSize.height,
+            mSoftwarePictureSize.width, mSoftwarePictureSize.height);
       }
       // Catch infinite loops, but some decoders perform at least 2 stream
       // changes on consecutive calls, so be permissive.
diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.h b/dom/media/platforms/wmf/WMFVideoMFTManager.h
index e834baeb70bbc..e1c08513c6a58 100644
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -81,7 +81,16 @@ class WMFVideoMFTManager : public MFTManager {
   const VideoInfo mVideoInfo;
   const gfx::IntSize mImageSize;
   const WMFStreamType mStreamType;
-  gfx::IntSize mDecodedImageSize;
+
+  // The size we update from the IMFMediaType which might include paddings when
+  // the stream format changes. This is only used for software decoding.
+  gfx::IntSize mSoftwareImageSize;
+
+  // The picture size we update from the IMFMediaType when the stream format
+  // changes. We assume it's equal to the image size by default (no cropping).
+  // This is only used for software decoding.
+  gfx::IntSize mSoftwarePictureSize;
+
   uint32_t mVideoStride;
   Maybe<gfx::YUVColorSpace> mColorSpace;
   gfx::ColorRange mColorRange;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits