Bug 1160689 - thumbnail image corruption on certain videos. r=sotaro
authorDiego Wilson <dwilson@quicinc.com>
Mon, 04 May 2015 15:14:34 -0700
changeset 261653 819c760b572fa8d2a00a3d50102a264232e35fb6
parent 261652 5b146d08b2c59b69bd7349b1a1e79355886b29a2
child 261654 5ae4aaad2fe960ad4cd97a00198e84c32b081cfb
push id1910
push userdrno@ohlmeier.org
push dateWed, 06 May 2015 22:39:15 +0000
reviewerssotaro
bugs1160689
milestone40.0a1
Bug 1160689 - thumbnail image corruption on certain videos. r=sotaro
gfx/layers/GrallocImages.cpp
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -293,16 +293,17 @@ ConvertOmxYUVFormatToRGB565(android::sp<
     return BAD_VALUE;
   }
 
   GraphicBufferAutoUnlock unlock(aBuffer);
 
   uint32_t format = aBuffer->getPixelFormat();
   uint32_t width = aSurface->GetSize().width;
   uint32_t height = aSurface->GetSize().height;
+  uint32_t stride = aBuffer->getStride();
 
   if (format == GrallocImage::HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO) {
     // The Adreno hardware decoder aligns image dimensions to a multiple of 32,
     // so we have to account for that here
     uint32_t alignedWidth = ALIGN(width, 32);
     uint32_t alignedHeight = ALIGN(height, 32);
     uint32_t uvOffset = ALIGN(alignedHeight * alignedWidth, 4096);
     uint32_t uvStride = 2 * ALIGN(width / 2, 32);
@@ -311,21 +312,21 @@ ConvertOmxYUVFormatToRGB565(android::sp<
                             buffer + uvOffset,
                             uvStride,
                             aMappedSurface->mData,
                             width, height);
     return OK;
   }
 
   if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) {
-    uint32_t uvOffset = height * width;
-    ConvertYVU420SPToRGB565(buffer, width,
+    uint32_t uvOffset = height * stride;
+    ConvertYVU420SPToRGB565(buffer, stride,
                             buffer + uvOffset + 1,
                             buffer + uvOffset,
-                            width,
+                            stride,
                             aMappedSurface->mData,
                             width, height);
     return OK;
   }
 
   if (format == HAL_PIXEL_FORMAT_YV12) {
     // Depend on platforms, it is possible for HW decoder to output YV12 format.
     // It means the mData won't be configured during the SetData API because the