diff options
-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", |