gralloc: Report YUV plane info
The android_ycbcr structure in graphics.h is populated to give the luma and chroma addresses. Use the same structure to give this information to graphics via a gralloc perform call. Change-Id: Ib42866a9ea90873886dcb60a1aac6cb375292642
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
32166191ac
commit
b29fdfdd84
@@ -547,6 +547,71 @@ void getBufferAttributes(int width, int height, int format, int usage,
|
|||||||
size = getSize(format, width, height, alignedw, alignedh);
|
size = getSize(format, width, height, alignedw, alignedh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getYUVPlaneInfo(private_handle_t* hnd, struct android_ycbcr* ycbcr)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
size_t ystride, cstride;
|
||||||
|
memset(ycbcr->reserved, 0, sizeof(ycbcr->reserved));
|
||||||
|
|
||||||
|
// Get the chroma offsets from the handle width/height. We take advantage
|
||||||
|
// of the fact the width _is_ the stride
|
||||||
|
switch (hnd->format) {
|
||||||
|
//Semiplanar
|
||||||
|
case HAL_PIXEL_FORMAT_YCbCr_420_SP:
|
||||||
|
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
|
||||||
|
ystride = hnd->width;
|
||||||
|
cstride = hnd->width/2;
|
||||||
|
ycbcr->y = (void*)hnd->base;
|
||||||
|
ycbcr->cb = (void*)(hnd->base + ystride * hnd->height);
|
||||||
|
ycbcr->cr = (void*)(hnd->base + ystride * hnd->height + 1);
|
||||||
|
ycbcr->ystride = ystride;
|
||||||
|
ycbcr->cstride = cstride;
|
||||||
|
ycbcr->chroma_step = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
||||||
|
case HAL_PIXEL_FORMAT_YCrCb_422_SP:
|
||||||
|
case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO:
|
||||||
|
case HAL_PIXEL_FORMAT_NV21_ZSL:
|
||||||
|
case HAL_PIXEL_FORMAT_RAW_SENSOR:
|
||||||
|
ystride = hnd->width;
|
||||||
|
cstride = hnd->width/2;
|
||||||
|
ycbcr->y = (void*)hnd->base;
|
||||||
|
ycbcr->cr = (void*)(hnd->base + ystride * hnd->height);
|
||||||
|
ycbcr->cb = (void*)(hnd->base + ystride * hnd->height + 1);
|
||||||
|
ycbcr->ystride = ystride;
|
||||||
|
ycbcr->cstride = cstride;
|
||||||
|
ycbcr->chroma_step = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Planar
|
||||||
|
case HAL_PIXEL_FORMAT_YV12:
|
||||||
|
ystride = hnd->width;
|
||||||
|
cstride = hnd->width/2;
|
||||||
|
ycbcr->y = (void*)hnd->base;
|
||||||
|
ycbcr->cr = (void*)(hnd->base + ystride * hnd->height);
|
||||||
|
ycbcr->cb = (void*)(hnd->base + ystride * hnd->height +
|
||||||
|
cstride * hnd->height/2);
|
||||||
|
ycbcr->ystride = ystride;
|
||||||
|
ycbcr->cstride = cstride;
|
||||||
|
ycbcr->chroma_step = 1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
//Unsupported formats
|
||||||
|
case HAL_PIXEL_FORMAT_YCbCr_422_I:
|
||||||
|
case HAL_PIXEL_FORMAT_YCrCb_422_I:
|
||||||
|
case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
|
||||||
|
default:
|
||||||
|
ALOGD("%s: Invalid format passed: 0x%x", __FUNCTION__,
|
||||||
|
hnd->format);
|
||||||
|
err = -EINVAL;
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Allocate buffer from width, height and format into a
|
// Allocate buffer from width, height and format into a
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ int decideBufferHandlingMechanism(int format, const char *compositionUsed,
|
|||||||
// It is the responsibility of the caller to free the buffer
|
// It is the responsibility of the caller to free the buffer
|
||||||
int alloc_buffer(private_handle_t **pHnd, int w, int h, int format, int usage);
|
int alloc_buffer(private_handle_t **pHnd, int w, int h, int format, int usage);
|
||||||
void free_buffer(private_handle_t *hnd);
|
void free_buffer(private_handle_t *hnd);
|
||||||
|
int getYUVPlaneInfo(private_handle_t* pHnd, struct android_ycbcr* ycbcr);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ enum {
|
|||||||
GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE,
|
GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE,
|
||||||
GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES,
|
GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES,
|
||||||
GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE,
|
GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE,
|
||||||
|
GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GRALLOC_HEAP_MASK (GRALLOC_USAGE_PRIVATE_UI_CONTIG_HEAP |\
|
#define GRALLOC_HEAP_MASK (GRALLOC_USAGE_PRIVATE_UI_CONTIG_HEAP |\
|
||||||
|
|||||||
@@ -259,28 +259,8 @@ int gralloc_lock_ycbcr(gralloc_module_t const* module,
|
|||||||
{
|
{
|
||||||
private_handle_t* hnd = (private_handle_t*)handle;
|
private_handle_t* hnd = (private_handle_t*)handle;
|
||||||
int err = gralloc_map_and_invalidate(module, handle, usage);
|
int err = gralloc_map_and_invalidate(module, handle, usage);
|
||||||
size_t ystride, cstride;
|
if(!err)
|
||||||
if(!err) {
|
err = getYUVPlaneInfo(hnd, ycbcr);
|
||||||
//hnd->format holds our implementation defined format
|
|
||||||
//HAL_PIXEL_FORMAT_YCrCb_420_SP is the only one set right now.
|
|
||||||
switch (hnd->format) {
|
|
||||||
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
|
||||||
ystride = ALIGN(hnd->width, 16);
|
|
||||||
cstride = ALIGN(hnd->width, 16)/2;
|
|
||||||
ycbcr->y = (void*)hnd->base;
|
|
||||||
ycbcr->cr = (void*)(hnd->base + ystride * hnd->height);
|
|
||||||
ycbcr->cb = (void*)(hnd->base + ystride * hnd->height + 1);
|
|
||||||
ycbcr->ystride = ystride;
|
|
||||||
ycbcr->cstride = cstride;
|
|
||||||
ycbcr->chroma_step = 2;
|
|
||||||
memset(ycbcr->reserved, 0, sizeof(ycbcr->reserved));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ALOGD("%s: Invalid format passed: 0x%x", __FUNCTION__,
|
|
||||||
hnd->format);
|
|
||||||
err = -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,6 +427,15 @@ int gralloc_perform(struct gralloc_module_t const* module,
|
|||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO:
|
||||||
|
{
|
||||||
|
private_handle_t* hnd = va_arg(args, private_handle_t*);
|
||||||
|
android_ycbcr* ycbcr = va_arg(args, struct android_ycbcr *);
|
||||||
|
if (private_handle_t::validate(hnd)) {
|
||||||
|
res = getYUVPlaneInfo(hnd, ycbcr);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user