Bug 1295921 - PA: Return blank decoder to being green. r?jwwang draft
authorDan Glastonbury <dglastonbury@mozilla.com>
Wed, 21 Sep 2016 14:06:51 +1000
changeset 450830 d06b67edd6b9a8e62fabab93e06bfc8224e116cb
parent 450829 968275f698f2b6cdb08c696288e36a1104e6e978
child 450831 f04eae06ddd9467003bb538780ed260f3e15b52b
push id38957
push userbmo:dglastonbury@mozilla.com
push dateMon, 19 Dec 2016 02:15:56 +0000
reviewersjwwang
bugs1295921
milestone53.0a1
Bug 1295921 - PA: Return blank decoder to being green. r?jwwang MozReview-Commit-ID: 44QZeHKlt3o
dom/media/platforms/agnostic/BlankDecoderModule.cpp
--- a/dom/media/platforms/agnostic/BlankDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/BlankDecoderModule.cpp
@@ -39,50 +39,46 @@ public:
     mInfo.mDisplay = nsIntSize(mFrameWidth, mFrameHeight);
     mPicture = gfx::IntRect(0, 0, mFrameWidth, mFrameHeight);
   }
 
   already_AddRefed<MediaData> Create(MediaRawData* aSample)
   {
     // Create a fake YUV buffer in a 420 format. That is, an 8bpp Y plane,
     // with a U and V plane that are half the size of the Y plane, i.e 8 bit,
-    // 2x2 subsampled.
-    const int sizeY = mFrameWidth * mFrameHeight;
-    const int sizeCbCr = ((mFrameWidth + 1) / 2) * ((mFrameHeight + 1) / 2);
-    auto frame = MakeUnique<uint8_t[]>(sizeY + sizeCbCr);
+    // 2x2 subsampled. Have the data pointer of each frame point to the
+    // first plane, they'll always be zero'd memory anyway.
+    auto frame = MakeUnique<uint8_t[]>(mFrameWidth * mFrameHeight);
+    memset(frame.get(), 0, mFrameWidth * mFrameHeight);
     VideoData::YCbCrBuffer buffer;
 
     // Y plane.
     buffer.mPlanes[0].mData = frame.get();
     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.
-    buffer.mPlanes[1].mData = frame.get() + sizeY;
+    buffer.mPlanes[1].mData = frame.get();
     buffer.mPlanes[1].mStride = mFrameWidth / 2;
     buffer.mPlanes[1].mHeight = mFrameHeight / 2;
     buffer.mPlanes[1].mWidth = mFrameWidth / 2;
     buffer.mPlanes[1].mOffset = 0;
     buffer.mPlanes[1].mSkip = 0;
 
     // Cr plane.
-    buffer.mPlanes[2].mData = frame.get() + sizeY;
+    buffer.mPlanes[2].mData = frame.get();
     buffer.mPlanes[2].mStride = mFrameWidth / 2;
     buffer.mPlanes[2].mHeight = mFrameHeight / 2;
     buffer.mPlanes[2].mWidth = mFrameWidth / 2;
     buffer.mPlanes[2].mOffset = 0;
     buffer.mPlanes[2].mSkip = 0;
 
-    // Set to color white.
-    memset(buffer.mPlanes[0].mData, 255, sizeY);
-    memset(buffer.mPlanes[1].mData, 128, sizeCbCr);
-
     return VideoData::CreateAndCopyData(mInfo,
                                         mImageContainer,
                                         aSample->mOffset,
                                         aSample->mTime,
                                         aSample->mDuration,
                                         buffer,
                                         aSample->mKeyframe,
                                         aSample->mTime,