Emulator gralloc: Support YV12
Bug: 6243944 Change-Id: I5f416ab0ae15143df422c0f79d91841984b4fabe
This commit is contained in:
@@ -236,7 +236,14 @@ static int gralloc_alloc(alloc_device_t* dev,
|
|||||||
glType = GL_UNSIGNED_BYTE;
|
glType = GL_UNSIGNED_BYTE;
|
||||||
break;
|
break;
|
||||||
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
||||||
bpp = 0; // Chroma-subsampled format has fractional bpp
|
align = 1;
|
||||||
|
bpp = 1; // per-channel bpp
|
||||||
|
yuv_format = true;
|
||||||
|
// Not expecting to actually create any GL surfaces for this
|
||||||
|
break;
|
||||||
|
case HAL_PIXEL_FORMAT_YV12:
|
||||||
|
align = 16;
|
||||||
|
bpp = 1; // per-channel bpp
|
||||||
yuv_format = true;
|
yuv_format = true;
|
||||||
// Not expecting to actually create any GL surfaces for this
|
// Not expecting to actually create any GL surfaces for this
|
||||||
break;
|
break;
|
||||||
@@ -254,9 +261,11 @@ static int gralloc_alloc(alloc_device_t* dev,
|
|||||||
// keep space for image on guest memory if SW access is needed
|
// keep space for image on guest memory if SW access is needed
|
||||||
// or if the camera is doing writing
|
// or if the camera is doing writing
|
||||||
if (yuv_format) {
|
if (yuv_format) {
|
||||||
// For NV21
|
size_t yStride = (w*bpp + (align - 1)) & ~(align-1);
|
||||||
ashmem_size += w * h * 3 / 2;
|
size_t uvStride = (yStride / 2 + (align - 1)) & ~(align-1);
|
||||||
stride = w;
|
size_t uvHeight = h / 2;
|
||||||
|
ashmem_size += yStride * h + 2 * (uvHeight * uvStride);
|
||||||
|
stride = yStride / bpp;
|
||||||
} else {
|
} else {
|
||||||
size_t bpr = (w*bpp + (align-1)) & ~(align-1);
|
size_t bpr = (w*bpp + (align-1)) & ~(align-1);
|
||||||
ashmem_size += (bpr * h);
|
ashmem_size += (bpr * h);
|
||||||
|
|||||||
Reference in New Issue
Block a user