}
static void rgb565_to_yv12(char* dest, char* src, int width, int height,
- int left, int top, int right, int bottom, bool switchUV) {
+ int left, int top, int right, int bottom) {
int align = 16;
int yStride = (width + (align -1)) & ~(align-1);
int cStride = (yStride / 2 + (align - 1)) & ~(align-1);
uint16_t *rgb_ptr0 = (uint16_t *)src;
uint8_t *yv12_y0 = (uint8_t *)dest;
-
uint8_t *yv12_v0 = yv12_y0 + yStride * height;
uint8_t *yv12_u0 = yv12_v0 + cSize;
- // switchUV allows this function to take care of
- // cases where the U/V planes need to be switched,
- // such as with YUV_420_888.
- if (switchUV) {
- yv12_u0 = yv12_y0 + yStride * height;
- yv12_v0 = yv12_u0 + cSize;
- }
-
for (int j = top; j <= bottom; ++j) {
uint8_t *yv12_y = yv12_y0 + j * yStride;
uint8_t *yv12_v = yv12_v0 + (j/2) * cStride;
rcEnc->rcReadColorBuffer(rcEnc, cb->hostHandle,
0, 0, cb->width, cb->height, cb->glFormat, cb->glType, rgb_addr);
if (tmpBuf) {
- // 420_888 format is YV12 with U and V planes switched.
- bool switchUV = cb->frameworkFormat == HAL_PIXEL_FORMAT_YCbCr_420_888;
- rgb565_to_yv12((char*)cpu_addr, tmpBuf, cb->width, cb->height, l, t, l+w-1, t+h-1,
- switchUV);
+ rgb565_to_yv12((char*)cpu_addr, tmpBuf, cb->width, cb->height, l, t, l+w-1, t+h-1);
delete [] tmpBuf;
}
}
// YV12 is aka YUV420Planar, or YUV420p; the only difference is that YV12 has
// certain stride requirements for Y and UV respectively.
static void yv12_to_rgb565(char* dest, char* src, int width, int height,
- int left, int top, int right, int bottom, bool switchUV) {
+ int left, int top, int right, int bottom) {
DD("%s convert %d by %d", __func__, width, height);
int align = 16;
int yStride = (width + (align -1)) & ~(align-1);
uint16_t *rgb_ptr0 = (uint16_t *)dest;
uint8_t *yv12_y0 = (uint8_t *)src;
-
uint8_t *yv12_v0 = yv12_y0 + yStride * height;
uint8_t *yv12_u0 = yv12_v0 + cSize;
- // switchUV allows this function to take care of
- // cases where the U/V planes need to be switched,
- // such as with YUV_420_888.
- if (switchUV) {
- yv12_u0 = yv12_y0 + yStride * height;
- yv12_v0 = yv12_u0 + cSize;
- }
-
for (int j = top; j <= bottom; ++j) {
uint8_t *yv12_y = yv12_y0 + j * yStride;
uint8_t *yv12_v = yv12_v0 + (j/2) * cStride;
if (cb->frameworkFormat == HAL_PIXEL_FORMAT_YV12 ||
cb->frameworkFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) {
// bpp should be 2
- // 420_888 format is YV12 with U and V planes switched.
- bool switchUV = cb->frameworkFormat == HAL_PIXEL_FORMAT_YCbCr_420_888;
yv12_to_rgb565(tmpBuf, (char*)cpu_addr, cb->width, cb->height, cb->lockedLeft,
- cb->lockedTop, cb->lockedLeft+cb->lockedWidth-1, cb->lockedTop+cb->lockedHeight-1,
- switchUV);
+ cb->lockedTop, cb->lockedLeft+cb->lockedWidth-1, cb->lockedTop+cb->lockedHeight-1);
} else {
int dst_line_len = cb->lockedWidth * bpp;
int src_line_len = cb->width * bpp;
// for this format, we need to conver to RGB565 format
// before updating host
rgbBuf = new char[cb->width * cb->height * 2];
- bool switchUV = cb->frameworkFormat == HAL_PIXEL_FORMAT_YCbCr_420_888;
- yv12_to_rgb565(rgbBuf, (char*)cpu_addr, cb->width, cb->height, 0, 0, cb->width-1, cb->height-1,
- switchUV);
+ yv12_to_rgb565(rgbBuf, (char*)cpu_addr, cb->width, cb->height, 0, 0, cb->width-1, cb->height-1);
rgb_addr = rgbBuf;
}
vOffset = yStride * cb->height;
uOffset = vOffset + cSize;
cStep = 1;
-
- // 420_888 format will have the U/V switched.
- if (cb->format == HAL_PIXEL_FORMAT_YCbCr_420_888) {
- uOffset = yStride * cb->height;
- vOffset = uOffset + cSize;
- }
break;
default:
ALOGE("gralloc_lock_ycbcr unexpected internal format %x",