From 723f67f7c3066b50e6a932f4d026f012ebd9fdc1 Mon Sep 17 00:00:00 2001 From: Iulian Moraru Date: Sat, 27 Aug 2022 03:09:49 +0300 Subject: [PATCH] Backed out changeset b1648cab08f0 (bug 1767360) for causing bc failures on browser_resizeVideo.js. CLOSED TREE --- .../platforms/wmf/WMFVideoMFTManager.cpp | 42 ++++++++----------- dom/media/platforms/wmf/WMFVideoMFTManager.h | 10 +---- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index e39404b2d5ebf..c6df6a8eff52a 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -129,7 +129,7 @@ WMFVideoMFTManager::WMFVideoMFTManager( : mVideoInfo(aConfig), mImageSize(aConfig.mImage), mStreamType(GetStreamTypeFromMimeType(aConfig.mMimeType)), - mSoftwareImageSize(aConfig.mImage), + mDecodedImageSize(aConfig.mImage), mVideoStride(0), mColorSpace(aConfig.mColorSpace), mColorRange(aConfig.mColorRange), @@ -149,8 +149,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 (mSoftwareImageSize.height % 16 != 0) { - mSoftwareImageSize.height += 16 - (mSoftwareImageSize.height % 16); + if (mDecodedImageSize.height % 16 != 0) { + mDecodedImageSize.height += 16 - (mDecodedImageSize.height % 16); } } @@ -664,15 +664,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; - MOZ_DIAGNOSTIC_ASSERT(mSoftwareImageSize.height % 16 == 0, - "decoded height must be 16 bytes aligned"); - const uint32_t y_size = stride * mSoftwareImageSize.height; - const uint32_t v_size = stride * mSoftwareImageSize.height / 4; - const uint32_t videoWidth = mSoftwareImageSize.width; - const uint32_t videoHeight = mSoftwareImageSize.height; - const uint32_t halfStride = (stride + 1) / 2; - const uint32_t halfHeight = (videoHeight + 1) / 2; - const uint32_t halfWidth = (videoWidth + 1) / 2; + uint32_t videoWidth = mImageSize.width; + uint32_t videoHeight = mImageSize.height; // Y (Y') plane b.mPlanes[0].mData = data; @@ -681,6 +674,14 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample, b.mPlanes[0].mWidth = videoWidth; b.mPlanes[0].mSkip = 0; + MOZ_DIAGNOSTIC_ASSERT(mDecodedImageSize.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; + if (subType == MFVideoFormat_YV12) { // U plane (Cb) b.mPlanes[1].mData = data + y_size + v_size; @@ -723,8 +724,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( - mSoftwareDisplaySize.width, mSoftwareDisplaySize.height); + gfx::IntRect pictureRegion = + mVideoInfo.ScaledImageRect(videoWidth, videoHeight); if (colorDepth != gfx::ColorDepth::COLOR_8 || !mKnowsCompositor || !mKnowsCompositor->SupportsD3D11() || !mIMFUsable) { @@ -746,7 +747,7 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample, VideoData::SetVideoDataToImage(image, mVideoInfo, b, pictureRegion, false); RefPtr v = VideoData::CreateFromImage( - mSoftwareDisplaySize, aStreamOffset, pts, duration, image.forget(), false, + mVideoInfo.mDisplay, aStreamOffset, pts, duration, image.forget(), false, TimeUnit::FromMicroseconds(-1)); v.forget(aOutVideoData); @@ -851,16 +852,7 @@ WMFVideoMFTManager::Output(int64_t aStreamOffset, RefPtr& 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); - mSoftwareImageSize = gfx::IntSize(width, height); - - gfx::IntRect display; - hr = GetPictureRegion(outputType, display); - NS_ENSURE_TRUE(SUCCEEDED(hr), hr); - MOZ_ASSERT(display.width != 0 && display.height != 0); - mSoftwareDisplaySize = gfx::IntSize(display.width, display.height); - LOG("Output type, image size=[%ux%u], display=[%u,%u]", - mSoftwareImageSize.width, mSoftwareImageSize.height, - mSoftwareDisplaySize.width, mSoftwareDisplaySize.height); + mDecodedImageSize = gfx::IntSize(width, 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 e572a6c4bf810..e834baeb70bbc 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.h +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h @@ -81,15 +81,7 @@ class WMFVideoMFTManager : public MFTManager { const VideoInfo mVideoInfo; const gfx::IntSize mImageSize; const WMFStreamType mStreamType; - - // The size we ask from the IMFMediaType which might include paddings. This is - // only used for softwate decoding. - gfx::IntSize mSoftwareImageSize; - - // The display size we ask from the IMFMediaType, which might be different - // from the video info. This is only used for softwate decoding. - gfx::IntSize mSoftwareDisplaySize; - + gfx::IntSize mDecodedImageSize; uint32_t mVideoStride; Maybe mColorSpace; gfx::ColorRange mColorRange;