From 8994068ce6313470004ba94221ce2c0271f51413 Mon Sep 17 00:00:00 2001 From: Naomi Luis Date: Mon, 28 Nov 2011 10:58:01 -0800 Subject: [PATCH] libgralloc: Add HAL_PIXEL_FORMAT_NV12_ENCODEABLE format. Add HAL_PIXEL_FORMAT_NV12_ENCODEABLE which is the encoder specific format. Remove unused OEM formats from the gralloc. Change-Id: I787203cd96b597c881f0acc10b60ea2ab2ffe1ab --- libgralloc/gpu.cpp | 14 ++++++++------ libgralloc/gralloc_priv.h | 9 +-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp index 014c54b..8909b95 100755 --- a/libgralloc/gpu.cpp +++ b/libgralloc/gpu.cpp @@ -28,11 +28,6 @@ #include "memalloc.h" #include "alloc_controller.h" -static const int OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00; -static const int QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka = 0x7FA30C03; -static const int QOMX_INTERLACE_FLAG = 0x49283654; -static const int QOMX_3D_VIDEO_FLAG = 0x23784238; - using namespace gralloc; using android::sp; @@ -248,6 +243,7 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage, size = ALIGN( alignedw * alignedh, 8192); size += ALIGN( alignedw * ALIGN(h/2, 32), 8192); break; + case HAL_PIXEL_FORMAT_NV12_ENCODEABLE: case HAL_PIXEL_FORMAT_YCbCr_420_SP: case HAL_PIXEL_FORMAT_YCrCb_420_SP: case HAL_PIXEL_FORMAT_YV12: @@ -257,8 +253,14 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage, } alignedw = ALIGN(w, 16); alignedh = h; - size = alignedw*alignedh + + if (HAL_PIXEL_FORMAT_NV12_ENCODEABLE == colorFormat) { + // The encoder requires a 2K aligned chroma offset. + size = ALIGN(alignedw*alignedh, 2048) + + (ALIGN(alignedw/2, 16) * (alignedh/2))*2; + } else { + size = alignedw*alignedh + (ALIGN(alignedw/2, 16) * (alignedh/2))*2; + } size = ALIGN(size, 4096); break; diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h index ced31f6..5461ede 100644 --- a/libgralloc/gralloc_priv.h +++ b/libgralloc/gralloc_priv.h @@ -155,14 +155,7 @@ private: enum { /* OEM specific HAL formats */ - //HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x100, // defined in hardware.h - //HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x101, // defined in hardware.h - HAL_PIXEL_FORMAT_YCbCr_422_P = 0x102, - HAL_PIXEL_FORMAT_YCbCr_420_P = 0x103, - //HAL_PIXEL_FORMAT_YCbCr_422_I = 0x104, // defined in hardware.h - HAL_PIXEL_FORMAT_YCbCr_420_I = 0x105, - HAL_PIXEL_FORMAT_CbYCrY_422_I = 0x106, - HAL_PIXEL_FORMAT_CbYCrY_420_I = 0x107, + HAL_PIXEL_FORMAT_NV12_ENCODEABLE = 0x102, HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED = 0x108, HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x109, HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO = 0x10A,