add support for YUV formats
This commit is contained in:
parent
689fa73c06
commit
8bf1f75268
1 changed files with 38 additions and 18 deletions
|
@ -294,6 +294,25 @@ static int gralloc_alloc(alloc_device_t* dev,
|
|||
if (!pHandle || !pStride)
|
||||
return -EINVAL;
|
||||
|
||||
size_t size, stride;
|
||||
if (format == HAL_PIXEL_FORMAT_YCbCr_420_SP ||
|
||||
format == HAL_PIXEL_FORMAT_YCbCr_422_SP)
|
||||
{
|
||||
// FIXME: there is no way to return the vstride
|
||||
int vstride;
|
||||
stride = (w + 1) & ~1;
|
||||
switch (format) {
|
||||
case HAL_PIXEL_FORMAT_YCbCr_420_SP:
|
||||
size = stride * h * 2;
|
||||
break;
|
||||
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
|
||||
vstride = (h+1) & ~1;
|
||||
size = (stride * vstride) + (w/2 * h/2) * 2;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
int align = 4;
|
||||
int bpp = 0;
|
||||
switch (format) {
|
||||
|
@ -309,10 +328,10 @@ static int gralloc_alloc(alloc_device_t* dev,
|
|||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
size_t bpr = (w*bpp + (align-1)) & ~(align-1);
|
||||
size_t size = bpr * h;
|
||||
size_t stride = bpr / bpp;
|
||||
size = bpr * h;
|
||||
stride = bpr / bpp;
|
||||
}
|
||||
|
||||
int err;
|
||||
if (usage & GRALLOC_USAGE_HW_FB) {
|
||||
|
@ -320,6 +339,7 @@ static int gralloc_alloc(alloc_device_t* dev,
|
|||
} else {
|
||||
err = gralloc_alloc_buffer(dev, size, usage, pHandle);
|
||||
}
|
||||
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue