Bug 1190939: Decode VP9 4:4:4 properly. r=jya
authorJan Gerber <j@mailb.org>
Tue, 25 Aug 2015 20:37:43 +0200
changeset 279699 13bed93876f2
parent 279698 a9f9b36c1a2e
child 279700 ecd38844bce6
push id70189
push userjyavenard@mozilla.com
push date2016-01-13 09:12 +0000
Treeherderresults
reviewersjya
bugs1190939
milestone46.0a1
Bug 1190939: Decode VP9 4:4:4 properly. r=jya
dom/media/platforms/agnostic/VPXDecoder.cpp
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp
+++ b/dom/media/platforms/agnostic/VPXDecoder.cpp
@@ -109,38 +109,53 @@ VPXDecoder::DoDecodeFrame(MediaRawData* 
     LOG("VPX Decode error: %s", vpx_codec_err_to_string(r));
     return -1;
   }
 
   vpx_codec_iter_t  iter = nullptr;
   vpx_image_t      *img;
 
   while ((img = vpx_codec_get_frame(&mVPX, &iter))) {
-    NS_ASSERTION(img->fmt == VPX_IMG_FMT_I420, "WebM image format not I420");
+    NS_ASSERTION(img->fmt == VPX_IMG_FMT_I420 ||
+                 img->fmt == VPX_IMG_FMT_I444,
+                 "WebM image format not I420 or I444");
 
     // Chroma shifts are rounded down as per the decoding examples in the SDK
     VideoData::YCbCrBuffer b;
     b.mPlanes[0].mData = img->planes[0];
     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[1].mData = img->planes[1];
     b.mPlanes[1].mStride = img->stride[1];
-    b.mPlanes[1].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
-    b.mPlanes[1].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
     b.mPlanes[1].mOffset = b.mPlanes[1].mSkip = 0;
 
     b.mPlanes[2].mData = img->planes[2];
     b.mPlanes[2].mStride = img->stride[2];
-    b.mPlanes[2].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
-    b.mPlanes[2].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
     b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0;
 
+    if (img->fmt == VPX_IMG_FMT_I420) {
+      b.mPlanes[1].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
+      b.mPlanes[1].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
+
+      b.mPlanes[2].mHeight = (img->d_h + 1) >> img->y_chroma_shift;
+      b.mPlanes[2].mWidth = (img->d_w + 1) >> img->x_chroma_shift;
+    } else if (img->fmt == VPX_IMG_FMT_I444) {
+      b.mPlanes[1].mHeight = img->d_h;
+      b.mPlanes[1].mWidth = img->d_w;
+
+      b.mPlanes[2].mHeight = img->d_h;
+      b.mPlanes[2].mWidth = img->d_w;
+    } else {
+      LOG("VPX Unknown image format");
+      return -1;
+    }
+
     VideoInfo info;
     info.mDisplay = mInfo.mDisplay;
     RefPtr<VideoData> v = VideoData::Create(info,
                                               mImageContainer,
                                               aSample->mOffset,
                                               aSample->mTime,
                                               aSample->mDuration,
                                               b,