diff --git a/gfx/layers/d3d9/ImageLayerD3D9.cpp b/gfx/layers/d3d9/ImageLayerD3D9.cpp index f10f87c7171e..eef6c6bf235c 100644 --- a/gfx/layers/d3d9/ImageLayerD3D9.cpp +++ b/gfx/layers/d3d9/ImageLayerD3D9.cpp @@ -269,23 +269,35 @@ PlanarYCbCrImageD3D9::SetData(const PlanarYCbCrImage::Data &aData) // YV24 format width_shift = 0; height_shift = 0; + mType = gfx::YV24; } else if (aData.mYSize.width / 2 == aData.mCbCrSize.width && aData.mYSize.height == aData.mCbCrSize.height) { // YV16 format width_shift = 1; height_shift = 0; + mType = gfx::YV16; } else if (aData.mYSize.width / 2 == aData.mCbCrSize.width && aData.mYSize.height / 2 == aData.mCbCrSize.height ) { // YV12 format width_shift = 1; height_shift = 1; + mType = gfx::YV12; } else { NS_ERROR("YCbCr format not supported"); } mData = aData; mData.mCbCrStride = mData.mCbCrSize.width = aData.mPicSize.width >> width_shift; + // Round up the values for width and height to make sure we sample enough data + // for the last pixel - See bug 590735 + if (width_shift && (aData.mPicSize.width & 1)) { + mData.mCbCrStride++; + mData.mCbCrSize.width++; + } mData.mCbCrSize.height = aData.mPicSize.height >> height_shift; + if (height_shift && (aData.mPicSize.height & 1)) { + mData.mCbCrSize.height++; + } mData.mYSize = aData.mPicSize; mData.mYStride = mData.mYSize.width; @@ -458,7 +470,7 @@ PlanarYCbCrImageD3D9::GetAsSurface() mData.mYStride, mData.mCbCrStride, imageSurface->Stride(), - gfx::YV12); + mType); return imageSurface.forget().get(); } diff --git a/gfx/layers/d3d9/ImageLayerD3D9.h b/gfx/layers/d3d9/ImageLayerD3D9.h index a21776519607..0ce25c147fba 100644 --- a/gfx/layers/d3d9/ImageLayerD3D9.h +++ b/gfx/layers/d3d9/ImageLayerD3D9.h @@ -129,6 +129,7 @@ public: nsRefPtr mCrTexture; nsRefPtr mCbTexture; PRPackedBool mHasData; + gfx::YUVType mType; }; diff --git a/gfx/layers/opengl/ImageLayerOGL.cpp b/gfx/layers/opengl/ImageLayerOGL.cpp index e9658b6427d8..405132cb7232 100644 --- a/gfx/layers/opengl/ImageLayerOGL.cpp +++ b/gfx/layers/opengl/ImageLayerOGL.cpp @@ -489,23 +489,35 @@ PlanarYCbCrImageOGL::SetData(const PlanarYCbCrImage::Data &aData) // YV24 format width_shift = 0; height_shift = 0; + mType = gfx::YV24; } else if (aData.mYSize.width / 2 == aData.mCbCrSize.width && aData.mYSize.height == aData.mCbCrSize.height) { // YV16 format width_shift = 1; height_shift = 0; + mType = gfx::YV16; } else if (aData.mYSize.width / 2 == aData.mCbCrSize.width && aData.mYSize.height / 2 == aData.mCbCrSize.height ) { // YV12 format width_shift = 1; height_shift = 1; + mType = gfx::YV16; } else { NS_ERROR("YCbCr format not supported"); } mData = aData; mData.mCbCrStride = mData.mCbCrSize.width = aData.mPicSize.width >> width_shift; + // Round up the values for width and height to make sure we sample enough data + // for the last pixel - See bug 590735 + if (width_shift && (aData.mPicSize.width & 1)) { + mData.mCbCrStride++; + mData.mCbCrSize.width++; + } mData.mCbCrSize.height = aData.mPicSize.height >> height_shift; + if (height_shift && (aData.mPicSize.height & 1)) { + mData.mCbCrSize.height++; + } mData.mYSize = aData.mPicSize; mData.mYStride = mData.mYSize.width; diff --git a/gfx/layers/opengl/ImageLayerOGL.h b/gfx/layers/opengl/ImageLayerOGL.h index e0d5b49d1226..287f72f4d3c5 100644 --- a/gfx/layers/opengl/ImageLayerOGL.h +++ b/gfx/layers/opengl/ImageLayerOGL.h @@ -40,6 +40,7 @@ #include "LayerManagerOGL.h" #include "ImageLayers.h" +#include "yuv_convert.h" #include "mozilla/Mutex.h" namespace mozilla { @@ -213,6 +214,7 @@ public: Data mData; gfxIntSize mSize; PRPackedBool mHasData; + gfx::YUVType mType; };