Bug 1190939: Decode VP9 4:4:4 properly. r=jya
--- 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,