Skip to content

Commit

Permalink
Backed out changeset b1648cab08f0 (bug 1767360) for causing bc failur…
Browse files Browse the repository at this point in the history
…es on browser_resizeVideo.js. CLOSED TREE
  • Loading branch information
Iulian Moraru committed Aug 27, 2022
1 parent 872c61e commit 723f67f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 34 deletions.
42 changes: 17 additions & 25 deletions dom/media/platforms/wmf/WMFVideoMFTManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -746,7 +747,7 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
VideoData::SetVideoDataToImage(image, mVideoInfo, b, pictureRegion, false);

RefPtr<VideoData> v = VideoData::CreateFromImage(
mSoftwareDisplaySize, aStreamOffset, pts, duration, image.forget(), false,
mVideoInfo.mDisplay, aStreamOffset, pts, duration, image.forget(), false,
TimeUnit::FromMicroseconds(-1));

v.forget(aOutVideoData);
Expand Down Expand Up @@ -851,16 +852,7 @@ 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);
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.
Expand Down
10 changes: 1 addition & 9 deletions dom/media/platforms/wmf/WMFVideoMFTManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<gfx::YUVColorSpace> mColorSpace;
gfx::ColorRange mColorRange;
Expand Down

0 comments on commit 723f67f

Please sign in to comment.