Bug 1321076 - In the case of alpha, VPXDecoder uses overloaded CreateAndCopy that takes alpha plane. r=jya draft
authorkaro <kkoorts@mozilla.com>
Wed, 21 Dec 2016 15:21:35 +1300
changeset 452677 15da81910ab6909ba9659e1f5c7ea86e4d0ebaa4
parent 452676 fcde786d529f69ba6fe2a533e351a8b33afa1de7
child 540269 efc7d790f1224c00469a0fc7aca57194d17604ce
push id39448
push userbmo:kkoorts@mozilla.com
push dateThu, 22 Dec 2016 00:02:10 +0000
reviewersjya
bugs1321076
milestone53.0a1
Bug 1321076 - In the case of alpha, VPXDecoder uses overloaded CreateAndCopy that takes alpha plane. r=jya MozReview-Commit-ID: AIJxPRjGvrg
dom/media/platforms/agnostic/VPXDecoder.cpp
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp
+++ b/dom/media/platforms/agnostic/VPXDecoder.cpp
@@ -193,27 +193,48 @@ VPXDecoder::DoDecode(MediaRawData* aSamp
       b.mPlanes[2].mHeight = img->d_h;
       b.mPlanes[2].mWidth = img->d_w;
     } else {
       LOG("VPX Unknown image format");
       return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
                          RESULT_DETAIL("VPX Unknown image format"));
     }
 
-    RefPtr<VideoData> v =
-      VideoData::CreateAndCopyData(mInfo,
-                                   mImageContainer,
-                                   aSample->mOffset,
-                                   aSample->mTime,
-                                   aSample->mDuration,
-                                   b,
-                                   aSample->mKeyframe,
-                                   aSample->mTimecode,
-                                   mInfo.ScaledImageRect(img->d_w,
-                                                         img->d_h));
+    RefPtr<VideoData> v;
+    if (!img_alpha) {
+      v = VideoData::CreateAndCopyData(mInfo,
+                                       mImageContainer,
+                                       aSample->mOffset,
+                                       aSample->mTime,
+                                       aSample->mDuration,
+                                       b,
+                                       aSample->mKeyframe,
+                                       aSample->mTimecode,
+                                       mInfo.ScaledImageRect(img->d_w,
+                                                             img->d_h));
+    } else {
+      VideoData::YCbCrBuffer::Plane alpha_plane;
+      alpha_plane.mData = img_alpha->planes[0];
+      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;
+      v = VideoData::CreateAndCopyData(mInfo,
+                                       mImageContainer,
+                                       aSample->mOffset,
+                                       aSample->mTime,
+                                       aSample->mDuration,
+                                       b,
+                                       alpha_plane,
+                                       aSample->mKeyframe,
+                                       aSample->mTimecode,
+                                       mInfo.ScaledImageRect(img->d_w,
+                                                             img->d_h));
+
+    }
 
     if (!v) {
       LOG("Image allocation error source %ldx%ld display %ldx%ld picture %ldx%ld",
           img->d_w, img->d_h, mInfo.mDisplay.width, mInfo.mDisplay.height,
           mInfo.mImage.width, mInfo.mImage.height);
       return MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__);
     }
     mCallback->Output(v);