minigbm: Ensure DRM_FORMAT_YVU420_ANDROID meets Android requirements.
For HAL_PIXEL_FORMAT_YV12 (mapped to DRM_FORMAT_YVU420_ANDROID), it
needs to meet the following requirements:
- The vertical stride must equal to the buffer's height.
- The chroma stride is 16-byte aligned.
As a result, stop mapping DRM_FORMAT_FLEX_YCbCr_420_888 to
DRM_FORMAT_YVU420_ANDROID. The format is used for hardware decoding,
It has more restrictions on the alignments of the width or height.
Bug: b:31479749
Test: Run the testOtherVP8ImageReader and testGoogH264ImageReader of
android.media.cts.ImageReaderDecoderTest.
Change-Id: Id37f51115ed8b1937ca7d6e48abd809235b43fe4
Reviewed-on: https://chromium-review.googlesource.com/526758
Commit-Ready: Owen Lin <[email protected]>
Tested-by: Owen Lin <[email protected]>
Reviewed-by: Gurchetan Singh <[email protected]>
diff --git a/i915.c b/i915.c
index d1a1731..87bb438 100644
--- a/i915.c
+++ b/i915.c
@@ -271,20 +271,28 @@
else
bo->tiling = I915_TILING_Y;
- stride = drv_stride_from_format(format, width, 0);
- /*
- * Align the Y plane to 128 bytes so the chroma planes would be aligned
- * to 64 byte boundaries. This is an Intel HW requirement.
- */
- if (format == DRM_FORMAT_YVU420 || format == DRM_FORMAT_YVU420_ANDROID) {
- stride = ALIGN(stride, 128);
+ if (format == DRM_FORMAT_YVU420 || format == DRM_FORMAT_YVU420_ANDROID)
bo->tiling = I915_TILING_NONE;
- }
+
+ stride = drv_stride_from_format(format, width, 0);
ret = i915_align_dimensions(bo, bo->tiling, &stride, &height);
if (ret)
return ret;
+ /*
+ * Align the Y plane to 128 bytes so the chroma planes would be aligned
+ * to 64 byte boundaries. This is an Intel HW requirement.
+ */
+ if (format == DRM_FORMAT_YVU420)
+ stride = ALIGN(stride, 128);
+
+ /*
+ * HAL_PIXEL_FORMAT_YV12 requires that the buffer's height not be aligned.
+ */
+ if (format == DRM_FORMAT_YVU420_ANDROID)
+ height = bo->height;
+
drv_bo_from_format(bo, stride, height, format);
memset(&gem_create, 0, sizeof(gem_create));
@@ -424,7 +432,7 @@
/*HACK: See b/28671744 */
return DRM_FORMAT_XBGR8888;
case DRM_FORMAT_FLEX_YCbCr_420_888:
- return DRM_FORMAT_YVU420_ANDROID;
+ return DRM_FORMAT_YVU420;
default:
return format;
}