Bug 1060811 - PlanarYCbCrData contains null for color conversion if the output format of HW decoder is YV12. r=Sotaro
authorVincent Liu <vliu@mozilla.com>
Mon, 01 Sep 2014 13:52:03 +0800
changeset 203038 dc77ebda2445634ef5a45de79f27f4c978efaee1
parent 203037 764e8c5fe5981ba54b7b9f7efa609373d87349be
child 203039 4d991522bbe3bbc2067ab61989df09900794f223
push id27418
push userryanvm@gmail.com
push dateTue, 02 Sep 2014 18:33:17 +0000
treeherdermozilla-central@7753c52d5976 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersSotaro
bugs1060811
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1060811 - PlanarYCbCrData contains null for color conversion if the output format of HW decoder is YV12. r=Sotaro
gfx/layers/GrallocImages.cpp
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -312,21 +312,40 @@ ConvertOmxYUVFormatToRGB565(android::sp<
                             buffer + uvOffset,
                             width,
                             aMappedSurface->mData,
                             width, height);
     return OK;
   }
 
   if (format == HAL_PIXEL_FORMAT_YV12) {
-    gfx::ConvertYCbCrToRGB(aYcbcrData,
+    // 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
+    // yuv data has already stored in GraphicBuffer. Here we try to confgiure the
+    // mData if it doesn't contain valid configuration.
+    layers::PlanarYCbCrData ycbcrData = aYcbcrData;
+    if (!ycbcrData.mYChannel) {
+      ycbcrData.mYChannel     = buffer;
+      ycbcrData.mYSkip        = 0;
+      ycbcrData.mYStride      = aBuffer->getStride();
+      ycbcrData.mYSize        = aSurface->GetSize();
+      ycbcrData.mCbSkip       = 0;
+      ycbcrData.mCbCrSize     = aSurface->GetSize() / 2;
+      ycbcrData.mPicSize      = aSurface->GetSize();
+      ycbcrData.mCrChannel    = buffer + ycbcrData.mYStride * ycbcrData.mYSize.height;
+      ycbcrData.mCrSkip       = 0;
+      // Align to 16 bytes boundary
+      ycbcrData.mCbCrStride   = ((ycbcrData.mYStride / 2) + 15) & ~0x0F;
+      ycbcrData.mCbChannel    = ycbcrData.mCrChannel + (ycbcrData.mCbCrStride * ycbcrData.mCbCrSize.height);
+    }
+    gfx::ConvertYCbCrToRGB(ycbcrData,
                            aSurface->GetFormat(),
                            aSurface->GetSize(),
-                           aSurface->GetData(),
-                           aSurface->Stride());
+                           aMappedSurface->mData,
+                           aMappedSurface->mStride);
     return OK;
   }
 
   android::ColorConverter colorConverter((OMX_COLOR_FORMATTYPE)aOmxFormat,
                                          OMX_COLOR_Format16bitRGB565);
   if (!colorConverter.isValid()) {
     NS_WARNING("Invalid color conversion");
     return BAD_VALUE;