From 2f8e5dee3f300ae2f3f56959e5b52b13e4e57179 Mon Sep 17 00:00:00 2001 From: Lingfeng Yang Date: Fri, 5 Aug 2016 21:17:33 +0000 Subject: [PATCH] Revert "Make YUV_420_888 color correct" This reverts commit 627769df70a80f638ded32984118a62196afaafc. Change-Id: I25112dd7735446359c2493108635205eca31a662 --- system/gralloc/gralloc.cpp | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp index 542927b..69ea198 100644 --- a/system/gralloc/gralloc.cpp +++ b/system/gralloc/gralloc.cpp @@ -680,7 +680,7 @@ static signed clamp_rgb(signed value) { } 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); @@ -689,18 +689,9 @@ static void rgb565_to_yv12(char* dest, char* src, int width, int height, 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; @@ -841,10 +832,7 @@ static int gralloc_lock(gralloc_module_t const* module, 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; } } @@ -876,7 +864,7 @@ static int gralloc_lock(gralloc_module_t const* module, // 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); @@ -886,18 +874,9 @@ static void yv12_to_rgb565(char* dest, char* src, int width, int height, 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; @@ -965,11 +944,8 @@ static int gralloc_unlock(gralloc_module_t const* module, 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; @@ -997,9 +973,7 @@ static int gralloc_unlock(gralloc_module_t const* module, // 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; } @@ -1096,12 +1070,6 @@ static int gralloc_lock_ycbcr(gralloc_module_t const* module, 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", -- 2.11.0