summaryrefslogtreecommitdiffstats
path: root/sec_mm
diff options
context:
space:
mode:
authorSeungBeom Kim <sbcrux.kim@samsung.com>2011-07-28 10:59:05 +0900
committerJames Dong <jdong@google.com>2011-08-04 10:10:24 -0700
commitcf996c94402fdce75ca9a9255e285784fd3487bc (patch)
tree88dd59d2edbd000ff8d13e30299911963f6aae29 /sec_mm
parent8f35b79e690080f07214f73080ec94ce2f47c1e1 (diff)
downloaddevice_samsung_crespo-cf996c94402fdce75ca9a9255e285784fd3487bc.zip
device_samsung_crespo-cf996c94402fdce75ca9a9255e285784fd3487bc.tar.gz
device_samsung_crespo-cf996c94402fdce75ca9a9255e285784fd3487bc.tar.bz2
Video decode component support gralloc color format.
That returns the current color format is a 0x100. But, It is not the normal way In terms of omx. (It is spec out) OMX spec is OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ I think.... I hope the color format is the value 0x7F000100. stagefright use the value(0x7F000100) after masking. ex) err = native_window_set_buffers_geometry( mNativeWindow.get(), def.format.video.nFrameWidth, def.format.video.nFrameHeight, (def.format.video.eColorFormat & 0x1FF)); Change-Id: If0578eb35338ff9bd8d0cf8cd8f1435af92aba04 Signed-off-by: SeungBeom Kim <sbcrux.kim@samsung.com>
Diffstat (limited to 'sec_mm')
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c1
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c81
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c54
-rw-r--r--sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h5
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp853
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h2
6 files changed, 515 insertions, 481 deletions
diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c b/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c
index 841ed70..dccdaa5 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c
+++ b/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c
@@ -66,6 +66,7 @@ inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
switch(secOutputPort->portDefinition.format.video.eColorFormat) {
case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
if (width && height)
secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
break;
diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c
index ca2f480..446af9a 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c
+++ b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c
@@ -459,6 +459,7 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_SetParameter(
case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420SemiPlanar:
case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
break;
default:
@@ -702,8 +703,7 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_GetExtensionIndex(
SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
*pIndexType = OMX_IndexVendorThumbnailMode;
ret = OMX_ErrorNone;
-#if 0
-// #ifdef USE_ANDROID_EXTENSION
+#ifdef USE_ANDROID_EXTENSION
} else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_ANB) == 0) {
*pIndexType = OMX_IndexParamEnableAndroidBuffers;
ret = OMX_ErrorNone;
@@ -883,9 +883,9 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
secOutputPort->cropRectangle.nHeight = imgResol.height - cropInfo.crop_top_offset - cropInfo.crop_bottom_offset;
/** Update Frame Size **/
- if((secInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) ||
- (secInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) {
- SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged");
+
+ if ((cropInfo.crop_left_offset != 0) || (cropInfo.crop_right_offset != 0) ||
+ (cropInfo.crop_top_offset != 0) || (cropInfo.crop_bottom_offset != 0)) {
/* change width and height information */
secInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
secInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
@@ -894,24 +894,32 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
SEC_UpdateFrameSize(pOMXComponent);
- /** Send Port Settings changed call back */
+ /** Send crop info call back */
(*(pSECComponent->pCallbacks->EventHandler))
(pOMXComponent,
pSECComponent->callbackData,
OMX_EventPortSettingsChanged, /* The command was completed */
OMX_DirOutput, /* This is the port index */
- 0,
+ OMX_IndexConfigCommonOutputCrop,
NULL);
- }
- if ((secOutputPort->cropRectangle.nWidth != secOutputPort->portDefinition.format.video.nFrameWidth) ||
- (secOutputPort->cropRectangle.nHeight != secOutputPort->portDefinition.format.video.nFrameHeight)) {
- /** Send crop info call back */
+ } else if((secInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) ||
+ (secInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged");
+ /* change width and height information */
+ secInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ secInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ secInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ secInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15));
+
+ SEC_UpdateFrameSize(pOMXComponent);
+
+ /** Send Port Settings changed call back */
(*(pSECComponent->pCallbacks->EventHandler))
(pOMXComponent,
pSECComponent->callbackData,
OMX_EventPortSettingsChanged, /* The command was completed */
OMX_DirOutput, /* This is the port index */
- OMX_IndexConfigCommonOutputCrop,
+ 0,
NULL);
}
@@ -958,8 +966,8 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
pH264Dec->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
status = SsbSipMfcDecGetOutBuf(pH264Dec->hMFCH264Handle.hMFCHandle, &outputInfo);
- bufWidth = (outputInfo.img_width + 15) & (~15);
- bufHeight = (outputInfo.img_height + 15) & (~15);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
if ((SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
(((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
@@ -977,26 +985,33 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
int imageSize = outputInfo.img_width * outputInfo.img_height;
SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
- void *pOutBuf = (void *)pOutputData->dataBuffer;
+ void *pOutputBuf[3];
+
+ pOutputBuf[0] = (void *)pOutputData->dataBuffer;
+ pOutputBuf[1] = (void *)pOutputData->dataBuffer + imageSize;
+ pOutputBuf[2] = (void *)pOutputData->dataBuffer + ((imageSize * 5) / 4);
-#if 0
-// #ifdef USE_ANDROID_EXTENSION
+#ifdef USE_ANDROID_EXTENSION
if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE) {
- pOutBuf = (void *)getVADDRfromANB
- (pOutputData->dataBuffer,
- (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
- (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight);
+ void *pVirAddrs[2];
+ getVADDRfromANB (pOutputData->dataBuffer,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pVirAddrs);
+ pOutputBuf[0] = pVirAddrs[0];
+ pOutputBuf[1] = pVirAddrs[1];
+ pOutputBuf[2] = pVirAddrs[1] + (imageSize / 4);
}
#endif
if ((pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE) &&
(pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress))
{
/* if use Post copy address structure */
- SEC_OSAL_Memcpy(pOutBuf, &frameSize, sizeof(frameSize));
- SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
- SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
- SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
- SEC_OSAL_Memcpy(pOutBuf + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0], &frameSize, sizeof(frameSize));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
} else {
switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
@@ -1004,13 +1019,13 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
{
SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420P out");
csc_tiled_to_linear(
- (unsigned char *)pOutBuf,
+ (unsigned char *)pOutputBuf[0],
(unsigned char *)outputInfo.YVirAddr,
outputInfo.img_width,
outputInfo.img_height);
csc_tiled_to_linear_deinterleave(
- (unsigned char *)pOutBuf + imageSize,
- (unsigned char *)pOutBuf + (imageSize * 5) / 4,
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)pOutputBuf[2],
(unsigned char *)outputInfo.CVirAddr,
outputInfo.img_width,
outputInfo.img_height >> 1);
@@ -1018,16 +1033,17 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
}
break;
case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
default:
{
SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420SP out");
csc_tiled_to_linear(
- (unsigned char *)pOutBuf,
+ (unsigned char *)pOutputBuf[0],
(unsigned char *)outputInfo.YVirAddr,
outputInfo.img_width,
outputInfo.img_height);
csc_tiled_to_linear(
- (unsigned char *)pOutBuf + imageSize,
+ (unsigned char *)pOutputBuf[1],
(unsigned char *)outputInfo.CVirAddr,
outputInfo.img_width,
outputInfo.img_height >> 1);
@@ -1036,8 +1052,7 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
break;
}
}
-#if 0
-//#ifdef USE_ANDROID_EXTENSION
+#ifdef USE_ANDROID_EXTENSION
if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE)
putVADDRtoANB(pOutputData->dataBuffer);
#endif
diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c
index 6555356..477983c 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c
+++ b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c
@@ -611,6 +611,7 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter(
case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420SemiPlanar:
case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
break;
default:
@@ -833,11 +834,13 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetExtensionIndex(
SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
*pIndexType = OMX_IndexVendorThumbnailMode;
ret = OMX_ErrorNone;
-#if 0
-//#ifdef USE_ANDROID_EXTENSION
+#ifdef USE_ANDROID_EXTENSION
} else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_ANB) == 0) {
*pIndexType = OMX_IndexParamEnableAndroidBuffers;
ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_GET_ANB) == 0) {
+ *pIndexType = OMX_IndexParamGetAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
} else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_USE_ANB) == 0) {
*pIndexType = OMX_IndexParamUseAndroidNativeBuffer;
ret = OMX_ErrorNone;
@@ -1121,25 +1124,34 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
int imageSize = outputInfo.img_width * outputInfo.img_height;
SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
- void *pOutputBuf = (void *)pOutputData->dataBuffer;
-#if 0
-//#ifdef USE_ANDROID_EXTENSION
+ void *pOutputBuf[3];
+
+ pOutputBuf[0] = (void *)pOutputData->dataBuffer;
+ pOutputBuf[1] = (void *)pOutputData->dataBuffer + imageSize;
+ pOutputBuf[2] = (void *)pOutputData->dataBuffer + ((imageSize * 5) / 4);
+
+#ifdef USE_ANDROID_EXTENSION
if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE) {
- pOutputBuf = (void *)getVADDRfromANB
- (pOutputData->dataBuffer,
- (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
- (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight);
+ void *pVirAddrs[2];
+ getVADDRfromANB(pOutputData->dataBuffer,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pVirAddrs);
+ pOutputBuf[0] = pVirAddrs[0];
+ pOutputBuf[1] = pVirAddrs[1];
+ pOutputBuf[2] = pVirAddrs[1] + (imageSize / 4);
+
}
#endif
if ((pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE) &&
(pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress))
{
/* if use Post copy address structure */
- SEC_OSAL_Memcpy(pOutputBuf, &frameSize, sizeof(frameSize));
- SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
- SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
- SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
- SEC_OSAL_Memcpy(pOutputBuf + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0], &frameSize, sizeof(frameSize));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
} else {
switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
@@ -1147,13 +1159,13 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
{
SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420P out");
csc_tiled_to_linear(
- (unsigned char *)pOutputBuf,
+ (unsigned char *)pOutputBuf[0],
(unsigned char *)outputInfo.YVirAddr,
outputInfo.img_width,
outputInfo.img_height);
csc_tiled_to_linear_deinterleave(
- (unsigned char *)pOutputBuf + imageSize,
- (unsigned char *)pOutputBuf + (imageSize * 5) / 4,
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)pOutputBuf[2],
(unsigned char *)outputInfo.CVirAddr,
outputInfo.img_width,
outputInfo.img_height >> 1);
@@ -1161,16 +1173,17 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
}
break;
case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
default:
{
SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420SP out");
csc_tiled_to_linear(
- (unsigned char *)pOutputBuf,
+ (unsigned char *)pOutputBuf[0],
(unsigned char *)outputInfo.YVirAddr,
outputInfo.img_width,
outputInfo.img_height);
csc_tiled_to_linear(
- (unsigned char *)pOutputBuf + imageSize,
+ (unsigned char *)pOutputBuf[1],
(unsigned char *)outputInfo.CVirAddr,
outputInfo.img_width,
outputInfo.img_height >> 1);
@@ -1179,8 +1192,7 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
break;
}
}
-#if 0
-//#ifdef USE_ANDROID_EXTENSION
+#ifdef USE_ANDROID_EXTENSION
if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE)
putVADDRtoANB(pOutputData->dataBuffer);
#endif
diff --git a/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h b/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h
index 66aa696..d25cde4 100644
--- a/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h
+++ b/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h
@@ -74,6 +74,7 @@ typedef enum _SEC_OMX_INDEXTYPE
OMX_IndexParamGetAndroidNativeBuffer = 0x7F000012,
#define SEC_INDEX_PARAM_USE_ANB "OMX.google.android.index.useAndroidNativeBuffer"
OMX_IndexParamUseAndroidNativeBuffer = 0x7F000013,
+ /* for Android Store Metadata Inbuffer */
#define SEC_INDEX_PARAM_STORE_METADATA_BUFFER "OMX.google.android.index.storeMetaDataInBuffers"
OMX_IndexParamStoreMetaDataBuffer = 0x7F000014,
@@ -106,7 +107,9 @@ typedef enum _SEC_OMX_TRANS_STATETYPE {
} SEC_OMX_TRANS_STATETYPE;
typedef enum _SEC_OMX_COLOR_FORMATTYPE {
- OMX_SEC_COLOR_FormatNV12TPhysicalAddress = 0x7F000001 /**< Reserved region for introducing Vendor Extensions */
+ OMX_SEC_COLOR_FormatNV12TPhysicalAddress = 0x7F000001, /**< Reserved region for introducing Vendor Extensions */
+ /* for Android Native Window */
+ OMX_SEC_COLOR_FormatANBYUV420SemiPlanar = 0x100
}SEC_OMX_COLOR_FORMATTYPE;
typedef enum _SEC_OMX_SUPPORTFORMAT_TYPE
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp
index d3ba70f..6fca837 100644
--- a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp
@@ -1,425 +1,428 @@
-/*
- *
- * Copyright 2010 Samsung Electronics S.LSI Co. LTD
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * @file SEC_OSAL_Buffer.c
- * @brief
- * @author SeungBeom Kim (sbcrux.kim@samsung.com)
- * Jinsung Yang (jsgood.yang@samsung.com)
- * @version 1.0.2
- * @history
- * 2011.5.15 : Create
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "SEC_OMX_Def.h"
-#include "SEC_OMX_Macros.h"
-#include "SEC_OSAL_Memory.h"
-#include "SEC_OSAL_Semaphore.h"
-#include "SEC_OSAL_Buffer.h"
-#include "SEC_OMX_Basecomponent.h"
-
-#define SEC_LOG_OFF
-#include "SEC_OSAL_Log.h"
-
-#ifdef __cplusplus
-}
-#endif
-
-#include <ui/android_native_buffer.h>
-#include <ui/GraphicBuffer.h>
-#include <ui/GraphicBufferMapper.h>
-#include <ui/Rect.h>
-#include <media/stagefright/HardwareAPI.h>
-#include <hardware/hardware.h>
-#include <media/stagefright/MetadataBufferType.h>
-
-using namespace android;
-
-
-struct AndroidNativeBuffersParams {
- OMX_U32 nSize;
- OMX_VERSIONTYPE nVersion;
- OMX_U32 nPortIndex;
-};
-
-#ifdef USE_ANDROID_EXTENSION
-OMX_ERRORTYPE checkVersionANB(OMX_PTR ComponentParameterStructure)
-{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_VERSIONTYPE* version = NULL;
-
-
- AndroidNativeBuffersParams *pANBP;
- pANBP = (AndroidNativeBuffersParams *)ComponentParameterStructure;
-
- version = (OMX_VERSIONTYPE*)((char*)pANBP + sizeof(OMX_U32));
- if (*((OMX_U32*)pANBP) <= sizeof(AndroidNativeBuffersParams)) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- if (version->s.nVersionMajor != VERSIONMAJOR_NUMBER ||
- version->s.nVersionMinor != VERSIONMINOR_NUMBER) {
- ret = OMX_ErrorVersionMismatch;
- goto EXIT;
- }
-
- ret = OMX_ErrorNone;
-
-EXIT:
- return ret;
-}
-
-OMX_U32 checkPortIndexANB(OMX_PTR ComponentParameterStructure)
-{
- AndroidNativeBuffersParams *pANBP;
- pANBP = (AndroidNativeBuffersParams *)ComponentParameterStructure;
-
- return pANBP->nPortIndex;
-}
-
-OMX_U32 getMetadataBufferType(const uint8_t *ptr)
-{
- return ptr[0] << 24 | ptr[1] << 16 | ptr[2] << 8 | ptr[3];
-}
-
-OMX_U32 getVADDRfromANB(OMX_PTR pUnreadableBuffer, OMX_U32 Width, OMX_U32 Height)
-{
- android_native_buffer_t *buf;
- void *readableBuffer;
- GraphicBufferMapper &mapper = GraphicBufferMapper::get();
- Rect bounds(Width, Height);
-
- FunctionIn();
-
- buf = (android_native_buffer_t *)pUnreadableBuffer;
- SEC_OSAL_Log(SEC_LOG_TRACE, "pUnreadableBuffer:0x%x, buf:0x%x, buf->handle:0x%x",
- pUnreadableBuffer, buf, buf->handle);
-
- if (0 != mapper.lock(buf->handle, GRALLOC_USAGE_SW_WRITE_OFTEN, bounds, &readableBuffer))
- return -1;
-
- FunctionOut();
-
- return (OMX_U32)readableBuffer;
-}
-
-OMX_U32 putVADDRtoANB(OMX_PTR pUnreadableBuffer)
-{
- android_native_buffer_t *buf;
- void *readableBuffer;
- int ret = 0;
- GraphicBufferMapper &mapper = GraphicBufferMapper::get();
-
- FunctionIn();
-
- buf = (android_native_buffer_t *)pUnreadableBuffer;
-
- FunctionOut();
-
- return mapper.unlock(buf->handle);
-}
-
-OMX_ERRORTYPE enableAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
-{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
- SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
- SEC_OMX_BASEPORT *pSECPort = NULL;
-
- EnableAndroidNativeBuffersParams *peanbp;
-
- FunctionIn();
-
- if (hComponent == NULL) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
- if (pOMXComponent->pComponentPrivate == NULL) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- peanbp = (EnableAndroidNativeBuffersParams *)ComponentParameterStructure;
- pSECPort = &pSECComponent->pSECPort[peanbp->nPortIndex];
-
- if (peanbp->enable == OMX_FALSE) {
- SEC_OSAL_Log(SEC_LOG_TRACE, "disable AndroidNativeBuffer");
- pSECPort->bUseAndroidNativeBuffer = OMX_FALSE;
- } else {
- SEC_OSAL_Log(SEC_LOG_TRACE, "enable AndroidNativeBuffer");
- pSECPort->bUseAndroidNativeBuffer = OMX_TRUE;
- }
-
- ret = OMX_ErrorNone;
-
-EXIT:
- FunctionOut();
-
- return ret;
-}
-
-OMX_ERRORTYPE getAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
-{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
- SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
- SEC_OMX_BASEPORT *pSECPort = NULL;
-
- GetAndroidNativeBufferUsageParams *pganbp;
-
- FunctionIn();
-
- pganbp = (GetAndroidNativeBufferUsageParams *)ComponentParameterStructure;
-
- pganbp->nUsage = GRALLOC_USAGE_SW_WRITE_OFTEN;
-
- ret = OMX_ErrorNone;
-
-EXIT:
- FunctionOut();
-
- return ret;
-}
-
-OMX_ERRORTYPE UseBufferANB(
- OMX_IN OMX_HANDLETYPE hComponent,
- OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
- OMX_IN OMX_U32 nPortIndex,
- OMX_IN OMX_PTR pAppPrivate,
- OMX_IN OMX_U32 nSizeBytes,
- OMX_IN OMX_U8 *pBuffer)
-{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
- SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
- SEC_OMX_BASEPORT *pSECPort = NULL;
- OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
- int i = 0;
-
- FunctionIn();
-
- if (hComponent == NULL) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
- if (pOMXComponent->pComponentPrivate == NULL) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
-
- pSECPort = &pSECComponent->pSECPort[nPortIndex];
- if (nPortIndex >= pSECComponent->portParam.nPorts) {
- ret = OMX_ErrorBadPortIndex;
- goto EXIT;
- }
- if (pSECPort->portState != OMX_StateIdle) {
- ret = OMX_ErrorIncorrectStateOperation;
- goto EXIT;
- }
-
- if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
- ret = OMX_ErrorBadPortIndex;
- goto EXIT;
- }
-
- temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
- if (temp_bufferHeader == NULL) {
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
-
- for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) {
- if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
- pSECPort->bufferHeader[i] = temp_bufferHeader;
- pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
- INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
- temp_bufferHeader->pBuffer = pBuffer;
- temp_bufferHeader->nAllocLen = nSizeBytes;
- temp_bufferHeader->pAppPrivate = pAppPrivate;
- if (nPortIndex == INPUT_PORT_INDEX)
- temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
- else
- temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
-
- pSECPort->assignedBufferNum++;
- if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) {
- pSECPort->portDefinition.bPopulated = OMX_TRUE;
- /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */
- SEC_OSAL_SemaphorePost(pSECPort->loadedResource);
- /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */
- }
- *ppBufferHdr = temp_bufferHeader;
- ret = OMX_ErrorNone;
- goto EXIT;
- }
- }
-
- SEC_OSAL_Free(temp_bufferHeader);
- ret = OMX_ErrorInsufficientResources;
-
-EXIT:
- FunctionOut();
-
- return ret;
-}
-
-OMX_ERRORTYPE useAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
-{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
- SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
- SEC_OMX_BASEPORT *pSECPort = NULL;
- OMX_U32 frameSize = 0;
- OMX_U32 bufWidth, bufHeight;
- UseAndroidNativeBufferParams *puanbp;
-
- FunctionIn();
-
- puanbp = (UseAndroidNativeBufferParams *)ComponentParameterStructure;
-
- OMX_PTR buffer = (void *)puanbp->nativeBuffer.get();
- android_native_buffer_t *buf = (android_native_buffer_t *)buffer;
- bufWidth = ((buf->width + 15) / 16) * 16;
- bufHeight = ((buf->height + 15) / 16) * 16;
- frameSize = (bufWidth * bufHeight * 3) / 2;
- SEC_OSAL_Log(SEC_LOG_TRACE, "buffer:0x%x, buf:0x%x, buf->handle:0x%x", buffer, buf, buf->handle);
-
- ret = UseBufferANB(hComponent, puanbp->bufferHeader, puanbp->nPortIndex,
- puanbp->pAppPrivate, frameSize, (OMX_U8 *)buffer);
-
-EXIT:
- FunctionOut();
-
- return ret;
-}
-
-OMX_ERRORTYPE enableStoreMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
-{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
- SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
- SEC_OMX_BASEPORT *pSECPort = NULL;
-
- StoreMetaDataInBuffersParams *pStoreMetaData;
-
- FunctionIn();
-
- if (hComponent == NULL) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
- if (pOMXComponent->pComponentPrivate == NULL) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- pStoreMetaData = (StoreMetaDataInBuffersParams*)ComponentParameterStructure;
- pSECPort = &pSECComponent->pSECPort[pStoreMetaData->nPortIndex];
-
- if (pStoreMetaData->bStoreMetaData == OMX_FALSE) {
- SEC_OSAL_Log(SEC_LOG_TRACE, "disable StoreMetaDataInBuffers");
- pSECPort->bStoreMetaDataInBuffer = OMX_FALSE;
- } else {
- SEC_OSAL_Log(SEC_LOG_TRACE, "enable StoreMetaDataInBuffers");
- pSECPort->bStoreMetaDataInBuffer = OMX_TRUE;
- }
-
-EXIT:
- FunctionOut();
-
- return ret;
-}
-
-OMX_ERRORTYPE preprocessMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_BYTE pInputDataBuffer, BUFFER_ADDRESS_INFO *pInputInfo)
-{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
- SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
- SEC_OMX_BASEPORT *pSECPort = NULL;
- OMX_U32 type = 0;
-
- FunctionIn();
-
- if (hComponent == NULL) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
- if (pOMXComponent->pComponentPrivate == NULL) {
- ret = OMX_ErrorBadParameter;
- goto EXIT;
- }
- pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
-
- type = getMetadataBufferType(pInputDataBuffer);
- if (type == kMetadataBufferTypeCameraSource) {
- SEC_OSAL_Memcpy(&pInputInfo->YPhyAddr, pInputDataBuffer + 4, sizeof(void *));
- SEC_OSAL_Memcpy(&pInputInfo->CPhyAddr, pInputDataBuffer + 4 + sizeof(void *), sizeof(void *));
- } else if (type == kMetadataBufferTypeGrallocSource){
-
- ret = OMX_ErrorNotImplemented;
- goto EXIT;
-
- OMX_PTR pUnreadableBuffer = NULL;
- OMX_PTR pReadableBuffer = NULL;
- OMX_PTR dstYAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YVirAddr;
- OMX_PTR dstCAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CVirAddr;
- SEC_OSAL_Memcpy(&pUnreadableBuffer, pInputDataBuffer + 4, sizeof(void *));
- pReadableBuffer = (OMX_PTR)getVADDRfromANB(pUnreadableBuffer,
- (OMX_U32)pSECPort->portDefinition.format.video.nFrameWidth,
- (OMX_U32)pSECPort->portDefinition.format.video.nFrameHeight);
-
-
- /**************************************/
- /* IMG CSC RGB to NV12(NV12T) */
- /**************************************/
- /*
- source : pReadableBuffer
- destination : dstYAddr, dstCAddr
- */
-
-
- putVADDRtoANB(pUnreadableBuffer);
-
- pInputInfo->YPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr;
- pInputInfo->CPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr;
- } else {
- ret = OMX_ErrorNotImplemented;
- goto EXIT;
- }
-
-EXIT:
- FunctionOut();
-
- return ret;
-}
-
-#endif
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OSAL_Buffer.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * Jinsung Yang (jsgood.yang@samsung.com)
+ * @version 1.0.2
+ * @history
+ * 2011.5.15 : Create
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SEC_OMX_Def.h"
+#include "SEC_OMX_Macros.h"
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Buffer.h"
+#include "SEC_OMX_Basecomponent.h"
+
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <ui/android_native_buffer.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/GraphicBufferMapper.h>
+#include <ui/Rect.h>
+#include <media/stagefright/HardwareAPI.h>
+#include <hardware/hardware.h>
+#include <media/stagefright/MetadataBufferType.h>
+
+using namespace android;
+
+
+struct AndroidNativeBuffersParams {
+ OMX_U32 nSize;
+ OMX_VERSIONTYPE nVersion;
+ OMX_U32 nPortIndex;
+};
+
+#ifdef USE_ANDROID_EXTENSION
+OMX_ERRORTYPE checkVersionANB(OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_VERSIONTYPE* version = NULL;
+
+
+ AndroidNativeBuffersParams *pANBP;
+ pANBP = (AndroidNativeBuffersParams *)ComponentParameterStructure;
+
+ version = (OMX_VERSIONTYPE*)((char*)pANBP + sizeof(OMX_U32));
+ if (*((OMX_U32*)pANBP) <= sizeof(AndroidNativeBuffersParams)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (version->s.nVersionMajor != VERSIONMAJOR_NUMBER ||
+ version->s.nVersionMinor != VERSIONMINOR_NUMBER) {
+ ret = OMX_ErrorVersionMismatch;
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ return ret;
+}
+
+OMX_U32 checkPortIndexANB(OMX_PTR ComponentParameterStructure)
+{
+ AndroidNativeBuffersParams *pANBP;
+ pANBP = (AndroidNativeBuffersParams *)ComponentParameterStructure;
+
+ return pANBP->nPortIndex;
+}
+
+OMX_U32 getMetadataBufferType(const uint8_t *ptr)
+{
+ return ptr[0] << 24 | ptr[1] << 16 | ptr[2] << 8 | ptr[3];
+}
+
+OMX_U32 getVADDRfromANB(OMX_PTR pUnreadableBuffer, OMX_U32 Width, OMX_U32 Height, void *pVirAddrs[])
+{
+ android_native_buffer_t *buf;
+ void *readableBuffer;
+ GraphicBufferMapper &mapper = GraphicBufferMapper::get();
+ Rect bounds(Width, Height);
+
+ FunctionIn();
+
+ buf = (android_native_buffer_t *)pUnreadableBuffer;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pUnreadableBuffer:0x%x, buf:0x%x, buf->handle:0x%x",
+ pUnreadableBuffer, buf, buf->handle);
+
+ if (0 != mapper.lock(buf->handle, GRALLOC_USAGE_SW_WRITE_OFTEN, bounds, pVirAddrs))
+ return -1;
+
+ FunctionOut();
+
+ return 0;
+}
+
+OMX_U32 putVADDRtoANB(OMX_PTR pUnreadableBuffer)
+{
+ android_native_buffer_t *buf;
+ void *readableBuffer;
+ int ret = 0;
+ GraphicBufferMapper &mapper = GraphicBufferMapper::get();
+
+ FunctionIn();
+
+ buf = (android_native_buffer_t *)pUnreadableBuffer;
+
+ FunctionOut();
+
+ return mapper.unlock(buf->handle);
+}
+
+OMX_ERRORTYPE enableAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ EnableAndroidNativeBuffersParams *peanbp;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ peanbp = (EnableAndroidNativeBuffersParams *)ComponentParameterStructure;
+ pSECPort = &pSECComponent->pSECPort[peanbp->nPortIndex];
+
+ if (peanbp->enable == OMX_FALSE) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disable AndroidNativeBuffer");
+ pSECPort->bUseAndroidNativeBuffer = OMX_FALSE;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "enable AndroidNativeBuffer");
+ pSECPort->bUseAndroidNativeBuffer = OMX_TRUE;
+ pSECPort->portDefinition.format.video.eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatANBYUV420SemiPlanar;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE getAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ GetAndroidNativeBufferUsageParams *pganbp;
+
+ FunctionIn();
+
+ pganbp = (GetAndroidNativeBufferUsageParams *)ComponentParameterStructure;
+
+ pganbp->nUsage = GRALLOC_USAGE_SW_WRITE_OFTEN;
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE UseBufferANB(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes,
+ OMX_IN OMX_U8 *pBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pSECPort = &pSECComponent->pSECPort[nPortIndex];
+ if (nPortIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ if (pSECPort->portState != OMX_StateIdle) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
+ if (temp_bufferHeader == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+
+ for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) {
+ if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
+ pSECPort->bufferHeader[i] = temp_bufferHeader;
+ pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
+ INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
+ temp_bufferHeader->pBuffer = pBuffer;
+ temp_bufferHeader->nAllocLen = nSizeBytes;
+ temp_bufferHeader->pAppPrivate = pAppPrivate;
+ if (nPortIndex == INPUT_PORT_INDEX)
+ temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
+ else
+ temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
+
+ pSECPort->assignedBufferNum++;
+ if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) {
+ pSECPort->portDefinition.bPopulated = OMX_TRUE;
+ /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */
+ SEC_OSAL_SemaphorePost(pSECPort->loadedResource);
+ /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */
+ }
+ *ppBufferHdr = temp_bufferHeader;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE useAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_U32 frameSize = 0;
+ OMX_U32 bufWidth, bufHeight;
+ UseAndroidNativeBufferParams *puanbp;
+
+ FunctionIn();
+
+ puanbp = (UseAndroidNativeBufferParams *)ComponentParameterStructure;
+
+ OMX_PTR buffer = (void *)puanbp->nativeBuffer.get();
+ android_native_buffer_t *buf = (android_native_buffer_t *)buffer;
+ bufWidth = ((buf->width + 15) / 16) * 16;
+ bufHeight = ((buf->height + 15) / 16) * 16;
+ frameSize = (bufWidth * bufHeight * 3) / 2;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "buffer:0x%x, buf:0x%x, buf->handle:0x%x", buffer, buf, buf->handle);
+
+ ret = UseBufferANB(hComponent, puanbp->bufferHeader, puanbp->nPortIndex,
+ puanbp->pAppPrivate, frameSize, (OMX_U8 *)buffer);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE enableStoreMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ StoreMetaDataInBuffersParams *pStoreMetaData;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pStoreMetaData = (StoreMetaDataInBuffersParams*)ComponentParameterStructure;
+ pSECPort = &pSECComponent->pSECPort[pStoreMetaData->nPortIndex];
+
+ if (pStoreMetaData->bStoreMetaData == OMX_FALSE) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disable StoreMetaDataInBuffers");
+ pSECPort->bStoreMetaDataInBuffer = OMX_FALSE;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "enable StoreMetaDataInBuffers");
+ pSECPort->bStoreMetaDataInBuffer = OMX_TRUE;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE preprocessMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_BYTE pInputDataBuffer, BUFFER_ADDRESS_INFO *pInputInfo)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_U32 type = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+
+ type = getMetadataBufferType(pInputDataBuffer);
+ if (type == kMetadataBufferTypeCameraSource) {
+ SEC_OSAL_Memcpy(&pInputInfo->YPhyAddr, pInputDataBuffer + 4, sizeof(void *));
+ SEC_OSAL_Memcpy(&pInputInfo->CPhyAddr, pInputDataBuffer + 4 + sizeof(void *), sizeof(void *));
+ } else if (type == kMetadataBufferTypeGrallocSource){
+
+ ret = OMX_ErrorNotImplemented;
+ goto EXIT;
+
+ OMX_PTR pUnreadableBuffer = NULL;
+ OMX_PTR pReadableBuffer = NULL;
+ void *pVirAddrs[2];
+ OMX_PTR dstYAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YVirAddr;
+ OMX_PTR dstCAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CVirAddr;
+ SEC_OSAL_Memcpy(&pUnreadableBuffer, pInputDataBuffer + 4, sizeof(void *));
+ pReadableBuffer = (OMX_PTR)getVADDRfromANB(pUnreadableBuffer,
+ (OMX_U32)pSECPort->portDefinition.format.video.nFrameWidth,
+ (OMX_U32)pSECPort->portDefinition.format.video.nFrameHeight,
+ pVirAddrs);
+
+
+ /**************************************/
+ /* IMG CSC RGB to NV12(NV12T) */
+ /**************************************/
+ /*
+ source : pReadableBuffer
+ destination : dstYAddr, dstCAddr
+ */
+
+
+ putVADDRtoANB(pUnreadableBuffer);
+
+ pInputInfo->YPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr;
+ pInputInfo->CPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr;
+ } else {
+ ret = OMX_ErrorNotImplemented;
+ goto EXIT;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+#endif
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h
index 7110d5a..3699c7d 100644
--- a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h
@@ -50,7 +50,7 @@ OMX_U32 getMetadataBufferType(const uint8_t *ptr);
OMX_ERRORTYPE enableAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure);
OMX_ERRORTYPE getAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure);
OMX_ERRORTYPE useAndroidNativeBuffer(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure);
-OMX_U32 getVADDRfromANB(OMX_PTR pUnreadableBuffer, OMX_U32 Width, OMX_U32 Height);
+OMX_U32 getVADDRfromANB(OMX_PTR pUnreadableBuffer, OMX_U32 Width, OMX_U32 Height, void *vaddress[]);
OMX_U32 putVADDRtoANB(OMX_PTR pUnreadableBuffer);
OMX_ERRORTYPE enableStoreMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_PTR ComponentParameterStructure);
OMX_ERRORTYPE preprocessMetaDataInBuffers(OMX_HANDLETYPE hComponent, OMX_BYTE pInputDataBuffer, BUFFER_ADDRESS_INFO *pInputInfo);