summaryrefslogtreecommitdiffstats
path: root/sec_mm
diff options
context:
space:
mode:
authorSeungBeom Kim <sbcrux.kim@samsung.com>2011-07-19 10:23:46 +0900
committerJames Dong <jdong@google.com>2011-07-25 17:39:50 -0700
commitdd600c91fc1bc564ae62ef945d67436fe2fb0451 (patch)
treead72255e4bdda4f81c8157d061861dd5c385d6af /sec_mm
parent40a09525b7c484764c64daa1ca663a314a1b6d31 (diff)
downloaddevice_samsung_crespo-dd600c91fc1bc564ae62ef945d67436fe2fb0451.zip
device_samsung_crespo-dd600c91fc1bc564ae62ef945d67436fe2fb0451.tar.gz
device_samsung_crespo-dd600c91fc1bc564ae62ef945d67436fe2fb0451.tar.bz2
Change SEC_OMX for Video Editor
1. Support Google ExtensionIndex. 2. Decode Component - Decode component return real YUV output data. - Video decode component support two output port color format. They are OMX_COLOR_FormatYUV420SemiPlanar(NV12) and OMX_COLOR_FormatYUV420Planar. Choose one of them under negotiation. - output port default color format is OMX_COLOR_FormatYUV420SemiPlanar(NV12). - Turn off the gralloc/graphic buffer since gralloc/graphic buffer allocator is unavailable 3. Encode Component - Encode component support real YUV input data. - Video encode component support two input port color format. They are OMX_COLOR_FormatYUV420SemiPlanar(NV12) and OMX_COLOR_FormatYUV420Planar. Choose one of them under negotiation. - input port default color format is OMX_COLOR_FormatYUV420SemiPlanar(NV12). - gralloc buffer is not support yet. (store meta data mode use physical address.) 4. Camera hal - Support metadata buffer mode TODO: 1. enable grallco/graphic buffer once the allocator is available 2. add support for gralloc-based metadata buffer support in video encoder component Change-Id: Ic8ba4f0230d6de77ffde7ddf1e2c9a3a5aeb806f Signed-off-by: SeungBeom Kim <sbcrux.kim@samsung.com>
Diffstat (limited to 'sec_mm')
-rw-r--r--sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c1
-rw-r--r--sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c4
-rw-r--r--sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h7
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c88
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk5
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c295
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk5
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c254
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c83
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk5
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c157
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c18
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk5
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c144
-rw-r--r--sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c26
-rw-r--r--sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Def.h100
-rw-r--r--sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h26
-rw-r--r--sec_mm/sec_omx/sec_osal/Android.mk15
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp426
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h63
-rw-r--r--sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h5
21 files changed, 1354 insertions, 378 deletions
diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c
index 024cf1c..4edbad1 100644
--- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c
+++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Basecomponent.c
@@ -1419,7 +1419,6 @@ OMX_ERRORTYPE SEC_OMX_BaseComponent_Constructor(
pOMXComponent->GetComponentVersion = &SEC_OMX_GetComponentVersion;
pOMXComponent->SendCommand = &SEC_OMX_SendCommand;
- pOMXComponent->GetConfig = &SEC_OMX_GetConfig;
pOMXComponent->GetExtensionIndex = &SEC_OMX_GetExtensionIndex;
pOMXComponent->GetState = &SEC_OMX_GetState;
pOMXComponent->SetCallbacks = &SEC_OMX_SetCallbacks;
diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c
index f42745d..97e00af 100644
--- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c
+++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.c
@@ -832,6 +832,8 @@ OMX_ERRORTYPE SEC_OMX_Port_Constructor(OMX_HANDLETYPE hComponent)
pSECInputPort->portDefinition.nBufferAlignment = 0;
pSECInputPort->markType.hMarkTargetComponent = NULL;
pSECInputPort->markType.pMarkData = NULL;
+ pSECInputPort->bUseAndroidNativeBuffer = OMX_FALSE;
+ pSECInputPort->bStoreMetaDataInBuffer = OMX_FALSE;
/* Output Port */
pSECOutputPort = &pSECPort[OUTPUT_PORT_INDEX];
@@ -940,6 +942,8 @@ OMX_ERRORTYPE SEC_OMX_Port_Constructor(OMX_HANDLETYPE hComponent)
pSECOutputPort->portDefinition.nBufferAlignment = 0;
pSECOutputPort->markType.hMarkTargetComponent = NULL;
pSECOutputPort->markType.pMarkData = NULL;
+ pSECOutputPort->bUseAndroidNativeBuffer = OMX_FALSE;
+ pSECOutputPort->bStoreMetaDataInBuffer = OMX_FALSE;
pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
diff --git a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h
index f38226b..bce2263 100644
--- a/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h
+++ b/sec_mm/sec_omx/sec_omx_component/common/SEC_OMX_Baseport.h
@@ -62,6 +62,8 @@ typedef struct _SEC_OMX_BASEPORT
OMX_BOOL bIsPortDisabled;
OMX_MARKTYPE markType;
+ OMX_CONFIG_RECTTYPE cropRectangle;
+
/* Tunnel Info */
OMX_HANDLETYPE tunneledComponent;
OMX_U32 tunneledPort;
@@ -70,6 +72,11 @@ typedef struct _SEC_OMX_BASEPORT
OMX_U32 tunnelFlags;
OMX_VIDEO_CONTROLRATETYPE eControlRate;
+
+ /* For Android Native Buffer */
+ OMX_BOOL bUseAndroidNativeBuffer;
+ /* For Android Store Meta Data inBuffer */
+ OMX_BOOL bStoreMetaDataInBuffer;
} SEC_OMX_BASEPORT;
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 48705c1..841ed70 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
@@ -34,15 +34,13 @@
#include "SEC_OMX_Vdec.h"
#include "SEC_OMX_Basecomponent.h"
#include "SEC_OSAL_Thread.h"
+#include "color_space_convertor.h"
#undef SEC_LOG_TAG
#define SEC_LOG_TAG "SEC_VIDEO_DEC"
#define SEC_LOG_OFF
#include "SEC_OSAL_Log.h"
-#define ONE_FRAME_OUTPUT /* only one frame output for Android */
-#define S5PC110_DECODE_OUT_DATA_BUFFER /* for Android s5pc110 0copy*/
-
inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
{
@@ -161,6 +159,8 @@ OMX_ERRORTYPE SEC_OMX_UseBuffer(
goto EXIT;
}
}
+
+ SEC_OSAL_Free(temp_bufferHeader);
ret = OMX_ErrorInsufficientResources;
EXIT:
@@ -257,6 +257,9 @@ OMX_ERRORTYPE SEC_OMX_AllocateBuffer(
goto EXIT;
}
}
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ SEC_OSAL_Free(temp_buffer);
ret = OMX_ErrorInsufficientResources;
EXIT:
@@ -607,10 +610,9 @@ OMX_ERRORTYPE SEC_OutputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent)
dataBuffer->dataValid =OMX_TRUE;
/* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */
/* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */
-#ifdef S5PC110_DECODE_OUT_DATA_BUFFER
pSECComponent->processData[OUTPUT_PORT_INDEX].dataBuffer = dataBuffer->bufferHeader->pBuffer;
pSECComponent->processData[OUTPUT_PORT_INDEX].allocSize = dataBuffer->bufferHeader->nAllocLen;
-#endif
+
SEC_OSAL_Free(message);
}
SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
@@ -816,13 +818,6 @@ OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent)
if (outputData->remainDataLen <= (outputUseBuffer->allocSize - outputUseBuffer->dataLen)) {
copySize = outputData->remainDataLen;
-#ifndef S5PC110_DECODE_OUT_DATA_BUFFER
- if (copySize > 0)
- SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen),
- (outputData->dataBuffer + outputData->usedDataLen),
- copySize);
-#endif
-
outputUseBuffer->dataLen += copySize;
outputUseBuffer->remainDataLen += copySize;
outputUseBuffer->nFlags = outputData->nFlags;
@@ -833,28 +828,13 @@ OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent)
/* reset outputData */
SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX);
-#ifdef ONE_FRAME_OUTPUT /* only one frame output for Android */
if ((outputUseBuffer->remainDataLen > 0) ||
(outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS))
SEC_OutputBufferReturn(pOMXComponent);
-#else
- if ((outputUseBuffer->remainDataLen > 0) ||
- ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) {
- SEC_OutputBufferReturn(pOMXComponent);
- } else {
- outputUseBuffer->dataValid = OMX_TRUE;
- }
-#endif
} else {
SEC_OSAL_Log(SEC_LOG_ERROR, "output buffer is smaller than decoded data size Out Length");
copySize = outputUseBuffer->allocSize - outputUseBuffer->dataLen;
-
-#ifndef S5PC110_DECODE_OUT_DATA_BUFFER
- SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen),
- (outputData->dataBuffer + outputData->usedDataLen),
- copySize);
-#endif
outputUseBuffer->dataLen += copySize;
outputUseBuffer->remainDataLen += copySize;
outputUseBuffer->nFlags = 0;
@@ -1063,19 +1043,19 @@ OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter(
portDefinition = &pSECPort->portDefinition;
switch (index) {
- case supportFormat_1:
+ case supportFormat_0:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
- case supportFormat_2:
+ case supportFormat_1:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
- case supportFormat_3:
+ case supportFormat_2:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12TPhysicalAddress;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
}
@@ -1103,6 +1083,20 @@ OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter(
ret = OMX_ErrorNone;
}
break;
+#ifdef USE_ANDROID_EXTENSION
+ case OMX_IndexParamGetAndroidNativeBuffer:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = getAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ }
+ break;
+#endif
default:
{
ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
@@ -1201,6 +1195,34 @@ OMX_ERRORTYPE SEC_OMX_VideoDecodeSetParameter(
ret = OMX_ErrorNone;
}
break;
+#ifdef USE_ANDROID_EXTENSION
+ case OMX_IndexParamEnableAndroidBuffers:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = enableAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ }
+ break;
+ case OMX_IndexParamUseAndroidNativeBuffer:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = useAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ }
+ break;
+#endif
default:
{
ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk
index cdf345c..516ee04 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk
+++ b/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk
@@ -14,8 +14,9 @@ LOCAL_CFLAGS :=
LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent libsecmfcdecapi libseccsc
-LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libsecmfcdecapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui
LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
$(SEC_OMX_INC)/sec \
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 2c5f3bb..ca2f480 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
@@ -454,10 +454,17 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_SetParameter(
pSECOutputPort->portDefinition.format.video.nFrameHeight = pSECPort->portDefinition.format.video.nFrameHeight;
pSECOutputPort->portDefinition.format.video.nStride = width;
pSECOutputPort->portDefinition.format.video.nSliceHeight = height;
- if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) {
+
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
- } else if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) {
- pSECOutputPort->portDefinition.nBufferSize = width * height * 2;
+ break;
+ default:
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Color format is not support!! use default YUV size!!");
+ ret = OMX_ErrorUnsupportedSetting;
+ break;
}
}
}
@@ -520,6 +527,84 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_H264Dec_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexConfigCommonOutputCrop:
+ {
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+ OMX_CONFIG_RECTTYPE *pSrcRectType = NULL;
+ OMX_CONFIG_RECTTYPE *pDstRectType = NULL;
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+
+ if (pH264Dec->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
+ ret = OMX_ErrorNotReady;
+ break;
+ }
+
+ pDstRectType = (OMX_CONFIG_RECTTYPE *)pComponentConfigStructure;
+
+ if ((pDstRectType->nPortIndex != INPUT_PORT_INDEX) &&
+ (pDstRectType->nPortIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[pDstRectType->nPortIndex];
+
+ pSrcRectType = &(pSECPort->cropRectangle);
+
+ pDstRectType->nTop = pSrcRectType->nTop;
+ pDstRectType->nLeft = pSrcRectType->nLeft;
+ pDstRectType->nHeight = pSrcRectType->nHeight;
+ pDstRectType->nWidth = pSrcRectType->nWidth;
+ }
+ break;
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_H264Dec_SetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
@@ -613,12 +698,22 @@ OMX_ERRORTYPE SEC_MFC_H264Dec_GetExtensionIndex(
goto EXIT;
}
- if (SEC_OSAL_Strcmp(cParameterName, "OMX.SEC.index.ThumbnailMode") == 0) {
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
-
*pIndexType = OMX_IndexVendorThumbnailMode;
-
ret = OMX_ErrorNone;
+#if 0
+// #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;
+#endif
} else {
ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
}
@@ -629,7 +724,6 @@ EXIT:
return ret;
}
-
OMX_ERRORTYPE SEC_MFC_H264Dec_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -769,6 +863,7 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
SSBSIP_MFC_IMG_RESOLUTION imgResol;
SSBSIP_MFC_CROP_INFORMATION cropInfo;
SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol);
SEC_OSAL_Log(SEC_LOG_TRACE, "set width height information : %d, %d",
@@ -782,16 +877,18 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
cropInfo.crop_top_offset , cropInfo.crop_bottom_offset ,
cropInfo.crop_left_offset , cropInfo.crop_right_offset);
- int actualWidth = imgResol.width - cropInfo.crop_left_offset - cropInfo.crop_right_offset;
- int actualHeight = imgResol.height - cropInfo.crop_top_offset - cropInfo.crop_bottom_offset;
+ secOutputPort->cropRectangle.nTop = cropInfo.crop_top_offset;
+ secOutputPort->cropRectangle.nLeft = cropInfo.crop_left_offset;
+ secOutputPort->cropRectangle.nWidth = imgResol.width - cropInfo.crop_left_offset - cropInfo.crop_right_offset;
+ secOutputPort->cropRectangle.nHeight = imgResol.height - cropInfo.crop_top_offset - cropInfo.crop_bottom_offset;
/** Update Frame Size **/
- if((secInputPort->portDefinition.format.video.nFrameWidth != actualWidth) ||
- (secInputPort->portDefinition.format.video.nFrameHeight != actualHeight)) {
+ 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 = actualWidth;
- secInputPort->portDefinition.format.video.nFrameHeight = actualHeight;
+ 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));
@@ -806,6 +903,17 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
0,
NULL);
}
+ if ((secOutputPort->cropRectangle.nWidth != secOutputPort->portDefinition.format.video.nFrameWidth) ||
+ (secOutputPort->cropRectangle.nHeight != secOutputPort->portDefinition.format.video.nFrameHeight)) {
+ /** Send crop info call back */
+ (*(pSECComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ OMX_IndexConfigCommonOutputCrop,
+ NULL);
+ }
pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_TRUE;
#ifdef ADD_SPS_PPS_I_FRAME
@@ -825,19 +933,15 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
#ifndef FULL_FRAME_SEARCH
if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
- (pSECComponent->bUseFlagEOF == OMX_FALSE)) {
+ (pSECComponent->bUseFlagEOF == OMX_FALSE))
pSECComponent->bUseFlagEOF = OMX_TRUE;
- }
#endif
- pSECComponent->timeStamp[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp;
- pSECComponent->nFlags[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->nFlags;
- SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pH264Dec->hMFCH264Handle.indexTimestamp));
- pH264Dec->hMFCH264Handle.indexTimestamp++;
- if (pH264Dec->hMFCH264Handle.indexTimestamp >= MAX_TIMESTAMP)
- pH264Dec->hMFCH264Handle.indexTimestamp = 0;
-
if (Check_H264_StartCode(pInputData->dataBuffer, pInputData->dataLen) == OMX_TRUE) {
+ pSECComponent->timeStamp[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pH264Dec->hMFCH264Handle.indexTimestamp));
+
returnCodec = SsbSipMfcDecExe(pH264Dec->hMFCH264Handle.hMFCHandle, oneFrameSize);
} else {
pOutputData->timeStamp = pInputData->timeStamp;
@@ -850,12 +954,15 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
SSBSIP_MFC_DEC_OUTBUF_STATUS status;
OMX_S32 indexTimestamp = 0;
+ pH264Dec->hMFCH264Handle.indexTimestamp++;
+ pH264Dec->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
+
status = SsbSipMfcDecGetOutBuf(pH264Dec->hMFCH264Handle.hMFCHandle, &outputInfo);
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)))) {
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -865,27 +972,92 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) ||
(status == MFC_GETOUTBUF_DISPLAY_ONLY)) {
- switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
- case OMX_COLOR_FormatYUV420Planar:
- case OMX_COLOR_FormatYUV420SemiPlanar:
+ /** Fill Output Buffer **/
+ int frameSize = bufWidth * bufHeight;
+ 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;
+
+#if 0
+// #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);
+ }
+#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));
pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
- break;
- default:
- pOutputData->dataLen = bufWidth * bufHeight * 2;
- break;
+ } else {
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420P out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutBuf,
+ (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 *)outputInfo.CVirAddr,
+ outputInfo.img_width,
+ outputInfo.img_height >> 1);
+ pOutputData->dataLen = (outputInfo.img_width * outputInfo.img_height) * 3 / 2;
+ }
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ default:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420SP out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutBuf,
+ (unsigned char *)outputInfo.YVirAddr,
+ outputInfo.img_width,
+ outputInfo.img_height);
+ csc_tiled_to_linear(
+ (unsigned char *)pOutBuf + imageSize,
+ (unsigned char *)outputInfo.CVirAddr,
+ outputInfo.img_width,
+ outputInfo.img_height >> 1);
+ pOutputData->dataLen = (outputInfo.img_width * outputInfo.img_height) * 3 / 2;
+ }
+ break;
+ }
}
+#if 0
+//#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE)
+ putVADDRtoANB(pOutputData->dataBuffer);
+#endif
}
if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
pOutputData->dataLen = 0;
if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) ||
- (pSECComponent->getAllDelayBuffer == OMX_TRUE)) {
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE))
ret = OMX_ErrorInputDataDecodeYet;
- }
if(status == MFC_GETOUTBUF_DECODING_ONLY) {
- /* ret = OMX_ErrorInputDataDecodeYet; */
- ret = OMX_ErrorNone;
+ if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) &&
+ (pSECComponent->bSaveFlagEOS == OMX_TRUE)) {
+ pInputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else {
+ ret = OMX_ErrorNone;
+ }
goto EXIT;
}
@@ -897,7 +1069,6 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
ret = OMX_ErrorInputDataDecodeYet;
} else
#endif
-
if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
pSECComponent->getAllDelayBuffer = OMX_TRUE;
@@ -909,67 +1080,20 @@ OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
} else {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
- switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
- case OMX_COLOR_FormatYUV420Planar:
- case OMX_COLOR_FormatYUV420SemiPlanar:
- pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
- break;
- default:
- pOutputData->dataLen = bufWidth * bufHeight * 2;
- break;
- }
if ((pSECComponent->bSaveFlagEOS == OMX_TRUE) ||
(pSECComponent->getAllDelayBuffer == OMX_TRUE) ||
(pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
pOutputData->nFlags |= OMX_BUFFERFLAG_EOS;
pSECComponent->getAllDelayBuffer = OMX_FALSE;
- pOutputData->dataLen = 0;
}
+ pOutputData->dataLen = 0;
- /* ret = OMX_ErrorUndefined; */ /* ????? */
+ /* ret = OMX_ErrorUndefined; */
ret = OMX_ErrorNone;
goto EXIT;
}
- /** Fill Output Buffer **/
- if (pOutputData->dataLen > 0)
- {
- int frameSize = bufWidth * bufHeight;
- void *pOutBuf = (void *)pOutputData->dataBuffer;
-
-#ifdef USE_SAMSUNG_COLORFORMAT
- SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
-
- if ((pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE) &&
- (pSECOutputPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress))
-
-#else
- if (pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE)
-#endif
- {
- /* 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));
- } else {
- SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode");
- csc_tiled_to_linear(
- (unsigned char *)pOutBuf,
- (unsigned char *)outputInfo.YVirAddr,
- bufWidth,
- bufHeight);
- csc_tiled_to_linear_deinterleave(
- (unsigned char *)pOutBuf + frameSize,
- (unsigned char *)pOutBuf + (frameSize * 5) / 4,
- (unsigned char *)outputInfo.CVirAddr,
- bufWidth,
- bufHeight >> 1);
- }
- }
-
EXIT:
FunctionOut();
@@ -1124,7 +1248,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video");
pSECPort->portDefinition.format.video.pNativeRender = 0;
pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
- pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
pSECPort->portDefinition.bEnabled = OMX_TRUE;
for(i = 0; i < ALL_PORT_NUM; i++) {
@@ -1136,6 +1260,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pOMXComponent->GetParameter = &SEC_MFC_H264Dec_GetParameter;
pOMXComponent->SetParameter = &SEC_MFC_H264Dec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_H264Dec_GetConfig;
pOMXComponent->SetConfig = &SEC_MFC_H264Dec_SetConfig;
pOMXComponent->GetExtensionIndex = &SEC_MFC_H264Dec_GetExtensionIndex;
pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Dec_ComponentRoleEnum;
diff --git a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk
index 66353d6..290cad5 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk
+++ b/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk
@@ -14,8 +14,9 @@ LOCAL_CFLAGS :=
LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent libsecmfcdecapi libseccsc
-LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libsecmfcdecapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui
LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
$(SEC_OMX_INC)/sec \
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 0d64e47..6555356 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
@@ -182,6 +182,8 @@ static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag
int len, readStream;
unsigned startCode;
OMX_BOOL bFrameStart = 0;
+ unsigned pTypeMask = 0x03;
+ unsigned pType = 0;
len = 0;
bFrameStart = OMX_FALSE;
@@ -192,9 +194,13 @@ static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag
startCode = 0xFFFFFFFF;
if (bFrameStart == OMX_FALSE) {
/* find PSC(Picture Start Code) : 0000 0000 0000 0000 1000 00 */
- while (((startCode << 8 >> 10) != 0x20)) {
+ while (((startCode << 8 >> 10) != 0x20) || (pType != 0x02)) {
readStream = *(pInputStream + len);
startCode = (startCode << 8) | readStream;
+
+ readStream = *(pInputStream + len + 1);
+ pType = readStream & pTypeMask;
+
len++;
if (len > buffSize)
goto EXIT;
@@ -203,9 +209,14 @@ static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag
/* find next PSC */
startCode = 0xFFFFFFFF;
- while (((startCode << 8 >> 10) != 0x20)) {
+ pType = 0;
+ while (((startCode << 8 >> 10) != 0x20) || (pType != 0x02)) {
readStream = *(pInputStream + len);
startCode = (startCode << 8) | readStream;
+
+ readStream = *(pInputStream + len + 1);
+ pType = readStream & pTypeMask;
+
len++;
if (len > buffSize)
goto EXIT;
@@ -595,10 +606,17 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter(
pSECOutputPort->portDefinition.format.video.nFrameHeight = pSECPort->portDefinition.format.video.nFrameHeight;
pSECOutputPort->portDefinition.format.video.nStride = width;
pSECOutputPort->portDefinition.format.video.nSliceHeight = height;
- if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) {
+
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
- } else if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV422Planar) {
- pSECOutputPort->portDefinition.nBufferSize = width * height * 2;
+ break;
+ default:
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Color format is not support!! use default YUV size!!");
+ ret = OMX_ErrorUnsupportedSetting;
+ break;
}
}
}
@@ -612,9 +630,8 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter(
OMX_S32 codecType;
ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
- if (ret != OMX_ErrorNone) {
+ if (ret != OMX_ErrorNone)
goto EXIT;
- }
if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) {
ret = OMX_ErrorBadPortIndex;
@@ -678,6 +695,54 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
@@ -764,12 +829,19 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetExtensionIndex(
goto EXIT;
}
- if (SEC_OSAL_Strcmp(cParameterName, "OMX.SEC.index.ThumbnailMode") == 0) {
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
-
*pIndexType = OMX_IndexVendorThumbnailMode;
-
ret = OMX_ErrorNone;
+#if 0
+//#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_USE_ANB) == 0) {
+ *pIndexType = OMX_IndexParamUseAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+#endif
} else {
ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
}
@@ -1005,19 +1077,15 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
#ifndef FULL_FRAME_SEARCH
if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
- (pSECComponent->bUseFlagEOF == OMX_FALSE)) {
+ (pSECComponent->bUseFlagEOF == OMX_FALSE))
pSECComponent->bUseFlagEOF = OMX_TRUE;
- }
#endif
- pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
- pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
- SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp));
- pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp++;
- if (pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp >= MAX_TIMESTAMP)
- pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp = 0;
-
if (Check_Stream_PrefixCode(pInputData->dataBuffer, pInputData->dataLen, pMpeg4Dec->hMFCMpeg4Handle.codecType) == OMX_TRUE) {
+ pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp));
+
returnCodec = SsbSipMfcDecExe(hMFCHandle, oneFrameSize);
} else {
pOutputData->timeStamp = pInputData->timeStamp;
@@ -1030,12 +1098,15 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
SSBSIP_MFC_DEC_OUTBUF_STATUS status;
OMX_S32 indexTimestamp = 0;
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp++;
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
+
status = SsbSipMfcDecGetOutBuf(hMFCHandle, &outputInfo);
bufWidth = (outputInfo.img_width + 15) & (~15);
bufHeight = (outputInfo.img_height + 15) & (~15);
if ((SsbSipMfcDecGetConfig(hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
- (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) {
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -1045,27 +1116,91 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) ||
(status == MFC_GETOUTBUF_DISPLAY_ONLY)) {
- switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
- case OMX_COLOR_FormatYUV420Planar:
- case OMX_COLOR_FormatYUV420SemiPlanar:
- pOutputData->dataLen = (bufWidth * bufHeight * 3) /2;
- break;
- default:
- pOutputData->dataLen = bufWidth * bufHeight * 2;
- break;
+ /** Fill Output Buffer **/
+ int frameSize = bufWidth * bufHeight;
+ 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
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE) {
+ pOutputBuf = (void *)getVADDRfromANB
+ (pOutputData->dataBuffer,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight);
+ }
+#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));
+ pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
+ } else {
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420P out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf,
+ (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 *)outputInfo.CVirAddr,
+ outputInfo.img_width,
+ outputInfo.img_height >> 1);
+ pOutputData->dataLen = (outputInfo.img_width * outputInfo.img_height) * 3 / 2;
+ }
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ default:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420SP out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf,
+ (unsigned char *)outputInfo.YVirAddr,
+ outputInfo.img_width,
+ outputInfo.img_height);
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf + imageSize,
+ (unsigned char *)outputInfo.CVirAddr,
+ outputInfo.img_width,
+ outputInfo.img_height >> 1);
+ pOutputData->dataLen = (outputInfo.img_width * outputInfo.img_height) * 3 / 2;
+ }
+ break;
+ }
}
+#if 0
+//#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE)
+ putVADDRtoANB(pOutputData->dataBuffer);
+#endif
}
if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
pOutputData->dataLen = 0;
if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) ||
- (pSECComponent->getAllDelayBuffer == OMX_TRUE)) {
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE))
ret = OMX_ErrorInputDataDecodeYet;
- }
if (status == MFC_GETOUTBUF_DECODING_ONLY) {
- /* ret = OMX_ErrorInputDataDecodeYet; */
- ret = OMX_ErrorNone;
+ if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) &&
+ (pSECComponent->bSaveFlagEOS == OMX_TRUE)) {
+ pInputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else {
+ ret = OMX_ErrorNone;
+ }
goto EXIT;
}
@@ -1077,7 +1212,6 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
ret = OMX_ErrorInputDataDecodeYet;
} else
#endif
-
if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
pSECComponent->getAllDelayBuffer = OMX_TRUE;
@@ -1089,67 +1223,20 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
} else {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
- switch(pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
- case OMX_COLOR_FormatYUV420Planar:
- case OMX_COLOR_FormatYUV420SemiPlanar:
- pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
- break;
- default:
- pOutputData->dataLen = bufWidth * bufHeight * 2;
- break;
- }
if ((pSECComponent->bSaveFlagEOS == OMX_TRUE) ||
(pSECComponent->getAllDelayBuffer == OMX_TRUE) ||
(pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
pOutputData->nFlags |= OMX_BUFFERFLAG_EOS;
pSECComponent->getAllDelayBuffer = OMX_FALSE;
- pOutputData->dataLen = 0;
}
+ pOutputData->dataLen = 0;
- /* ret = OMX_ErrorUndefined; */ /* ????? */
+ /* ret = OMX_ErrorUndefined; */
ret = OMX_ErrorNone;
goto EXIT;
}
- /** Fill Output Buffer **/
- if (pOutputData->dataLen > 0)
- {
- int frameSize = bufWidth * bufHeight;
- void *pOutputBuf = (void *)pOutputData->dataBuffer;
-
-#ifdef USE_SAMSUNG_COLORFORMAT
- SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
-
- if ((pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE) &&
- (pSECOutputPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress))
-
-#else
- if (pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE)
-#endif
- {
- /* 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));
- } else {
- SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode");
- csc_tiled_to_linear(
- (unsigned char *)pOutputBuf,
- (unsigned char *)outputInfo.YVirAddr,
- bufWidth,
- bufHeight);
- csc_tiled_to_linear_deinterleave(
- (unsigned char *)pOutputBuf + frameSize,
- (unsigned char *)pOutputBuf + (frameSize * 5) / 4,
- (unsigned char *)outputInfo.CVirAddr,
- bufWidth,
- bufHeight >> 1);
- }
- }
-
EXIT:
FunctionOut();
@@ -1320,7 +1407,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video");
pSECPort->portDefinition.format.video.pNativeRender = 0;
pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
- pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
pSECPort->portDefinition.bEnabled = OMX_TRUE;
if (codecType == CODEC_TYPE_MPEG4) {
@@ -1341,6 +1428,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Dec_GetParameter;
pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Dec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_Mpeg4Dec_GetConfig;
pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Dec_SetConfig;
pOMXComponent->GetExtensionIndex = &SEC_MFC_Mpeg4Dec_GetExtensionIndex;
pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Dec_ComponentRoleEnum;
diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c b/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c
index eff5dec..8ddd2a4 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c
+++ b/sec_mm/sec_omx/sec_omx_component/video/enc/SEC_OMX_Venc.c
@@ -33,15 +33,13 @@
#include "SEC_OMX_Venc.h"
#include "SEC_OMX_Basecomponent.h"
#include "SEC_OSAL_Thread.h"
+#include "color_space_convertor.h"
#undef SEC_LOG_TAG
#define SEC_LOG_TAG "SEC_VIDEO_ENC"
#define SEC_LOG_OFF
#include "SEC_OSAL_Log.h"
-#define ONE_FRAME_OUTPUT /* only one frame output for Android */
-#define S5PC110_ENCODE_IN_DATA_BUFFER /* for Android s5pc110 0copy*/
-
inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
{
@@ -160,6 +158,8 @@ OMX_ERRORTYPE SEC_OMX_UseBuffer(
goto EXIT;
}
}
+
+ SEC_OSAL_Free(temp_bufferHeader);
ret = OMX_ErrorInsufficientResources;
EXIT:
@@ -256,6 +256,9 @@ OMX_ERRORTYPE SEC_OMX_AllocateBuffer(
goto EXIT;
}
}
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ SEC_OSAL_Free(temp_buffer);
ret = OMX_ErrorInsufficientResources;
EXIT:
@@ -496,10 +499,9 @@ OMX_ERRORTYPE SEC_InputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent)
dataBuffer->dataValid = OMX_TRUE;
dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags;
dataBuffer->timeStamp = dataBuffer->bufferHeader->nTimeStamp;
-#ifdef S5PC110_ENCODE_IN_DATA_BUFFER
pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = dataBuffer->bufferHeader->pBuffer;
pSECComponent->processData[INPUT_PORT_INDEX].allocSize = dataBuffer->bufferHeader->nAllocLen;
-#endif
+
SEC_OSAL_Free(message);
}
SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex);
@@ -738,12 +740,8 @@ OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent)
if (((inputData->allocSize) - (inputData->dataLen)) >= copySize) {
SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
-#ifndef S5PC110_ENCODE_IN_DATA_BUFFER
- if (copySize > 0) {
- SEC_OSAL_Memcpy(inputData->dataBuffer + inputData->dataLen, checkInputStream, copySize);
- }
-#else
- if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatYUV420Planar) {
+ if ((pSECPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) &&
+ (pSECPort->bStoreMetaDataInBuffer == OMX_FALSE)) {
if (flagEOF == OMX_TRUE) {
OMX_U32 width, height;
@@ -756,11 +754,24 @@ OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent)
SEC_OSAL_Log(SEC_LOG_TRACE, "width:%d, height:%d, Ysize:%d", width, height, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
SEC_OSAL_Log(SEC_LOG_TRACE, "width:%d, height:%d, Csize:%d", width, height, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)));
- SEC_OSAL_Memcpy(inputData->specificBufferHeader.YVirAddr, checkInputStream, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
- SEC_OSAL_Memcpy(inputData->specificBufferHeader.CVirAddr, checkInputStream + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)));
+ switch (pSECPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ csc_linear_to_tiled(inputData->specificBufferHeader.YVirAddr,
+ checkInputStream, width, height);
+ csc_linear_to_tiled_interleave(inputData->specificBufferHeader.CVirAddr,
+ checkInputStream + (width * height),
+ checkInputStream + (((width * height) * 5) / 4),
+ width, height >> 1);
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ default:
+ SEC_OSAL_Memcpy(inputData->specificBufferHeader.YVirAddr, checkInputStream, (width * height));
+ SEC_OSAL_Memcpy(inputData->specificBufferHeader.CVirAddr, checkInputStream + (width * height), (width * height / 2));
+ break;
+ }
}
}
-#endif
+
inputUseBuffer->dataLen -= copySize;
inputUseBuffer->remainDataLen -= copySize;
inputUseBuffer->usedDataLen += copySize;
@@ -795,10 +806,8 @@ OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent)
}
if (inputUseBuffer->remainDataLen == 0) {
-#ifdef S5PC110_ENCODE_IN_DATA_BUFFER
if(flagEOF == OMX_FALSE)
-#endif
- SEC_InputBufferReturn(pOMXComponent);
+ SEC_InputBufferReturn(pOMXComponent);
} else {
inputUseBuffer->dataValid = OMX_TRUE;
}
@@ -864,18 +873,9 @@ OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent)
/* reset outputData */
SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX);
-#ifdef ONE_FRAME_OUTPUT /* only one frame output for Android */
if ((outputUseBuffer->remainDataLen > 0) ||
(outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS))
SEC_OutputBufferReturn(pOMXComponent);
-#else
- if ((outputUseBuffer->remainDataLen > 0) ||
- ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) {
- SEC_OutputBufferReturn(pOMXComponent);
- } else {
- outputUseBuffer->dataValid = OMX_TRUE;
- }
-#endif
} else {
SEC_OSAL_Log(SEC_LOG_ERROR, "output buffer is smaller than encoded data size Out Length");
@@ -969,12 +969,12 @@ OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent)
SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex);
SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex);
ret = pSECComponent->sec_mfc_bufferProcess(pOMXComponent, inputData, outputData);
-#ifdef S5PC110_ENCODE_IN_DATA_BUFFER
+
if (inputUseBuffer->remainDataLen == 0)
SEC_InputBufferReturn(pOMXComponent);
else
inputUseBuffer->dataValid = OMX_TRUE;
-#endif
+
SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex);
@@ -1084,19 +1084,19 @@ OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter(
portDefinition = &pSECPort->portDefinition;
switch (index) {
- case supportFormat_1:
+ case supportFormat_0:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
- case supportFormat_2:
+ case supportFormat_1:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
- case supportFormat_3:
+ case supportFormat_2:
portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
- portFormat->eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12TPhysicalAddress;
portFormat->xFramerate = portDefinition->format.video.xFramerate;
break;
}
@@ -1257,6 +1257,21 @@ OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter(
}
}
break;
+#ifdef USE_ANDROID_EXTENSION
+ case OMX_IndexParamStoreMetaDataBuffer:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (INPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = enableStoreMetaDataInBuffers(hComponent, ComponentParameterStructure);
+ }
+ break;
+#endif
default:
{
ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk
index cf91356..d4dfd1d 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk
+++ b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/Android.mk
@@ -14,8 +14,9 @@ LOCAL_CFLAGS :=
LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent libsecmfcencapi
-LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent \
+ libsecmfcencapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui
LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
$(SEC_OMX_INC)/sec \
diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c
index 634e353..2bb12b8 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c
+++ b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/SEC_OMX_H264enc.c
@@ -35,6 +35,7 @@
#include "library_register.h"
#include "SEC_OMX_H264enc.h"
#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
#undef SEC_LOG_TAG
#define SEC_LOG_TAG "SEC_H264_ENC"
@@ -533,6 +534,54 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_H264Enc_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_H264Enc_SetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
@@ -576,6 +625,59 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_H264Enc_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if ((cParameterName == NULL) || (pIndexType == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+#ifdef USE_ANDROID_EXTENSION
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) {
+ *pIndexType = OMX_IndexParamStoreMetaDataBuffer;
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+#else
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -744,8 +846,7 @@ OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
pSECComponent->nFlags[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->nFlags;
SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pH264Enc->hMFCH264Handle.indexTimestamp));
pH264Enc->hMFCH264Handle.indexTimestamp++;
- if (pH264Enc->hMFCH264Handle.indexTimestamp >= MAX_TIMESTAMP)
- pH264Enc->hMFCH264Handle.indexTimestamp = 0;
+ pH264Enc->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
if (oneFrameSize <= 0) {
pOutputData->timeStamp = pInputData->timeStamp;
@@ -756,28 +857,28 @@ OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
}
pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
- if (pSECPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress) {
-#define USE_FIMC_FRAME_BUFFER
-#ifdef USE_FIMC_FRAME_BUFFER
+ if (pSECPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY));
SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC));
pInputInfo->YPhyAddr = addrInfo.pAddrY;
pInputInfo->CPhyAddr = addrInfo.pAddrC;
- ret = SsbSipMfcEncSetInBuf(pH264Enc->hMFCH264Handle.hMFCHandle, pInputInfo);
- if (ret != MFC_RET_OK) {
- SEC_OSAL_Log(SEC_LOG_TRACE, "Error : SsbSipMfcEncSetInBuf() \n");
- ret = OMX_ErrorUndefined;
+#ifdef USE_ANDROID_EXTENSION
+ } else if (pSECPort->bStoreMetaDataInBuffer != OMX_FALSE) {
+ ret = preprocessMetaDataInBuffers(pOMXComponent, pInputData->dataBuffer, pInputInfo);
+ if (ret != OMX_ErrorNone)
goto EXIT;
- }
-#else
- OMX_U32 width, height;
-
- width = pSECPort->portDefinition.format.video.nFrameWidth;
- height = pSECPort->portDefinition.format.video.nFrameHeight;
-
- SEC_OSAL_Memcpy(pInputInfo->YVirAddr, pInputData->dataBuffer, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
- SEC_OSAL_Memcpy(pInputInfo->CVirAddr, pInputData->dataBuffer + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)));
#endif
+ } else {
+ /* Real input data */
+ pInputInfo->YPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr;
+ pInputInfo->CPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr;
+ }
+
+ ret = SsbSipMfcEncSetInBuf(pH264Enc->hMFCH264Handle.hMFCHandle, pInputInfo);
+ if (ret != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Error : SsbSipMfcEncSetInBuf() \n");
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
}
returnCodec = SsbSipMfcEncExe(pH264Enc->hMFCH264Handle.hMFCHandle);
@@ -786,7 +887,7 @@ OMX_ERRORTYPE SEC_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA
returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo);
if ((SsbSipMfcEncGetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
- (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))){
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))){
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -861,8 +962,8 @@ OMX_ERRORTYPE SEC_MFC_H264Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SE
pInputData->dataLen -= pInputData->usedDataLen;
pInputData->usedDataLen = 0;
- pOutputData->usedDataLen = 0;
- pOutputData->remainDataLen = pOutputData->dataLen;
+ /* pOutputData->usedDataLen = 0; */
+ pOutputData->remainDataLen = pOutputData->dataLen - pOutputData->usedDataLen;
}
EXIT:
@@ -952,7 +1053,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video");
- pSECPort->portDefinition.format.video.eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress;
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
pSECPort->portDefinition.bEnabled = OMX_TRUE;
/* Output port */
@@ -976,7 +1077,9 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pOMXComponent->GetParameter = &SEC_MFC_H264Enc_GetParameter;
pOMXComponent->SetParameter = &SEC_MFC_H264Enc_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_H264Enc_GetConfig;
pOMXComponent->SetConfig = &SEC_MFC_H264Enc_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_H264Enc_GetExtensionIndex;
pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Enc_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
@@ -1000,7 +1103,7 @@ OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
OMX_ERRORTYPE ret = OMX_ErrorNone;
OMX_COMPONENTTYPE *pOMXComponent = NULL;
SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
- SEC_H264ENC_HANDLE *pH264Dec = NULL;
+ SEC_H264ENC_HANDLE *pH264Enc = NULL;
FunctionIn();
@@ -1014,10 +1117,10 @@ OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
SEC_OSAL_Free(pSECComponent->componentName);
pSECComponent->componentName = NULL;
- pH264Dec = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle;
- if (pH264Dec != NULL) {
- SEC_OSAL_Free(pH264Dec);
- pH264Dec = pSECComponent->hCodecHandle = NULL;
+ pH264Enc = (SEC_H264ENC_HANDLE *)pSECComponent->hCodecHandle;
+ if (pH264Enc != NULL) {
+ SEC_OSAL_Free(pH264Enc);
+ pH264Enc = pSECComponent->hCodecHandle = NULL;
}
ret = SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent);
diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c
index 772d66a..247b38b 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c
+++ b/sec_mm/sec_omx/sec_omx_component/video/enc/h264enc/library_register.c
@@ -37,19 +37,19 @@
OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents)
{
- FunctionIn();
+ FunctionIn();
- if (secComponents == NULL)
- goto EXIT;
+ if (secComponents == NULL)
+ goto EXIT;
- /* component 1 - video decoder H.264 */
- SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPONENT_H264_ENC);
- SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPONENT_H264_ENC_ROLE);
- secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+ /* component 1 - video decoder H.264 */
+ SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPONENT_H264_ENC);
+ SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPONENT_H264_ENC_ROLE);
+ secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
EXIT:
- FunctionOut();
+ FunctionOut();
- return MAX_COMPONENT_NUM;
+ return MAX_COMPONENT_NUM;
}
diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk
index 87c3924..de6be61 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk
+++ b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/Android.mk
@@ -14,8 +14,9 @@ LOCAL_CFLAGS :=
LOCAL_ARM_MODE := arm
-LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent libsecmfcencapi
-LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent \
+ libsecmfcencapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui
LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
$(SEC_OMX_INC)/sec \
diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c
index 35f3622..cc9998f 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c
+++ b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/SEC_OMX_Mpeg4enc.c
@@ -36,6 +36,7 @@
#include "library_register.h"
#include "SEC_OMX_Mpeg4enc.h"
#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
#undef SEC_LOG_TAG
#define SEC_LOG_TAG "SEC_MPEG4_ENC"
@@ -647,6 +648,54 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_SetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
@@ -690,6 +739,59 @@ EXIT:
return ret;
}
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if ((cParameterName == NULL) || (pIndexType == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+#ifdef USE_ANDROID_EXTENSION
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) {
+ *pIndexType = OMX_IndexParamStoreMetaDataBuffer;
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+#else
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_ComponentRoleEnum(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_OUT OMX_U8 *cRole,
@@ -870,8 +972,7 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
pSECComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
SsbSipMfcEncSetConfig(hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp));
pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp++;
- if (pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp >= MAX_TIMESTAMP)
- pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp = 0;
+ pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
if (oneFrameSize <= 0) {
pOutputData->timeStamp = pInputData->timeStamp;
@@ -882,29 +983,28 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
}
pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
- if (pSECPort->portDefinition.format.video.eColorFormat == SEC_OMX_COLOR_FormatNV12PhysicalAddress) {
- /* input data from Real camera */
-#define USE_FIMC_FRAME_BUFFER
-#ifdef USE_FIMC_FRAME_BUFFER
+ if (pSECPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY));
SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC));
pInputInfo->YPhyAddr = addrInfo.pAddrY;
pInputInfo->CPhyAddr = addrInfo.pAddrC;
- returnCodec = SsbSipMfcEncSetInBuf(hMFCHandle, pInputInfo);
- if (returnCodec != MFC_RET_OK) {
- SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncSetInBuf failed, ret:%d", __FUNCTION__, returnCodec);
- ret = OMX_ErrorUndefined;
+#ifdef USE_ANDROID_EXTENSION
+ } else if (pSECPort->bStoreMetaDataInBuffer != OMX_FALSE) {
+ ret = preprocessMetaDataInBuffers(pOMXComponent, pInputData->dataBuffer, pInputInfo);
+ if (ret != OMX_ErrorNone)
goto EXIT;
- }
-#else
- OMX_U32 width, height;
-
- width = pSECPort->portDefinition.format.video.nFrameWidth;
- height = pSECPort->portDefinition.format.video.nFrameHeight;
-
- SEC_OSAL_Memcpy(pInputInfo->YVirAddr, pInputData->dataBuffer, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
- SEC_OSAL_Memcpy(pInputInfo->CVirAddr, pInputData->dataBuffer + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)), ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)));
#endif
+ } else {
+ /* Real input data */
+ pInputInfo->YPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.YPhyAddr;
+ pInputInfo->CPhyAddr = pSECComponent->processData[INPUT_PORT_INDEX].specificBufferHeader.CPhyAddr;
+ }
+
+ returnCodec = SsbSipMfcEncSetInBuf(hMFCHandle, pInputInfo);
+ if (returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncSetInBuf failed, ret:%d", __FUNCTION__, returnCodec);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
}
returnCodec = SsbSipMfcEncExe(hMFCHandle);
@@ -914,7 +1014,7 @@ OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DAT
returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
if ((SsbSipMfcEncGetConfig(hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
- (((indexTimestamp < 0) || (indexTimestamp > MAX_TIMESTAMP)))) {
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -1084,7 +1184,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video");
- pSECPort->portDefinition.format.video.eColorFormat = SEC_OMX_COLOR_FormatNV12PhysicalAddress;//OMX_COLOR_FormatYUV420SemiPlanar;
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
pSECPort->portDefinition.bEnabled = OMX_TRUE;
@@ -1142,7 +1242,9 @@ OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, O
pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Enc_GetParameter;
pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Enc_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_Mpeg4Enc_GetConfig;
pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Enc_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_Mpeg4Enc_GetExtensionIndex;
pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Enc_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
diff --git a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c
index 6603e66..467eba2 100644
--- a/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c
+++ b/sec_mm/sec_omx/sec_omx_component/video/enc/mpeg4enc/library_register.c
@@ -42,23 +42,23 @@
OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent)
{
- FunctionIn();
+ FunctionIn();
- if (ppSECComponent == NULL)
- goto EXIT;
+ if (ppSECComponent == NULL)
+ goto EXIT;
- /* component 1 - video encoder MPEG4 */
- SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_MPEG4_ENC);
- SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_MPEG4_ENC_ROLE);
- ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+ /* component 1 - video encoder MPEG4 */
+ SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_MPEG4_ENC);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_MPEG4_ENC_ROLE);
+ ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
- /* component 2 - video encoder H.263 */
- SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPONENT_H263_ENC);
- SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPONENT_H263_ENC_ROLE);
- ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+ /* component 2 - video encoder H.263 */
+ SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPONENT_H263_ENC);
+ SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPONENT_H263_ENC_ROLE);
+ ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
EXIT:
- FunctionOut();
- return MAX_COMPONENT_NUM;
+ FunctionOut();
+ return MAX_COMPONENT_NUM;
}
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 10dd94d..66aa696 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
@@ -16,10 +16,10 @@
*/
/*
- * @file SEC_OMX_Def.h
- * @brief SEC_OMX specific define
- * @author SeungBeom Kim (sbcrux.kim@samsung.com)
- * @version 1.0
+ * @file SEC_OMX_Def.h
+ * @brief SEC_OMX specific define
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.0
* @history
* 2010.7.15 : Create
*/
@@ -43,83 +43,93 @@
#define MAX_OMX_COMPONENT_LIBNAME_SIZE OMX_MAX_STRINGNAME_SIZE * 2
#define MAX_OMX_MIMETYPE_SIZE OMX_MAX_STRINGNAME_SIZE
-#define MAX_TIMESTAMP 16
-#define MAX_FLAGS 16
+#define MAX_TIMESTAMP 17
+#define MAX_FLAGS 17
+#define USE_ANDROID_EXTENSION
typedef enum _SEC_CODEC_TYPE
{
- SW_CODEC,
- HW_VIDEO_CODEC,
- HW_AUDIO_CODEC
+ SW_CODEC,
+ HW_VIDEO_CODEC,
+ HW_AUDIO_CODEC
} SEC_CODEC_TYPE;
typedef struct _SEC_OMX_PRIORITYMGMTTYPE
{
- OMX_U32 nGroupPriority; /* the value 0 represents the highest priority */
- /* for a group of components */
- OMX_U32 nGroupID;
+ OMX_U32 nGroupPriority; /* the value 0 represents the highest priority */
+ /* for a group of components */
+ OMX_U32 nGroupID;
} SEC_OMX_PRIORITYMGMTTYPE;
typedef enum _SEC_OMX_INDEXTYPE
{
- OMX_IndexVendorThumbnailMode = 0x7F000001,
- OMX_COMPONENT_CAPABILITY_TYPE_INDEX = 0xFF7A347 /*for Android*/
+#define SEC_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.ThumbnailMode"
+ OMX_IndexVendorThumbnailMode = 0x7F000001,
+
+ /* for Android Native Window */
+#define SEC_INDEX_PARAM_ENABLE_ANB "OMX.google.android.index.enableAndroidNativeBuffers"
+ OMX_IndexParamEnableAndroidBuffers = 0x7F000011,
+#define SEC_INDEX_PARAM_GET_ANB "OMX.google.android.index.getAndroidNativeBufferUsage"
+ OMX_IndexParamGetAndroidNativeBuffer = 0x7F000012,
+#define SEC_INDEX_PARAM_USE_ANB "OMX.google.android.index.useAndroidNativeBuffer"
+ OMX_IndexParamUseAndroidNativeBuffer = 0x7F000013,
+#define SEC_INDEX_PARAM_STORE_METADATA_BUFFER "OMX.google.android.index.storeMetaDataInBuffers"
+ OMX_IndexParamStoreMetaDataBuffer = 0x7F000014,
+
+ /* for Android PV OpenCore*/
+ OMX_COMPONENT_CAPABILITY_TYPE_INDEX = 0xFF7A347
} SEC_OMX_INDEXTYPE;
typedef enum _SEC_OMX_ERRORTYPE
{
- OMX_ErrorNoEOF = 0x90000001,
- OMX_ErrorInputDataDecodeYet,
- OMX_ErrorInputDataEncodeYet,
- OMX_ErrorMFCInit
+ OMX_ErrorNoEOF = 0x90000001,
+ OMX_ErrorInputDataDecodeYet,
+ OMX_ErrorInputDataEncodeYet,
+ OMX_ErrorMFCInit
} SEC_OMX_ERRORTYPE;
typedef enum _SEC_OMX_COMMANDTYPE
{
- SEC_OMX_CommandComponentDeInit = 0x7F000001,
- SEC_OMX_CommandEmptyBuffer,
- SEC_OMX_CommandFillBuffer
+ SEC_OMX_CommandComponentDeInit = 0x7F000001,
+ SEC_OMX_CommandEmptyBuffer,
+ SEC_OMX_CommandFillBuffer
} SEC_OMX_COMMANDTYPE;
typedef enum _SEC_OMX_TRANS_STATETYPE {
- SEC_OMX_TransStateInvalid,
- SEC_OMX_TransStateLoadedToIdle,
- SEC_OMX_TransStateIdleToExecuting,
- SEC_OMX_TransStateExecutingToIdle,
- SEC_OMX_TransStateIdleToLoaded,
- SEC_OMX_TransStateMax = 0X7FFFFFFF
+ SEC_OMX_TransStateInvalid,
+ SEC_OMX_TransStateLoadedToIdle,
+ SEC_OMX_TransStateIdleToExecuting,
+ SEC_OMX_TransStateExecutingToIdle,
+ SEC_OMX_TransStateIdleToLoaded,
+ SEC_OMX_TransStateMax = 0X7FFFFFFF
} SEC_OMX_TRANS_STATETYPE;
typedef enum _SEC_OMX_COLOR_FORMATTYPE {
-#ifndef USE_SAMSUNG_COLORFORMAT
- SEC_OMX_COLOR_FormatNV12PhysicalAddress = OMX_COLOR_FormatYUV420SemiPlanar
-#else
- SEC_OMX_COLOR_FormatNV12PhysicalAddress = 0x7F000001 /**< Reserved region for introducing Vendor Extensions */
-#endif
+ OMX_SEC_COLOR_FormatNV12TPhysicalAddress = 0x7F000001 /**< Reserved region for introducing Vendor Extensions */
}SEC_OMX_COLOR_FORMATTYPE;
typedef enum _SEC_OMX_SUPPORTFORMAT_TYPE
{
- supportFormat_1 = 0x00,
- supportFormat_2,
- supportFormat_3,
- supportFormat_4
+ supportFormat_0 = 0x00,
+ supportFormat_1,
+ supportFormat_2,
+ supportFormat_3
} SEC_OMX_SUPPORTFORMAT_TYPE;
/* for Android */
typedef struct _OMXComponentCapabilityFlagsType
{
- /* OMX COMPONENT CAPABILITY RELATED MEMBERS */
- OMX_BOOL iIsOMXComponentMultiThreaded;
- OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
- OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
- OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
- OMX_BOOL iOMXComponentSupportsPartialFrames;
- OMX_BOOL iOMXComponentUsesNALStartCodes;
- OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
- OMX_BOOL iOMXComponentUsesFullAVCFrames;
+ /* OMX COMPONENT CAPABILITY RELATED MEMBERS */
+ OMX_BOOL iIsOMXComponentMultiThreaded;
+ OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
+ OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
+ OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
+ OMX_BOOL iOMXComponentSupportsPartialFrames;
+ OMX_BOOL iOMXComponentUsesNALStartCodes;
+ OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
+ OMX_BOOL iOMXComponentUsesFullAVCFrames;
} OMXComponentCapabilityFlagsType;
typedef struct _SEC_OMX_VIDEO_PROFILELEVEL
diff --git a/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h b/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h
index b3bfda6..1debc62 100644
--- a/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h
+++ b/sec_mm/sec_omx/sec_omx_include/sec/SEC_OMX_Macros.h
@@ -16,10 +16,10 @@
*/
/*
- * @file SEC_OMX_Macros.h
- * @brief Macros
- * @author SeungBeom Kim (sbcrux.kim@samsung.com)
- * @version 1.0
+ * @file SEC_OMX_Macros.h
+ * @brief Macros
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.0
* @history
* 2010.7.15 : Create
*/
@@ -38,15 +38,15 @@
#define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7)
#define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13)
-#define INIT_SET_SIZE_VERSION(_struct_, _structType_) \
- do { \
- SEC_OSAL_Memset((_struct_), 0, sizeof(_structType_)); \
- (_struct_)->nSize = sizeof(_structType_); \
- (_struct_)->nVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; \
- (_struct_)->nVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; \
- (_struct_)->nVersion.s.nRevision = REVISION_NUMBER; \
- (_struct_)->nVersion.s.nStep = STEP_NUMBER; \
- } while (0)
+#define INIT_SET_SIZE_VERSION(_struct_, _structType_) \
+ do { \
+ SEC_OSAL_Memset((_struct_), 0, sizeof(_structType_)); \
+ (_struct_)->nSize = sizeof(_structType_); \
+ (_struct_)->nVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; \
+ (_struct_)->nVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; \
+ (_struct_)->nVersion.s.nRevision = REVISION_NUMBER; \
+ (_struct_)->nVersion.s.nStep = STEP_NUMBER; \
+ } while (0)
/*
* Port Specific
diff --git a/sec_mm/sec_omx/sec_osal/Android.mk b/sec_mm/sec_omx/sec_osal/Android.mk
index 894bc7a..75ceb14 100644
--- a/sec_mm/sec_omx/sec_osal/Android.mk
+++ b/sec_mm/sec_omx/sec_osal/Android.mk
@@ -12,7 +12,8 @@ LOCAL_SRC_FILES := \
SEC_OSAL_Memory.c \
SEC_OSAL_Semaphore.c \
SEC_OSAL_Library.c \
- SEC_OSAL_Log.c
+ SEC_OSAL_Log.c \
+ SEC_OSAL_Buffer.cpp
LOCAL_MODULE := libsecosal
@@ -20,10 +21,18 @@ LOCAL_MODULE := libsecosal
LOCAL_CFLAGS :=
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libcutils libutils
+
+LOCAL_SHARED_LIBRARIES := libcutils libutils \
+ libui \
+ libhardware \
+ libandroid_runtime \
+ libsurfaceflinger_client \
+ libbinder \
+ libmedia
LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
$(SEC_OMX_INC)/sec \
- $(SEC_OMX_TOP)/sec_osal
+ $(SEC_OMX_TOP)/sec_osal \
+ $(SEC_OMX_COMPONENT)/common
include $(BUILD_STATIC_LIBRARY)
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp
new file mode 100644
index 0000000..ea96e6f
--- /dev/null
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.cpp
@@ -0,0 +1,426 @@
+/*
+ *
+ * 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_PROTECTED; /* Need Change */
+
+ 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
+
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h
new file mode 100644
index 0000000..7110d5a
--- /dev/null
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Buffer.h
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * Jinsung Yang (jsgood.yang@samsung.com)
+ * @version 1.0.2
+ * @history
+ * 2011.5.15 : Create
+ */
+
+#ifndef SEC_OSAL_BUFFER
+#define SEC_OSAL_BUFFER
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "OMX_Types.h"
+
+typedef struct {
+ void *YPhyAddr; // [IN/OUT] physical address of Y
+ void *CPhyAddr; // [IN/OUT] physical address of CbCr
+ void *YVirAddr; // [IN/OUT] virtual address of Y
+ void *CVirAddr; // [IN/OUT] virtual address of CbCr
+ int YSize; // [IN/OUT] input size of Y data
+ int CSize; // [IN/OUT] input size of CbCr data
+} BUFFER_ADDRESS_INFO;
+
+
+OMX_ERRORTYPE checkVersionANB(OMX_PTR ComponentParameterStructure);
+OMX_U32 checkPortIndexANB(OMX_PTR ComponentParameterStructure);
+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 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h
index 68910cc..3f0938f 100644
--- a/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h
+++ b/sec_mm/sec_omx/sec_osal/SEC_OSAL_Queue.h
@@ -33,11 +33,10 @@
#define MAX_QUEUE_ELEMENTS 10
-struct SEC_QElem;
typedef struct _SEC_QElem
{
- void *data;
- struct SEC_QElem *qNext;
+ void *data;
+ struct _SEC_QElem *qNext;
} SEC_QElem;
typedef struct _SEC_QUEUE