diff options
Diffstat (limited to 'sec_mm/sec_omx/sec_omx_component/video/enc')
7 files changed, 330 insertions, 108 deletions
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; } |