diff options
author | Vikas Sajjan <vikas.sajjan@linaro.org> | 2013-04-17 19:15:09 +0530 |
---|---|---|
committer | Fahad Kunnathadi <fahad.k@linaro.org> | 2013-04-17 19:17:58 +0530 |
commit | 8c13d1ff7db246516c9fff208926aedcd14e0924 (patch) | |
tree | 52db8c1df02f984b4b7e2e0b0cb0baf122495233 | |
parent | 378fa719a208074c2a1b0a7c7b86c9abd79a1065 (diff) |
origen_quad: Enabled Video Hardware accelerationlinaro_android_4.2.2_origen_quad
The following patch enables video acceleration on orien_quad
Change-Id: Ia6fe6a95290fbe75c0d7369e7398a6dfc41c8b43
Signed-off-by: Vikas Sajjan <vikas.sajjan@linaro.org>
-rw-r--r-- | media/libstagefright/Android.mk | 11 | ||||
-rwxr-xr-x | media/libstagefright/OMXCodec.cpp | 174 |
2 files changed, 175 insertions, 10 deletions
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index faa0f315..c9295935 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -115,6 +115,17 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_CFLAGS += -Wno-multichar +ifeq ($(BOARD_USE_SAMSUNG_COLORFORMAT), true) +LOCAL_CFLAGS += -DUSE_SAMSUNG_COLORFORMAT +LOCAL_C_INCLUDES += vendor/samsung/origen_quad/proprietary/include +endif + +ifeq ($(BOARD_USE_V4L2), false) +ifeq ($(BOARD_USE_S3D_SUPPORT), true) +LOCAL_CFLAGS += -DS3D_SUPPORT +endif +endif + LOCAL_MODULE:= libstagefright LOCAL_MODULE_TAGS := optional diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 6b1d9651..32c24f5e 100755 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -44,8 +44,33 @@ #include "include/avc_utils.h" +#if defined(USE_SAMSUNG_COLORFORMAT) +#include "sec_format.h" +#endif + namespace android { +#if defined(USE_SAMSUNG_COLORFORMAT) +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; +#ifdef S3D_SUPPORT +static const int OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR = 0x7FC00003; +static const int OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL = 0x7FC00004; +static const int OMX_SEC_COLOR_FormatNV12Tiled_TB_LR = 0x7FC00005; +static const int OMX_SEC_COLOR_FormatNV12Tiled_TB_RL = 0x7FC00006; +static const int OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR = 0x7FC00007; +static const int OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL = 0x7FC00008; +static const int OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR = 0x7FC00009; +static const int OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL = 0x7FC0000A; +static const int OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR = 0x7FC0000B; +static const int OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL = 0x7FC0000C; +static const int OMX_SEC_COLOR_FormatYUV420Planar_TB_LR = 0x7FC0000D; +static const int OMX_SEC_COLOR_FormatYUV420Planar_TB_RL = 0x7FC0000E; +#endif +#endif + // Treat time out as an error if we have not received any output // buffers after 3 seconds. const static int64_t kBufferFilledEventTimeOutNs = 3000000000LL; @@ -691,6 +716,13 @@ status_t OMXCodec::setVideoPortFormatType( return err; } +#if defined(USE_SAMSUNG_COLORFORMAT) +#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) { @@ -710,8 +742,21 @@ static size_t getFrameSize( * this part in the future */ case OMX_COLOR_FormatAndroidOpaque: - return (width * height * 3) / 2; +#if defined(USE_SAMSUNG_COLORFORMAT) + case OMX_SEC_COLOR_FormatNV12TPhysicalAddress: + case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: +#endif + return (width * height * 3) / 2; +#if defined(USE_SAMSUNG_COLORFORMAT) + 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; @@ -1218,8 +1263,25 @@ status_t OMXCodec::setVideoOutputFormat( || format.eColorFormat == OMX_COLOR_FormatCbYCrY || format.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar - || format.eColorFormat == OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka); - + || format.eColorFormat == OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka +#if defined(USE_SAMSUNG_COLORFORMAT) + || format.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress + || format.eColorFormat == OMX_SEC_COLOR_FormatNV12Tiled +#endif + ); + +#if defined(USE_SAMSUNG_COLORFORMAT) + 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) || + !strcmp("OMX.SEC.VP8.Decoder", mComponentName)) { + if (mNativeWindow == NULL) + format.eColorFormat = OMX_COLOR_FormatYUV420Planar; + else + format.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; + } +#endif int32_t colorFormat; if (meta->findInt32(kKeyColorFormat, &colorFormat) && colorFormat != OMX_COLOR_FormatUnused @@ -1263,7 +1325,11 @@ status_t OMXCodec::setVideoOutputFormat( #if 1 // XXX Need a (much) better heuristic to compute input buffer sizes. +#if USE_SAMSUNG_COLORFORMAT + const size_t X = 64 * 8 * 1024; // const size_t X = 64 * 1024; +#else const size_t X = 64 * 1024; +#endif if (def.nBufferSize < X) { def.nBufferSize = X; } @@ -1709,11 +1775,54 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() { return err; } +#ifndef USE_SAMSUNG_COLORFORMAT 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: +#ifdef S3D_SUPPORT + case OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR: + case OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL: + case OMX_SEC_COLOR_FormatNV12Tiled_TB_LR: + case OMX_SEC_COLOR_FormatNV12Tiled_TB_RL: +#endif + eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_CUSTOM_YCbCr_420_SP_TILED; + break; + case OMX_COLOR_FormatYUV420SemiPlanar: +#ifdef S3D_SUPPORT + case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR: + case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL: + case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR: + case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL: +#endif + //eColorFormat = (OMX_COLOR_FORMATTYPE)HAL_PIXEL_FORMAT_YCbCr_420_SP; + eColorFormat = (OMX_COLOR_FORMATTYPE)(0x11); + break; +#ifdef S3D_SUPPORT + case OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR: + case OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL: + case OMX_SEC_COLOR_FormatYUV420Planar_TB_LR: + case OMX_SEC_COLOR_FormatYUV420Planar_TB_RL: +#endif + 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) { ALOGE("native_window_set_buffers_geometry failed: %s (%d)", @@ -3098,12 +3207,42 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) { CHECK(info->mMediaBuffer == NULL); info->mMediaBuffer = srcBuffer; - } else { - 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) { +#ifdef USE_SAMSUNG_COLORFORMAT + 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; + } +#endif + 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()); + } } int64_t lastBufferTimeUs; @@ -4021,7 +4160,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) { + } +#if defined(USE_SAMSUNG_COLORFORMAT) + 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"; |