diff options
author | Annamalai Lakshmanan <annamalai.l@samsung.com> | 2012-02-28 20:39:06 +0100 |
---|---|---|
committer | codeworkx <daniel.hillenbrand@codeworkx.de> | 2012-02-28 20:39:06 +0100 |
commit | 01e4493cc72b509ee96126a824eec40d1c86adbb (patch) | |
tree | e20f46500c7c96389ef9a734febe3996f390760a | |
parent | e4052534bb749ff66e545b9b753aac75f1cbe6f3 (diff) | |
download | frameworks_base-01e4493cc72b509ee96126a824eec40d1c86adbb.zip frameworks_base-01e4493cc72b509ee96126a824eec40d1c86adbb.tar.gz frameworks_base-01e4493cc72b509ee96126a824eec40d1c86adbb.tar.bz2 |
[Exynos4] added support for samsung codec
Change-Id: I7ed5034ad847fe312fbe79624fa24e097dc547e8
-rw-r--r-- | include/ui/GraphicBuffer.h | 3 | ||||
-rw-r--r-- | include/ui/GraphicBufferAllocator.h | 3 | ||||
-rw-r--r-- | media/libstagefright/Android.mk | 3 | ||||
-rwxr-xr-x | media/libstagefright/OMXCodec.cpp | 135 | ||||
-rw-r--r-- | media/libstagefright/include/ColorFormat.h | 30 | ||||
-rw-r--r-- | services/surfaceflinger/Android.mk | 4 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 4 |
7 files changed, 179 insertions, 3 deletions
diff --git a/include/ui/GraphicBuffer.h b/include/ui/GraphicBuffer.h index 6ab01f4..2a18731 100644 --- a/include/ui/GraphicBuffer.h +++ b/include/ui/GraphicBuffer.h @@ -64,6 +64,9 @@ public: USAGE_HW_2D = GRALLOC_USAGE_HW_2D, USAGE_HW_COMPOSER = GRALLOC_USAGE_HW_COMPOSER, USAGE_HW_VIDEO_ENCODER = GRALLOC_USAGE_HW_VIDEO_ENCODER, +#ifdef SAMSUNG_CODEC_SUPPORT + USAGE_HW_FIMC1 = GRALLOC_USAGE_HW_FIMC1, +#endif USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK }; diff --git a/include/ui/GraphicBufferAllocator.h b/include/ui/GraphicBufferAllocator.h index dffa788..3682ea3 100644 --- a/include/ui/GraphicBufferAllocator.h +++ b/include/ui/GraphicBufferAllocator.h @@ -56,6 +56,9 @@ public: USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE, USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER, USAGE_HW_2D = GRALLOC_USAGE_HW_2D, +#ifdef SAMSUNG_CODEC_SUPPORT + USAGE_HW_FIMC1 = GRALLOC_USAGE_HW_FIMC1, +#endif USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK }; diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index 690deac..e578785 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -3,6 +3,9 @@ include $(CLEAR_VARS) include frameworks/base/media/libstagefright/codecs/common/Config.mk +ifeq ($(BOARD_HAVE_CODEC_SUPPORT),SAMSUNG_CODEC_SUPPORT) +LOCAL_CFLAGS += -DSAMSUNG_CODEC_SUPPORT +endif LOCAL_SRC_FILES:= \ ACodec.cpp \ AACExtractor.cpp \ diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 86b3fe4..c080b6c 100755 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -45,9 +45,19 @@ #include <OMX_Component.h> #include "include/avc_utils.h" +#ifdef SAMSUNG_CODEC_SUPPORT +#include "include/ColorFormat.h" +#endif namespace android { +#ifdef SAMSUNG_CODEC_SUPPORT +static const int OMX_SEC_COLOR_FormatNV12TPhysicalAddress = 0x7F000001; +static const int OMX_SEC_COLOR_FormatNV12LPhysicalAddress = 0x7F000002; +static const int OMX_SEC_COLOR_FormatNV12LVirtualAddress = 0x7F000003; +static const int OMX_SEC_COLOR_FormatNV12Tiled = 0x7FC00002; +#endif + // Treat time out as an error if we have not received any output // buffers after 3 seconds. const static int64_t kBufferFilledEventTimeOutNs = 3000000000LL; @@ -875,6 +885,12 @@ status_t OMXCodec::setVideoPortFormatType( return err; } +#ifdef SAMSUNG_CODEC_SUPPORT +#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13) +#define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5) +#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7) +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) +#endif static size_t getFrameSize( OMX_COLOR_FORMATTYPE colorFormat, int32_t width, int32_t height) { switch (colorFormat) { @@ -894,8 +910,21 @@ static size_t getFrameSize( * this part in the future */ case OMX_COLOR_FormatAndroidOpaque: +#ifdef SAMSUNG_CODEC_SUPPORT + case OMX_SEC_COLOR_FormatNV12TPhysicalAddress: + case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: +#endif return (width * height * 3) / 2; +#ifdef SAMSUNG_CODEC_SUPPORT + case OMX_SEC_COLOR_FormatNV12LVirtualAddress: + return ALIGN((ALIGN(width, 16) * ALIGN(height, 16)), 2048) + ALIGN((ALIGN(width, 16) * ALIGN(height >> 1, 8)), 2048); + + case OMX_SEC_COLOR_FormatNV12Tiled: + static unsigned int frameBufferYSise = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)); + static unsigned int frameBufferUVSise = ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height/2)); + return (frameBufferYSise + frameBufferUVSise); +#endif default: CHECK(!"Should not be here. Unsupported color format."); break; @@ -1403,7 +1432,23 @@ status_t OMXCodec::setVideoOutputFormat( || format.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar || format.eColorFormat == OMX_COLOR_FormatCbYCrY || format.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar - || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar); + || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar +#ifdef SAMSUNG_CODEC_SUPPORT + || format.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress + || format.eColorFormat == OMX_SEC_COLOR_FormatNV12Tiled +#endif + ); +#ifdef SAMSUNG_CODEC_SUPPORT + if (!strcmp("OMX.SEC.FP.AVC.Decoder", mComponentName) || + !strcmp("OMX.SEC.AVC.Decoder", mComponentName) || + !strcmp("OMX.SEC.MPEG4.Decoder", mComponentName) || + !strcmp("OMX.SEC.H263.Decoder", mComponentName)) { + if (mNativeWindow == NULL) + format.eColorFormat = OMX_COLOR_FormatYUV420Planar; + else + format.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; + } +#endif err = mOMX->setParameter( mNode, OMX_IndexParamVideoPortFormat, @@ -1841,13 +1886,34 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() { if (err != OK) { return err; } - +#ifndef SAMSUNG_CODEC_SUPPORT err = native_window_set_buffers_geometry( mNativeWindow.get(), def.format.video.nFrameWidth, def.format.video.nFrameHeight, def.format.video.eColorFormat); +#else + OMX_COLOR_FORMATTYPE eColorFormat; + + switch (def.format.video.eColorFormat) { + case OMX_SEC_COLOR_FormatNV12TPhysicalAddress: + eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED; + break; + case OMX_COLOR_FormatYUV420SemiPlanar: + eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YCbCr_420_SP; + break; + case OMX_COLOR_FormatYUV420Planar: + default: + eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YCbCr_420_P; + break; + } + err = native_window_set_buffers_geometry( + mNativeWindow.get(), + def.format.video.nFrameWidth, + def.format.video.nFrameHeight, + eColorFormat); +#endif if (err != 0) { LOGE("native_window_set_buffers_geometry failed: %s (%d)", strerror(-err), -err); @@ -1891,8 +1957,13 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() { } LOGV("native_window_set_usage usage=0x%lx", usage); +#ifndef SAMSUNG_CODEC_SUPPORT err = native_window_set_usage( mNativeWindow.get(), usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP); +#else + err = native_window_set_usage( + mNativeWindow.get(), usage | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP | GRALLOC_USAGE_HW_FIMC1 | GRALLOC_USAGE_HWC_HWOVERLAY); +#endif if (err != 0) { LOGE("native_window_set_usage failed: %s (%d)", strerror(-err), -err); return err; @@ -3238,11 +3309,47 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) { CHECK(info->mMediaBuffer == NULL); info->mMediaBuffer = srcBuffer; } else { +#ifndef SAMSUNG_CODEC_SUPPORT CHECK(srcBuffer->data() != NULL) ; memcpy((uint8_t *)info->mData + offset, (const uint8_t *)srcBuffer->data() + srcBuffer->range_offset(), srcBuffer->range_length()); +#else + OMX_PARAM_PORTDEFINITIONTYPE def; + InitOMXParams(&def); + def.nPortIndex = kPortIndexInput; + + status_t err = mOMX->getParameter(mNode, OMX_IndexParamPortDefinition, + &def, sizeof(def)); + CHECK_EQ(err, (status_t)OK); + + if (def.eDomain == OMX_PortDomainVideo) { + OMX_VIDEO_PORTDEFINITIONTYPE *videoDef = &def.format.video; + switch (videoDef->eColorFormat) { + case OMX_SEC_COLOR_FormatNV12LVirtualAddress: { + CHECK(srcBuffer->data() != NULL); + void *pSharedMem = (void *)(srcBuffer->data()); + memcpy((uint8_t *)info->mData + offset, + (const void *)&pSharedMem, sizeof(void *)); + break; + } + default: + CHECK(srcBuffer->data() != NULL); + memcpy((uint8_t *)info->mData + offset, + (const uint8_t *)srcBuffer->data() + + srcBuffer->range_offset(), + srcBuffer->range_length()); + break; + } + } else { + CHECK(srcBuffer->data() != NULL); + memcpy((uint8_t *)info->mData + offset, + (const uint8_t *)srcBuffer->data() + + srcBuffer->range_offset(), + srcBuffer->range_length()); + } +#endif } } @@ -4130,7 +4237,22 @@ static const char *colorFormatString(OMX_COLOR_FORMATTYPE type) { if (type == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) { return "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar"; - } else if (type == OMX_QCOM_COLOR_FormatYVU420SemiPlanar) { + } +#ifdef SAMSUNG_CODEC_SUPPORT + if (type == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) { + return "OMX_SEC_COLOR_FormatNV12TPhysicalAddress"; + } + if (type == OMX_SEC_COLOR_FormatNV12LPhysicalAddress) { + return "OMX_SEC_COLOR_FormatNV12LPhysicalAddress"; + } + if (type == OMX_SEC_COLOR_FormatNV12LVirtualAddress) { + return "OMX_SEC_COLOR_FormatNV12LVirtualAddress"; + } + if (type == OMX_SEC_COLOR_FormatNV12Tiled) { + return "OMX_SEC_COLOR_FormatNV12Tiled"; + } +#endif + else if (type == OMX_QCOM_COLOR_FormatYVU420SemiPlanar) { return "OMX_QCOM_COLOR_FormatYVU420SemiPlanar"; } else if (type < 0 || (size_t)type >= numNames) { return "UNKNOWN"; @@ -4571,6 +4693,13 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) { video_def->nFrameWidth, video_def->nFrameHeight); if (err == OK) { +#ifdef SAMSUNG_CODEC_SUPPORT + /* Hack GetConfig */ + rect.nLeft = 0; + rect.nTop = 0; + rect.nWidth = video_def->nFrameWidth; + rect.nHeight = video_def->nFrameHeight; +#endif CHECK_GE(rect.nLeft, 0); CHECK_GE(rect.nTop, 0); CHECK_GE(rect.nWidth, 0u); diff --git a/media/libstagefright/include/ColorFormat.h b/media/libstagefright/include/ColorFormat.h new file mode 100644 index 0000000..6b66a2b --- /dev/null +++ b/media/libstagefright/include/ColorFormat.h @@ -0,0 +1,30 @@ +/************************************************* + Author: Annamalai Lakshmanan + Added Color formats for Samsung OMX Decode +*************************************************/ + +enum { + HAL_PIXEL_FORMAT_YCbCr_422_P = 0x100, + HAL_PIXEL_FORMAT_YCbCr_420_P = 0x101, + HAL_PIXEL_FORMAT_YCbCr_420_I = 0x102, + HAL_PIXEL_FORMAT_CbYCrY_422_I = 0x103, + HAL_PIXEL_FORMAT_CbYCrY_420_I = 0x104, + HAL_PIXEL_FORMAT_YCbCr_420_SP = 0x105, + HAL_PIXEL_FORMAT_YCrCb_422_SP = 0x106, + // support custom format for zero copy + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP = 0x110, + HAL_PIXEL_FORMAT_CUSTOM_YCrCb_420_SP = 0x111, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED = 0x112, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_SP = 0x113, + HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_SP = 0x114, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_422_I = 0x115, + HAL_PIXEL_FORMAT_CUSTOM_YCrCb_422_I = 0x116, + HAL_PIXEL_FORMAT_CUSTOM_CbYCrY_422_I = 0x117, + HAL_PIXEL_FORMAT_CUSTOM_CrYCbY_422_I = 0x118, + HAL_PIXEL_FORMAT_CUSTOM_CbYCr_422_I = 0x11B, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_P_SBS_LR = 0x11C, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_P_SBS_RL = 0x11D, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_P_TB_LR = 0x11E, + HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_P_TB_RL = 0x11F, + HAL_PIXEL_FORMAT_CUSTOM_MAX +}; diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 930842e..fbd0f92 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -1,6 +1,10 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) +ifeq ($(BOARD_HAVE_CODEC_SUPPORT),SAMSUNG_CODEC_SUPPORT) +LOCAL_CFLAGS += -DSAMSUNG_CODEC_SUPPORT +endif + LOCAL_SRC_FILES:= \ Layer.cpp \ LayerBase.cpp \ diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 5b9ffbf..d414dd5 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -293,7 +293,11 @@ void Layer::onDraw(const Region& clip) const // if not everything below us is covered, we plug the holes! Region holes(clip.subtract(under)); if (!holes.isEmpty()) { +#ifdef SAMSUNG_CODEC_SUPPORT + clearWithOpenGL(holes, 0, 0, 0, 0); +#else clearWithOpenGL(holes, 0, 0, 0, 1); +#endif } return; } |