Bug 1215089 - P1: Properly use frame dimensions to determine planes divisors. r?jgilbert draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 04 Oct 2017 23:26:42 +0200
changeset 675218 d89983dbc33c0d8700560cb890d0dc3cf9a5c62f
parent 672296 e6c32278f32cd5f7d159627b2157396b62d0c4a9
child 675219 1d1bad59d33c90154a7924e2e8eb85f90d432d97
push id83072
push userbmo:jyavenard@mozilla.com
push dateThu, 05 Oct 2017 01:30:32 +0000
reviewersjgilbert
bugs1215089
milestone58.0a1
Bug 1215089 - P1: Properly use frame dimensions to determine planes divisors. r?jgilbert There's no guarantee that the stride of the uv planes is twice as wide as the y plane's stride. This relationship is only true between the planes' width. MozReview-Commit-ID: JInge1c86Z1
gfx/gl/GLBlitHelper.cpp
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -696,25 +696,23 @@ GLBlitHelper::BlitImage(layers::PlanarYC
                            << yuvData->mYSize.height << ", "
                            << yuvData->mCbCrSize.width << ","
                            << yuvData->mCbCrSize.height << ", "
                            << yuvData->mYStride << ","
                            << yuvData->mCbCrStride;
         return false;
     }
 
-    const gfx::IntSize yTexSize(yuvData->mYStride, yuvData->mYSize.height);
-    const gfx::IntSize uvTexSize(yuvData->mCbCrStride, yuvData->mCbCrSize.height);
     gfx::IntSize divisors;
-    if (!GuessDivisors(yTexSize, uvTexSize, &divisors)) {
+    if (!GuessDivisors(yuvData->mYSize, yuvData->mCbCrSize, &divisors)) {
         gfxCriticalError() << "GuessDivisors failed:"
-                           << yTexSize.width << ","
-                           << yTexSize.height << ", "
-                           << uvTexSize.width << ","
-                           << uvTexSize.height;
+                           << yuvData->mYSize.width << ","
+                           << yuvData->mYSize.height << ", "
+                           << yuvData->mCbCrSize.width << ","
+                           << yuvData->mCbCrSize.height;
         return false;
     }
 
     // --
 
     // RED textures aren't valid in GLES2, and ALPHA textures are not valid in desktop GL Core Profiles.
     // So use R8 textures on GL3.0+ and GLES3.0+, but LUMINANCE/LUMINANCE/UNSIGNED_BYTE otherwise.
     GLenum internalFormat;
@@ -728,16 +726,18 @@ GLBlitHelper::BlitImage(layers::PlanarYC
         internalFormat = LOCAL_GL_LUMINANCE;
         unpackFormat = LOCAL_GL_LUMINANCE;
     }
 
     // --
 
     const ScopedSaveMultiTex saveTex(mGL, 3, LOCAL_GL_TEXTURE_2D);
     const ResetUnpackState reset(mGL);
+    const gfx::IntSize yTexSize(yuvData->mYStride, yuvData->mYSize.height);
+    const gfx::IntSize uvTexSize(yuvData->mCbCrStride, yuvData->mCbCrSize.height);
 
     if (yTexSize != mYuvUploads_YSize ||
         uvTexSize != mYuvUploads_UVSize)
     {
         mYuvUploads_YSize = yTexSize;
         mYuvUploads_UVSize = uvTexSize;
 
         mGL->fActiveTexture(LOCAL_GL_TEXTURE0);