Bug 1643375 - Remove VideoData::YCbCrBuffer::Plane::mOffset. r=alwu

Because we store each plane's data pointer we don't need to store a separate
offset, we can just roll that offset into the pointer for that plane.

This helps remove a lot of code where we're not using the offset anyway, and in
the Chromium CDM case we simply roll the offset into our data pointer.

Differential Revision: https://phabricator.services.mozilla.com/D78320
This commit is contained in:
Bryce Seager van Dyk 2020-06-11 23:04:55 +00:00
parent 7b30d6e82e
commit ac666e8dcb
13 changed files with 18 additions and 41 deletions

View File

@ -263,12 +263,12 @@ PlanarYCbCrData ConstructPlanarYCbCrData(const VideoInfo& aInfo,
const VideoData::YCbCrBuffer::Plane& Cr = aBuffer.mPlanes[2];
PlanarYCbCrData data;
data.mYChannel = Y.mData + Y.mOffset;
data.mYChannel = Y.mData;
data.mYSize = IntSize(Y.mWidth, Y.mHeight);
data.mYStride = Y.mStride;
data.mYSkip = Y.mSkip;
data.mCbChannel = Cb.mData + Cb.mOffset;
data.mCrChannel = Cr.mData + Cr.mOffset;
data.mCbChannel = Cb.mData;
data.mCrChannel = Cr.mData;
data.mCbCrSize = IntSize(Cb.mWidth, Cb.mHeight);
data.mCbCrStride = Cb.mStride;
data.mCbSkip = Cb.mSkip;

View File

@ -441,7 +441,6 @@ class VideoData : public MediaData {
uint32_t mWidth;
uint32_t mHeight;
uint32_t mStride;
uint32_t mOffset;
uint32_t mSkip;
};

View File

@ -820,25 +820,24 @@ already_AddRefed<VideoData> ChromiumCDMParent::CreateVideoFrame(
VideoData::YCbCrBuffer b;
MOZ_ASSERT(aData.Length() > 0);
b.mPlanes[0].mData = aData.Elements();
// Since we store each plane separately we can just roll the offset
// into our pointer to that plane and store that.
b.mPlanes[0].mData = aData.Elements() + aFrame.mYPlane().mPlaneOffset();
b.mPlanes[0].mWidth = aFrame.mImageWidth();
b.mPlanes[0].mHeight = aFrame.mImageHeight();
b.mPlanes[0].mStride = aFrame.mYPlane().mStride();
b.mPlanes[0].mOffset = aFrame.mYPlane().mPlaneOffset();
b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mData = aData.Elements();
b.mPlanes[1].mData = aData.Elements() + aFrame.mUPlane().mPlaneOffset();
b.mPlanes[1].mWidth = (aFrame.mImageWidth() + 1) / 2;
b.mPlanes[1].mHeight = (aFrame.mImageHeight() + 1) / 2;
b.mPlanes[1].mStride = aFrame.mUPlane().mStride();
b.mPlanes[1].mOffset = aFrame.mUPlane().mPlaneOffset();
b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = aData.Elements();
b.mPlanes[2].mData = aData.Elements() + aFrame.mVPlane().mPlaneOffset();
b.mPlanes[2].mWidth = (aFrame.mImageWidth() + 1) / 2;
b.mPlanes[2].mHeight = (aFrame.mImageHeight() + 1) / 2;
b.mPlanes[2].mStride = aFrame.mVPlane().mStride();
b.mPlanes[2].mOffset = aFrame.mVPlane().mPlaneOffset();
b.mPlanes[2].mSkip = 0;
// We unfortunately can't know which colorspace the video is using at this

View File

@ -152,17 +152,14 @@ RefPtr<MediaDataDecoder::DecodePromise> AOMDecoder::ProcessDecode(
b.mPlanes[0].mStride = img->stride[0];
b.mPlanes[0].mHeight = img->d_h;
b.mPlanes[0].mWidth = img->d_w;
b.mPlanes[0].mOffset = 0;
b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mData = img->planes[1];
b.mPlanes[1].mStride = img->stride[1];
b.mPlanes[1].mOffset = 0;
b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = img->planes[2];
b.mPlanes[2].mStride = img->stride[2];
b.mPlanes[2].mOffset = 0;
b.mPlanes[2].mSkip = 0;
if (img->fmt == AOM_IMG_FMT_I420 || img->fmt == AOM_IMG_FMT_I42016) {

View File

@ -51,7 +51,6 @@ already_AddRefed<MediaData> BlankVideoDataCreator::Create(
buffer.mPlanes[0].mStride = mFrameWidth;
buffer.mPlanes[0].mHeight = mFrameHeight;
buffer.mPlanes[0].mWidth = mFrameWidth;
buffer.mPlanes[0].mOffset = 0;
buffer.mPlanes[0].mSkip = 0;
// Cb plane.
@ -59,7 +58,6 @@ already_AddRefed<MediaData> BlankVideoDataCreator::Create(
buffer.mPlanes[1].mStride = (mFrameWidth + 1) / 2;
buffer.mPlanes[1].mHeight = (mFrameHeight + 1) / 2;
buffer.mPlanes[1].mWidth = (mFrameWidth + 1) / 2;
buffer.mPlanes[1].mOffset = 0;
buffer.mPlanes[1].mSkip = 0;
// Cr plane.
@ -67,7 +65,6 @@ already_AddRefed<MediaData> BlankVideoDataCreator::Create(
buffer.mPlanes[2].mStride = (mFrameWidth + 1) / 2;
buffer.mPlanes[2].mHeight = (mFrameHeight + 1) / 2;
buffer.mPlanes[2].mWidth = (mFrameWidth + 1) / 2;
buffer.mPlanes[2].mOffset = 0;
buffer.mPlanes[2].mSkip = 0;
buffer.mYUVColorSpace = gfx::YUVColorSpace::BT601;

View File

@ -210,17 +210,14 @@ already_AddRefed<VideoData> DAV1DDecoder::ConstructImage(
b.mPlanes[0].mStride = aPicture.stride[0];
b.mPlanes[0].mHeight = aPicture.p.h;
b.mPlanes[0].mWidth = aPicture.p.w;
b.mPlanes[0].mOffset = 0;
b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mData = static_cast<uint8_t*>(aPicture.data[1]);
b.mPlanes[1].mStride = aPicture.stride[1];
b.mPlanes[1].mOffset = 0;
b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = static_cast<uint8_t*>(aPicture.data[2]);
b.mPlanes[2].mStride = aPicture.stride[1];
b.mPlanes[2].mOffset = 0;
b.mPlanes[2].mSkip = 0;
// https://code.videolan.org/videolan/dav1d/blob/master/tools/output/yuv.c#L67

View File

@ -152,19 +152,19 @@ RefPtr<MediaDataDecoder::DecodePromise> TheoraDecoder::ProcessDecode(
b.mPlanes[0].mStride = ycbcr[0].stride;
b.mPlanes[0].mHeight = mTheoraInfo.frame_height;
b.mPlanes[0].mWidth = mTheoraInfo.frame_width;
b.mPlanes[0].mOffset = b.mPlanes[0].mSkip = 0;
b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mData = ycbcr[1].data;
b.mPlanes[1].mStride = ycbcr[1].stride;
b.mPlanes[1].mHeight = mTheoraInfo.frame_height >> vdec;
b.mPlanes[1].mWidth = mTheoraInfo.frame_width >> hdec;
b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = ycbcr[2].data;
b.mPlanes[2].mStride = ycbcr[2].stride;
b.mPlanes[2].mHeight = mTheoraInfo.frame_height >> vdec;
b.mPlanes[2].mWidth = mTheoraInfo.frame_width >> hdec;
b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
b.mPlanes[2].mSkip = 0;
b.mYUVColorSpace =
DefaultColorSpace({mTheoraInfo.frame_width, mTheoraInfo.frame_height});

View File

@ -148,15 +148,15 @@ RefPtr<MediaDataDecoder::DecodePromise> VPXDecoder::ProcessDecode(
b.mPlanes[0].mStride = img->stride[0];
b.mPlanes[0].mHeight = img->d_h;
b.mPlanes[0].mWidth = img->d_w;
b.mPlanes[0].mOffset = b.mPlanes[0].mSkip = 0;
b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mData = img->planes[1];
b.mPlanes[1].mStride = img->stride[1];
b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = img->planes[2];
b.mPlanes[2].mStride = img->stride[2];
b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
b.mPlanes[2].mSkip = 0;
if (img->fmt == VPX_IMG_FMT_I420) {
b.mPlanes[1].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
@ -206,7 +206,7 @@ RefPtr<MediaDataDecoder::DecodePromise> VPXDecoder::ProcessDecode(
alpha_plane.mStride = img_alpha->stride[0];
alpha_plane.mHeight = img_alpha->d_h;
alpha_plane.mWidth = img_alpha->d_w;
alpha_plane.mOffset = alpha_plane.mSkip = 0;
alpha_plane.mSkip = 0;
v = VideoData::CreateAndCopyData(
mInfo, mImageContainer, aSample->mOffset, aSample->mTime,
aSample->mDuration, b, alpha_plane, aSample->mKeyframe,

View File

@ -52,7 +52,6 @@ void GMPVideoDecoder::Decoded(GMPVideoi420Frame* aDecodedFrame) {
b.mPlanes[i].mWidth = (decodedFrame->Width() + 1) / 2;
b.mPlanes[i].mHeight = (decodedFrame->Height() + 1) / 2;
}
b.mPlanes[i].mOffset = 0;
b.mPlanes[i].mSkip = 0;
}

View File

@ -384,7 +384,6 @@ void AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
buffer.mPlanes[0].mStride = CVPixelBufferGetBytesPerRowOfPlane(aImage, 0);
buffer.mPlanes[0].mWidth = width;
buffer.mPlanes[0].mHeight = height;
buffer.mPlanes[0].mOffset = 0;
buffer.mPlanes[0].mSkip = 0;
// Cb plane.
buffer.mPlanes[1].mData =
@ -392,7 +391,6 @@ void AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
buffer.mPlanes[1].mStride = CVPixelBufferGetBytesPerRowOfPlane(aImage, 1);
buffer.mPlanes[1].mWidth = (width + 1) / 2;
buffer.mPlanes[1].mHeight = (height + 1) / 2;
buffer.mPlanes[1].mOffset = 0;
buffer.mPlanes[1].mSkip = 0;
// Cr plane.
buffer.mPlanes[2].mData =
@ -400,7 +398,6 @@ void AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage,
buffer.mPlanes[2].mStride = CVPixelBufferGetBytesPerRowOfPlane(aImage, 2);
buffer.mPlanes[2].mWidth = (width + 1) / 2;
buffer.mPlanes[2].mHeight = (height + 1) / 2;
buffer.mPlanes[2].mOffset = 0;
buffer.mPlanes[2].mSkip = 0;
buffer.mYUVColorSpace = mColorSpace;

View File

@ -571,9 +571,9 @@ MediaResult FFmpegVideoDecoder<LIBAV_VER>::CreateImage(
b.mPlanes[1].mStride = mFrame->linesize[1];
b.mPlanes[2].mStride = mFrame->linesize[2];
b.mPlanes[0].mOffset = b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mSkip = 0;
b.mPlanes[0].mWidth = mFrame->width;
b.mPlanes[0].mHeight = mFrame->height;

View File

@ -921,21 +921,18 @@ already_AddRefed<VideoData> MediaDataHelper::CreateYUV420VideoData(
b.mPlanes[0].mWidth = width;
b.mPlanes[0].mHeight = height;
b.mPlanes[0].mStride = stride;
b.mPlanes[0].mOffset = 0;
b.mPlanes[0].mSkip = 0;
b.mPlanes[1].mData = yuv420p_u;
b.mPlanes[1].mWidth = (width + 1) / 2;
b.mPlanes[1].mHeight = (height + 1) / 2;
b.mPlanes[1].mStride = (stride + 1) / 2;
b.mPlanes[1].mOffset = 0;
b.mPlanes[1].mSkip = 0;
b.mPlanes[2].mData = yuv420p_v;
b.mPlanes[2].mWidth = (width + 1) / 2;
b.mPlanes[2].mHeight = (height + 1) / 2;
b.mPlanes[2].mStride = (stride + 1) / 2;
b.mPlanes[2].mOffset = 0;
b.mPlanes[2].mSkip = 0;
b.mYUVColorSpace =

View File

@ -868,7 +868,6 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
b.mPlanes[0].mStride = stride;
b.mPlanes[0].mHeight = videoHeight;
b.mPlanes[0].mWidth = videoWidth;
b.mPlanes[0].mOffset = 0;
b.mPlanes[0].mSkip = 0;
MOZ_DIAGNOSTIC_ASSERT(mDecodedImageSize.height % 16 == 0,
@ -885,7 +884,6 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
b.mPlanes[1].mStride = halfStride;
b.mPlanes[1].mHeight = halfHeight;
b.mPlanes[1].mWidth = halfWidth;
b.mPlanes[1].mOffset = 0;
b.mPlanes[1].mSkip = 0;
// V plane (Cr)
@ -893,7 +891,6 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
b.mPlanes[2].mStride = halfStride;
b.mPlanes[2].mHeight = halfHeight;
b.mPlanes[2].mWidth = halfWidth;
b.mPlanes[2].mOffset = 0;
b.mPlanes[2].mSkip = 0;
} else {
// U plane (Cb)
@ -901,7 +898,6 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
b.mPlanes[1].mStride = stride;
b.mPlanes[1].mHeight = halfHeight;
b.mPlanes[1].mWidth = halfWidth;
b.mPlanes[1].mOffset = 0;
b.mPlanes[1].mSkip = 1;
// V plane (Cr)
@ -909,7 +905,6 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample,
b.mPlanes[2].mStride = stride;
b.mPlanes[2].mHeight = halfHeight;
b.mPlanes[2].mWidth = halfWidth;
b.mPlanes[2].mOffset = 0;
b.mPlanes[2].mSkip = 1;
}