diff options
author | Roman Kiryanov <rkir@google.com> | 2019-04-15 15:33:09 -0700 |
---|---|---|
committer | Roman Kiryanov <rkir@google.com> | 2019-04-16 09:34:06 -0700 |
commit | 76835be663b5a1723d7134bfb9fca58b0ed2a4e8 (patch) | |
tree | 20adea706480a3d24d21093c2d3a4aee208d22e8 | |
parent | 3624615bc01fd9c3ef81d3324cf6a11ee0cfc630 (diff) | |
download | goldfish-opengl-76835be663b5a1723d7134bfb9fca58b0ed2a4e8.tar.gz |
Mark YUV camera buffers as interleaved
HAL_PIXEL_FORMAT_YCbCr_420_888 does not specify the exact
buffer layout. EmulatedFakeCamera3.cpp uses interleaved
UV planes, while other places place them separately.
Bug: 130295800
Bug: 129974968
Test: run cts -m CtsCameraTestCases \
-t android.hardware.camera2.cts.ImageReaderTest#teutYUVResolutions
Merged-In: If3a495aa794d9ab09288b7b92be7258a07cc077d
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: I33f6777b5cca6f4fa0c61ac3db994230d6b6efb0
-rw-r--r-- | shared/OpenglCodecCommon/gralloc_cb.h | 3 | ||||
-rw-r--r-- | system/gralloc/gralloc.cpp | 29 |
2 files changed, 24 insertions, 8 deletions
diff --git a/shared/OpenglCodecCommon/gralloc_cb.h b/shared/OpenglCodecCommon/gralloc_cb.h index 927c820f..ee4bd9a2 100644 --- a/shared/OpenglCodecCommon/gralloc_cb.h +++ b/shared/OpenglCodecCommon/gralloc_cb.h @@ -31,7 +31,8 @@ enum EmulatorFrameworkFormat { FRAMEWORK_FORMAT_GL_COMPATIBLE = 0, FRAMEWORK_FORMAT_YV12 = 1, - FRAMEWORK_FORMAT_YUV_420_888 = 2, + FRAMEWORK_FORMAT_YUV_420_888 = 2, // (Y+)(U+)(V+) + FRAMEWORK_FORMAT_YUV_420_888_INTERLEAVED = 3, // (Y+)(UV)+ }; // diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp index 3706bc68..aace8e3f 100644 --- a/system/gralloc/gralloc.cpp +++ b/system/gralloc/gralloc.cpp @@ -622,7 +622,13 @@ static int gralloc_alloc(alloc_device_t* dev, // We are going to use RGB888 on the host glFormat = GL_RGB; glType = GL_UNSIGNED_BYTE; - selectedEmuFrameworkFormat = FRAMEWORK_FORMAT_YUV_420_888; + + if (usage & (GRALLOC_USAGE_HW_CAMERA_READ | GRALLOC_USAGE_HW_CAMERA_WRITE)) { + // EmulatedFakeCamera3.cpp assumes it is NV21 + selectedEmuFrameworkFormat = FRAMEWORK_FORMAT_YUV_420_888_INTERLEAVED; + } else { + selectedEmuFrameworkFormat = FRAMEWORK_FORMAT_YUV_420_888; + } break; default: ALOGE("gralloc_alloc: Unknown format %d", format); @@ -1360,12 +1366,21 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, cStep = 1; break; case HAL_PIXEL_FORMAT_YCbCr_420_888: - yStride = cb->width; - cStride = yStride / 2; - yOffset = 0; - uOffset = cb->height * yStride; - vOffset = uOffset + cStride * cb->height / 2; - cStep = 1; + if (cb->emuFrameworkFormat == FRAMEWORK_FORMAT_YUV_420_888_INTERLEAVED) { + yStride = cb->width; + cStride = cb->width; + yOffset = 0; + vOffset = yStride * cb->height; + uOffset = vOffset + 1; + cStep = 2; + } else { + yStride = cb->width; + cStride = yStride / 2; + yOffset = 0; + uOffset = cb->height * yStride; + vOffset = uOffset + cStride * cb->height / 2; + cStep = 1; + } break; default: ALOGE("gralloc_lock_ycbcr unexpected internal format %x", |