[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor-browser] 05/09: 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 tor-browser-91.13.0esr-11.5-1
in repository tor-browser.
commit 97dc7924d1a369deda583cac7aa8f01fb73ca057
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 084736e0a70c..6ef81eac494f 100644
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -114,7 +114,8 @@ WMFVideoMFTManager::WMFVideoMFTManager(
const CreateDecoderParams::OptionSet& aOptions, bool aDXVAEnabled)
: mVideoInfo(aConfig),
mImageSize(aConfig.mImage),
- mDecodedImageSize(aConfig.mImage),
+ mSoftwareImageSize(aConfig.mImage),
+ mSoftwarePictureSize(aConfig.mImage),
mVideoStride(0),
mColorSpace(aConfig.mColorSpace),
mColorRange(aConfig.mColorRange),
@@ -144,8 +145,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);
}
}
@@ -582,8 +583,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;
@@ -592,13 +593,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)
@@ -640,8 +641,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) {
@@ -763,7 +764,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 f35524c061e1..378089a000db 100644
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -79,7 +79,16 @@ class WMFVideoMFTManager : public MFTManager {
// Video frame geometry.
const VideoInfo mVideoInfo;
const gfx::IntSize mImageSize;
- 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