libgralloc: Get appropriate width and height from metadata

Compute YUV plane info using buffer width and height from metadata for
UPDATE_BUFFER_GEOMETRY use case.

CRs-Fixed: 994771
Change-Id: Idb42b56be970942a79c07ceb337afa2f966e4fbc
This commit is contained in:
Ramkumar Radhakrishnan
2016-03-24 17:03:41 -07:00
parent b800f1b5b4
commit 790357e660

View File

@@ -726,8 +726,8 @@ void getBufferAttributes(int width, int height, int format, int usage,
size = getSize(format, width, height, usage, alignedw, alignedh);
}
void getYuvUbwcSPPlaneInfo(private_handle_t* hnd, int color_format,
struct android_ycbcr* ycbcr)
void getYuvUbwcSPPlaneInfo(uint64_t base, int width, int height,
int color_format, struct android_ycbcr* ycbcr)
{
// UBWC buffer has these 4 planes in the following sequence:
// Y_Meta_Plane, Y_Plane, UV_Meta_Plane, UV_Plane
@@ -735,8 +735,6 @@ void getYuvUbwcSPPlaneInfo(private_handle_t* hnd, int color_format,
unsigned int y_stride, y_height, y_size;
unsigned int c_meta_stride, c_meta_height, c_meta_size;
unsigned int alignment = 4096;
int width = hnd->width;
int height = hnd->height;
y_meta_stride = VENUS_Y_META_STRIDE(color_format, width);
y_meta_height = VENUS_Y_META_SCANLINES(color_format, height);
@@ -750,25 +748,23 @@ void getYuvUbwcSPPlaneInfo(private_handle_t* hnd, int color_format,
c_meta_height = VENUS_UV_META_SCANLINES(color_format, height);
c_meta_size = ALIGN((c_meta_stride * c_meta_height), alignment);
ycbcr->y = (void*)(hnd->base + y_meta_size);
ycbcr->cb = (void*)(hnd->base + y_meta_size + y_size + c_meta_size);
ycbcr->cr = (void*)(hnd->base + y_meta_size + y_size +
ycbcr->y = (void*)(base + y_meta_size);
ycbcr->cb = (void*)(base + y_meta_size + y_size + c_meta_size);
ycbcr->cr = (void*)(base + y_meta_size + y_size +
c_meta_size + 1);
ycbcr->ystride = y_stride;
ycbcr->cstride = VENUS_UV_STRIDE(color_format, width);
}
void getYuvSPPlaneInfo(private_handle_t* hnd, int bpp,
struct android_ycbcr* ycbcr)
void getYuvSPPlaneInfo(uint64_t base, int width, int height, int bpp,
struct android_ycbcr* ycbcr)
{
int width = hnd->width;
int height = hnd->height;
unsigned int ystride, cstride;
ystride = cstride = width * bpp;
ycbcr->y = (void*)hnd->base;
ycbcr->cb = (void*)(hnd->base + ystride * height);
ycbcr->cr = (void*)(hnd->base + ystride * height + 1);
ycbcr->y = (void*)base;
ycbcr->cb = (void*)(base + ystride * height);
ycbcr->cr = (void*)(base + ystride * height + 1);
ycbcr->ystride = ystride;
ycbcr->cstride = cstride;
ycbcr->chroma_step = 2 * bpp;
@@ -811,20 +807,22 @@ int getYUVPlaneInfo(private_handle_t* hnd, struct android_ycbcr* ycbcr)
case HAL_PIXEL_FORMAT_YCbCr_422_SP:
case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
case HAL_PIXEL_FORMAT_NV12_ENCODEABLE: //Same as YCbCr_420_SP_VENUS
getYuvSPPlaneInfo(hnd, 1, ycbcr);
getYuvSPPlaneInfo(hnd->base, width, height, 1, ycbcr);
break;
case HAL_PIXEL_FORMAT_YCbCr_420_P010:
getYuvSPPlaneInfo(hnd, 2, ycbcr);
getYuvSPPlaneInfo(hnd->base, width, height, 2, ycbcr);
break;
case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC:
getYuvUbwcSPPlaneInfo(hnd, COLOR_FMT_NV12_UBWC, ycbcr);
getYuvUbwcSPPlaneInfo(hnd->base, width, height,
COLOR_FMT_NV12_UBWC, ycbcr);
ycbcr->chroma_step = 2;
break;
case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC:
getYuvUbwcSPPlaneInfo(hnd, COLOR_FMT_NV12_BPP10_UBWC, ycbcr);
getYuvUbwcSPPlaneInfo(hnd->base, width, height,
COLOR_FMT_NV12_BPP10_UBWC, ycbcr);
ycbcr->chroma_step = 3;
break;
@@ -835,7 +833,7 @@ int getYUVPlaneInfo(private_handle_t* hnd, struct android_ycbcr* ycbcr)
case HAL_PIXEL_FORMAT_NV21_ZSL:
case HAL_PIXEL_FORMAT_RAW16:
case HAL_PIXEL_FORMAT_RAW10:
getYuvSPPlaneInfo(hnd, 1, ycbcr);
getYuvSPPlaneInfo(hnd->base, width, height, 1, ycbcr);
std::swap(ycbcr->cb, ycbcr->cr);
break;