diff options
author | Andrew F. Davis <afd@ti.com> | 2018-06-14 12:45:00 -0500 |
---|---|---|
committer | Praneeth Bajjuri <praneeth@ti.com> | 2018-06-14 12:46:18 -0500 |
commit | 4720ea4441562d2dc7751da7ea90844b0b9baef5 (patch) | |
tree | 5d4171c7f27237225bde2ddf8d70483deb8e70d7 | |
parent | f7f858c48827a2e4e2199e60689855cfa2abf393 (diff) | |
download | dra7xx-d-oreo-mr1-core-release.tar.gz |
OMX: Remove OMX Supportd-oreo-mr1-core-release
Removing OMX Support
Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
56 files changed, 0 insertions, 17534 deletions
@@ -17,14 +17,6 @@ PRODUCT_PACKAGES += \ hwcomposer.am57x \ - libmmrpc \ - libdce \ - libOMX_Core \ - libOMX \ - libosal \ - libOMX.TI.DUCATI1.VIDEO.H264E \ - libstagefrighthw \ - libOMX.TI.DUCATI1.VIDEO.DECODER \ camera.am57x \ libtiutils diff --git a/jacinto6.mk b/jacinto6.mk index 87cd29f..29a75c8 100644 --- a/jacinto6.mk +++ b/jacinto6.mk @@ -17,14 +17,6 @@ PRODUCT_PACKAGES += \ hwcomposer.jacinto6 \ - libmmrpc \ - libdce \ - libOMX_Core \ - libOMX \ - libosal \ - libOMX.TI.DUCATI1.VIDEO.H264E \ - libstagefrighthw \ - libOMX.TI.DUCATI1.VIDEO.DECODER \ camera.jacinto6 \ libtiutils diff --git a/omx/Android.mk b/omx/Android.mk deleted file mode 100644 index 3f316f2..0000000 --- a/omx/Android.mk +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(TARGET_BOARD_PLATFORM), $(filter $(TARGET_BOARD_PLATFORM), jacinto6 am57x)) - include $(all-subdir-makefiles) -endif diff --git a/omx/base/Android.mk b/omx/base/Android.mk deleted file mode 100644 index c21501c..0000000 --- a/omx/base/Android.mk +++ /dev/null @@ -1,64 +0,0 @@ -# OMX CORE Library # -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - omx_core/src/OMX_Core.c \ - omx_core/src/OMX_Core_Wrapper.c - -LOCAL_C_INCLUDES += \ - frameworks/native/include/media/openmax \ - $(LOCAL_PATH)/omx_core/inc \ - $(LOCAL_PATH)/../osal/inc \ - hardware/ti/dce/ \ - -LOCAL_SHARED_LIBRARIES := \ - libdl \ - libosal \ - libutils \ - liblog \ - libdce - -LOCAL_CFLAGS += -DBUILDOS_ANDROID -DSTATIC_TABLE -LOCAL_MODULE:= libOMX_Core -LOCAL_MODULE_TAGS:= optional -LOCAL_VENDOR_MODULE := true -include $(BUILD_SHARED_LIBRARY) - -# OMX Base library # -include $(CLEAR_VARS) -LOCAL_SRC_FILES:= \ - omx_base_comp/src/omx_base.c \ - omx_base_comp/src/omx_base_callbacks.c \ - omx_base_comp/src/omx_base_internal.c \ - omx_base_comp/src/omx_base_process.c \ - omx_base_dio_plugin/src/omx_base_dio.c \ - omx_base_dio_plugin/src/omx_base_dio_table.c \ - omx_base_dio_plugin/src/omx_base_dio_non_tunnel.c - -LOCAL_C_INCLUDES += \ - frameworks/native/include/media/openmax \ - $(LOCAL_PATH)/omx_core/inc \ - $(LOCAL_PATH)/../osal/inc \ - system/core/include/cutils \ - $(LOCAL_PATH)/omx_base_dio_plugin/inc/ \ - $(LOCAL_PATH)/omx_base_comp/inc/ \ - hardware/ti/dce/ - - -LOCAL_SHARED_LIBRARIES := \ - libosal \ - libc \ - liblog \ - libcutils \ - libutils \ - libdce - -LOCAL_CFLAGS += -DBUILDOS_ANDROID - -LOCAL_MODULE:= libOMX -LOCAL_MODULE_TAGS:= optional -LOCAL_VENDOR_MODULE := true - -include $(BUILD_SHARED_LIBRARY) diff --git a/omx/base/omx_base_comp/inc/omx_base.h b/omx/base/omx_base_comp/inc/omx_base.h deleted file mode 100644 index 3395ab8..0000000 --- a/omx/base/omx_base_comp/inc/omx_base.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _D_OMX_BASE_H_ -#define _D_OMX_BASE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <OMX_Core.h> -#include <OMX_Component.h> -#include <osal_error.h> -#include <osal_mutex.h> -#include <osal_memory.h> -#include <osal_pipes.h> -#include <osal_events.h> -#include <osal_task.h> -#include <omx_base_internal.h> -#include <omx_base_utils.h> -#include <memplugin.h> - -#define OMX_NOPORT 0xFFFFFFFE -#define OMX_BASE_INPUT_PORT 0 -#define OMX_BASE_OUTPUT_PORT 1 -#define OMX_BASE_NUM_OF_PORTS 2 -#define OMX_BASE_DEFAULT_START_PORT_NUM 0 -#define DEFAULT_COMPOENENT 0 -#define MAX_PLANES_PER_BUFFER 3 - - -/* -* buffer life cycle -*/ -typedef enum OMXBase_BufferStatus{ - OWNED_BY_US, - OWNED_BY_CLIENT, - OWNED_BY_CODEC -}OMXBase_BufStatus; - -/** Platform private buffer header - */ -typedef struct OMXBase_BufHdrPrivateData { - MemHeader sMemHdr[MAX_PLANES_PER_BUFFER]; - OMXBase_BufStatus bufSt; - OMX_BOOL bIsLocked; -}OMXBase_BufHdrPvtData; - -typedef struct OMXBase_CodecConfigBuffer { - MemHeader *sBuffer; -} OMXBase_CodecConfigBuf; - -/** Port properties. - */ -typedef struct OMXBase_PortProperties { - OMX_U32 nWatermark; - BufAccessMode eDataAccessMode; - MemRegion eBufMemoryType; - OMX_U32 nNumComponentBuffers; - OMX_U32 nTimeoutForDequeue; -}OMXBase_PortProps; - -/** Base port definition - */ -typedef struct OMXBase_Port{ - OMX_PARAM_PORTDEFINITIONTYPE sPortDef; - OMX_BUFFERHEADERTYPE **pBufferlist; - OMXBase_PortProps sProps; - OMX_BOOL bIsBufferAllocator; - OMX_BOOL bIsInTransition; - OMX_BOOL bIsFlushingBuffers; - OMX_BOOL bEosRecd; - OMX_U32 nBufferCnt; - OMX_PTR pBufAllocFreeEvent; - OMX_PTR pDioOpenCloseSem; - OMX_PTR hDIO; - OMX_U32 nCachedBufferCnt; -}OMXBase_Port; - -/* OMX base component structure -*/ -typedef struct OMXBaseComp -{ - OMX_STRING cComponentName; - OMX_VERSIONTYPE nComponentVersion; - OMX_PORT_PARAM_TYPE *pAudioPortParams; - OMX_PORT_PARAM_TYPE *pVideoPortParams; - OMX_PORT_PARAM_TYPE *pImagePortParams; - OMX_PORT_PARAM_TYPE *pOtherPortParams; - OMX_U32 nNumPorts; - OMX_U32 nMinStartPortIndex; - OMXBase_Port **pPorts; - OMX_BOOL bNotifyForAnyPort; - OMXBaseComp_Pvt *pPvtData; - OMX_STATETYPE tCurState; - OMX_STATETYPE tNewState; - OMX_PTR pMutex; - - OMX_ERRORTYPE (*fpCommandNotify)(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, OMX_PTR pCmdData); - - OMX_ERRORTYPE (*fpDataNotify)(OMX_HANDLETYPE hComponent); - - - OMX_ERRORTYPE (*fpReturnEventNotify)(OMX_HANDLETYPE hComponent, OMX_EVENTTYPE eEvent, - OMX_U32 nEventData1, OMX_U32 nEventData2, OMX_PTR pEventData); - - OMX_ERRORTYPE (*fpXlateBuffHandle)(OMX_HANDLETYPE hComponent, OMX_PTR pBufferHdr, OMX_BOOL bRegister); - -}OMXBaseComp; - - -OMX_ERRORTYPE OMXBase_ComponentInit(OMX_IN OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXBase_SetCallbacks(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_CALLBACKTYPE *pCallbacks, - OMX_IN OMX_PTR pAppData); - -OMX_ERRORTYPE OMXBase_GetComponentVersion(OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STRING pComponentName, - OMX_OUT OMX_VERSIONTYPE *pComponentVersion, - OMX_OUT OMX_VERSIONTYPE *pSpecVersion, - OMX_OUT OMX_UUIDTYPE *pComponentUUID); - -OMX_ERRORTYPE OMXBase_SendCommand(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_COMMANDTYPE Cmd, - OMX_IN OMX_U32 nParam1, - OMX_IN OMX_PTR pCmdData); - -OMX_ERRORTYPE OMXBase_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR pParamStruct); - -OMX_ERRORTYPE OMXBase_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pParamStruct); - - -OMX_ERRORTYPE OMXBase_GetConfig(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_INOUT OMX_PTR pComponentConfigStructure); - - -OMX_ERRORTYPE OMXBase_SetConfig(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR pComponentConfigStructure); - -OMX_ERRORTYPE OMXBase_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, - OMX_OUT OMX_INDEXTYPE *pIndexType); - - -OMX_ERRORTYPE OMXBase_GetState(OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_STATETYPE *pState); - - -OMX_ERRORTYPE OMXBase_UseBuffer(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 OMXBase_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE * *ppBuffer, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN OMX_U32 nSizeBytes); - - -OMX_ERRORTYPE OMXBase_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); - - -OMX_ERRORTYPE OMXBase_EmptyThisBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); - - -OMX_ERRORTYPE OMXBase_FillThisBuffer(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); - - -OMX_ERRORTYPE OMXBase_ComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); - - -OMX_ERRORTYPE OMXBase_UseEGLImage(OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE * *ppBufferHdr, - OMX_IN OMX_U32 nPortIndex, - OMX_IN OMX_PTR pAppPrivate, - OMX_IN void *eglImage); - -OMX_ERRORTYPE OMXBase_ComponentRoleEnum(OMX_IN OMX_HANDLETYPE hComponent, - OMX_OUT OMX_U8 *cRole, - OMX_IN OMX_U32 nIndex); - -#ifdef __cplusplus -} -#endif - -#endif /* _OMX_BASE_H_ */ - diff --git a/omx/base/omx_base_comp/inc/omx_base_internal.h b/omx/base/omx_base_comp/inc/omx_base_internal.h deleted file mode 100644 index f989ae9..0000000 --- a/omx/base/omx_base_comp/inc/omx_base_internal.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_BASE_INTERNAL_H_ -#define _OMX_BASE_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <OMX_Core.h> -#include <OMX_Component.h> -#include <omx_base_dio_plugin.h> - -#define CMDEVENT (0x00000100) - -#define DATAEVENT (0x00000200) - -#define ENDEVENT (0x00f00000) - -#define OMXBase_CmdStateSet (0x00001000) - -#define OMXBase_CmdPortEnable (0x00002000) - -#define OMXBase_CmdPortDisable (0x00003000) - -#define OMXBase_CmdFlush (0x00004000) - -#define OMXBase_CmdMarkBuffer (0x00005000) - -#define OMXBase_MAXCMDS 10 - -#define BUF_ALLOC_EVENT (0x00000001) - -#define BUF_FREE_EVENT (0x00000002) - -#define BUF_FAIL_EVENT (0x00000004) - -#define STATE_LOADED_EVENT (0x00000001) -#define STATE_IDLE_EVENT (0x00000002) -#define STATE_EXEC_EVENT (0x00000004) -#define STATE_PAUSE_EVENT (0x00000008) -#define ERROR_EVENT (0x00000010) -#define PORT_ENABLE_EVENT (0x00000020) -#define PORT_DISABLE_EVENT (0x00000040) - -#define STATE_TRANSITION_TIMEOUT 500 -#define STATE_TRANSITION_LONG_TIMEOUT 5000 - -/** Priority of the Component thread */ -#define OMX_BASE_THREAD_PRIORITY (10) - -/** Stack Size of the Comp thread*/ -#define OMX_BASE_THREAD_STACKSIZE (50 * 1024) - - -/** OMX Base Command params - * This structure contains the params required to execute command - * @param cmd : command to execute - * @param nParam : parameter for the command to be executed - * @param pCmdData : pointer to the command data - */ -typedef struct OMXBase_CmdParams { - OMX_COMMANDTYPE eCmd; - OMX_U32 unParam; - OMX_PTR pCmdData; -}OMXBase_CmdParams; - -/** OMX Base component private structure - */ -typedef struct OMXBaseComp_Private { - OMX_U8 cTaskName[OMX_BASE_MAXNAMELEN]; - OMX_U32 nStackSize; - OMX_U32 nPrioirty; - OMX_PTR pThreadId; - OMX_CALLBACKTYPE sAppCallbacks; - OMX_BOOL bForceNotifyOnce; - OMX_PTR pCmdPipe; - OMX_PTR pCmdDataPipe; - OMX_PTR pTriggerEvent; - OMX_PTR pCmdCompleteEvent; - OMX_PTR pErrorCmdcompleteEvent; - OMX_PTR pCmdPipeMutex; - OMX_PTR pNewStateMutex; - OMX_PTR pPortDisableMutex; - OMX_ERRORTYPE (*fpInvokeProcessFunction)(OMX_HANDLETYPE hComponent, - OMX_U32 retEvent); - - OMX_ERRORTYPE (*fpDioGetCount)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_U32 *pCount); - - OMX_ERRORTYPE (*fpDioQueue)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pBuffHeader); - - OMX_ERRORTYPE (*fpDioDequeue)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR *pBuffHeader); - - OMX_ERRORTYPE (*fpDioSend)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pBuffHeader); - - OMX_ERRORTYPE (*fpDioCancel)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pBuffHeader); - - OMX_ERRORTYPE (*fpDioControl)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, - OMX_DIO_CtrlCmdType nCmdType, OMX_PTR pParams); -}OMXBaseComp_Pvt; - -/* Initialization and control functions */ -OMX_ERRORTYPE OMXBase_PrivateInit(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXBase_PrivateDeInit(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXBase_SetDefaultProperties(OMX_HANDLETYPE hComponent); - -void OMXBase_CompThreadEntry(void *arg); - -OMX_ERRORTYPE OMXBase_InitializePorts(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXBase_DeinitializePorts(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXBase_DisablePort(OMX_HANDLETYPE hComponent, - OMX_U32 nParam); - -OMX_ERRORTYPE OMXBase_EnablePort(OMX_HANDLETYPE hComponent, - OMX_U32 nParam); - -OMX_ERRORTYPE OMXBase_FlushBuffers(OMX_HANDLETYPE hComponent, - OMX_U32 nParam); - -OMX_ERRORTYPE OMXBase_HandleStateTransition(OMX_HANDLETYPE hComponent, - OMX_U32 nParam); - - -/* Event processing */ -OMX_ERRORTYPE OMXBase_EventNotifyToClient(OMX_HANDLETYPE hComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, - OMX_PTR pCmdData); -OMX_BOOL OMXBase_IsCmdPending (OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXBase_ProcessEvents(OMX_HANDLETYPE hComponent, - OMX_U32 retEvent); - -OMX_ERRORTYPE OMXBase_ProcessTriggerEvent(OMX_HANDLETYPE hComponent, - OMX_U32 EventToSet); - -OMX_ERRORTYPE OMXBase_CB_ReturnEventNotify(OMX_HANDLETYPE hComponent, - OMX_EVENTTYPE eEvent, - OMX_U32 nData1, OMX_U32 nData2, - OMX_PTR pEventData); - -/* DIO functions */ -OMX_BOOL OMXBase_IsDioReady(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex); - -OMX_ERRORTYPE OMXBase_DIO_Init (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_STRING cChannelType, - OMX_PTR pCreateParams); - -OMX_ERRORTYPE OMXBase_DIO_Open (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pOpenParams); - -OMX_ERRORTYPE OMXBase_DIO_Close (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex); - -OMX_ERRORTYPE OMXBase_DIO_Queue (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pBuffHeader); - -OMX_ERRORTYPE OMXBase_DIO_Dequeue (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR *pBuffHeader); - -OMX_ERRORTYPE OMXBase_DIO_Send (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pBuffHeader); - -OMX_ERRORTYPE OMXBase_DIO_Cancel (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pBuffHeader); - -OMX_ERRORTYPE OMXBase_DIO_Control (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_DIO_CtrlCmdType nCmdType, - OMX_PTR pParams); - -OMX_ERRORTYPE OMXBase_DIO_GetCount (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_U32 *pCount); - -OMX_ERRORTYPE OMXBase_DIO_Deinit (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex); - -/* Error Handling */ - -OMX_ERRORTYPE OMXBase_Error_EventHandler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, - OMX_EVENTTYPE eEvent, OMX_U32 nData1, - OMX_U32 nData2, OMX_PTR pEventData); - -OMX_ERRORTYPE OMXBase_Error_FillBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, - OMX_BUFFERHEADERTYPE *pBuffer); - -OMX_ERRORTYPE OMXBase_Error_EmptyBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, - OMX_BUFFERHEADERTYPE *pBuffer); - -void OMXBase_HandleFailEvent(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE eCmd, - OMX_U32 nPortIndex); - OMX_ERRORTYPE OMXBase_UtilCleanupIfError(OMX_HANDLETYPE hComponent); - -/* Miscellaneous */ - -OMX_ERRORTYPE OMXBase_GetUVBuffer(OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pBufHdr, OMX_PTR *pUVBuffer); - - - -#ifdef __cplusplus -} -#endif - -#endif /* _OMX_BASE_INTERNAL_H_ */ - diff --git a/omx/base/omx_base_comp/inc/omx_base_utils.h b/omx/base/omx_base_comp/inc/omx_base_utils.h deleted file mode 100644 index 6b4d890..0000000 --- a/omx/base/omx_base_comp/inc/omx_base_utils.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_BASE_UTILS_H_ -#define _OMX_BASE_UTILS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <osal_trace.h> - -#define OMX_CHECK(_COND_, _ERRORCODE_) do { \ - if( !(_COND_)) { eError = _ERRORCODE_; \ - OSAL_ErrorTrace("Failed check: " # _COND_); \ - OSAL_ErrorTrace("Returning error: " # _ERRORCODE_); \ - goto EXIT; } \ - } while( 0 ) - -#define OMX_BASE_CHK_VERSION(_pStruct_, _sName_, _e_) do { \ - if(((_sName_ *)_pStruct_)->nSize != sizeof(_sName_)) { \ - _e_ = OMX_ErrorBadParameter; \ - OSAL_ErrorTrace("Incorrect 'nSize' field. Returning OMX_ErrorBadParameter"); \ - goto EXIT; } \ - if((((_sName_ *)_pStruct_)->nVersion.s.nVersionMajor != 0x1) || \ - ((((_sName_ *)_pStruct_)->nVersion.s.nVersionMinor != 0x1) && \ - ((_sName_ *)_pStruct_)->nVersion.s.nVersionMinor != 0x0 )) { \ - _e_ = OMX_ErrorVersionMismatch; \ - OSAL_ErrorTrace("Version mismatch. Returning OMX_ErrorVersionMismatch"); \ - goto EXIT; } \ - } while( 0 ) - -#define OMX_BASE_INIT_STRUCT_PTR(_pStruct_, _sName_) do { \ - OSAL_Memset((_pStruct_), 0x0, sizeof(_sName_)); \ - (_pStruct_)->nSize = sizeof(_sName_); \ - (_pStruct_)->nVersion.s.nVersionMajor = 0x1; \ - (_pStruct_)->nVersion.s.nVersionMinor = 0x1; \ - (_pStruct_)->nVersion.s.nRevision = 0x2; \ - (_pStruct_)->nVersion.s.nStep = 0x0; \ - } while( 0 ) - -#ifdef __cplusplus -} -#endif - -#endif /* _OMX_BASE_UTILS_H_ */ - diff --git a/omx/base/omx_base_comp/src/omx_base.c b/omx/base/omx_base_comp/src/omx_base.c deleted file mode 100644 index 31079bf..0000000 --- a/omx/base/omx_base_comp/src/omx_base.c +++ /dev/null @@ -1,1260 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_BASE" - -#include <string.h> -#include <OMX_Core.h> -#include <OMX_Component.h> -#include <omx_base.h> -#include <OMX_TI_Custom.h> - -/** -* OMX BaseComponent Init -*/ -OMX_ERRORTYPE OMXBase_ComponentInit(OMX_IN OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp*)pComp->pComponentPrivate; - OMX_CHECK(pBaseComp != NULL, OMX_ErrorBadParameter); - - /* populate component specific function pointers */ - pComp->GetComponentVersion = OMXBase_GetComponentVersion; - pComp->SendCommand = OMXBase_SendCommand; - pComp->GetParameter = OMXBase_GetParameter; - pComp->SetParameter = OMXBase_SetParameter; - pComp->GetConfig = OMXBase_GetConfig; - pComp->SetConfig = OMXBase_SetConfig; - pComp->GetExtensionIndex = OMXBase_GetExtensionIndex; - pComp->GetState = OMXBase_GetState; - pComp->ComponentTunnelRequest = NULL; - pComp->UseBuffer = OMXBase_UseBuffer; - pComp->AllocateBuffer = OMXBase_AllocateBuffer; - pComp->FreeBuffer = OMXBase_FreeBuffer; - pComp->EmptyThisBuffer = OMXBase_EmptyThisBuffer; - pComp->FillThisBuffer = OMXBase_FillThisBuffer; - pComp->SetCallbacks = OMXBase_SetCallbacks; - pComp->ComponentDeInit = OMXBase_ComponentDeinit; - pComp->UseEGLImage = OMXBase_UseEGLImage; - pComp->ComponentRoleEnum = OMXBase_ComponentRoleEnum; - - pBaseComp->fpReturnEventNotify = OMXBase_CB_ReturnEventNotify; - - /* create a mutex to handle race conditions */ - tStatus = OSAL_CreateMutex(&(pBaseComp->pMutex)); - if(OSAL_ErrNone != tStatus) { - return OMX_ErrorInsufficientResources; - } - - /* Allocate internal area for Base component */ - pBaseComp->pPvtData = (OMXBaseComp_Pvt*)OSAL_Malloc(sizeof(OMXBaseComp_Pvt)); - OMX_CHECK(pBaseComp->pPvtData != NULL, OMX_ErrorInsufficientResources); - - OSAL_Memset(pBaseComp->pPvtData, 0, sizeof(OMXBaseComp_Pvt)); - eError = OMXBase_PrivateInit(hComponent); - OMX_CHECK(OMX_ErrorNone == eError, eError); - - /* Initialize ports */ - eError = OMXBase_InitializePorts(hComponent); - OMX_CHECK(OMX_ErrorNone == eError, eError); - - /* Component is initialized successfully, set the - * component to loaded state */ - pBaseComp->tCurState = OMX_StateLoaded; - pBaseComp->tNewState = OMX_StateMax; - - -EXIT: - /* incase of an error, deinitialize the component */ - if((OMX_ErrorNone != eError) && (pComp != NULL)) { - eTmpError = eError; - eError = pComp->ComponentDeInit(hComponent); - eError = eTmpError; - } - return (eError); -} - -/* -* SetCallbacks -*/ -OMX_ERRORTYPE OMXBase_SetCallbacks(OMX_HANDLETYPE hComponent, - OMX_CALLBACKTYPE *pCallbacks, - OMX_PTR pAppData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMX_U32 i = 0; - - OMX_CHECK((hComponent != NULL) && - (pCallbacks != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - pComp->pApplicationPrivate = pAppData; - pBaseCompPvt->sAppCallbacks = *pCallbacks; - - for( i = 0; i < pBaseComp->nNumPorts; i++ ) { - pBaseComp->pPorts[i]->bIsBufferAllocator = OMX_FALSE; - } - -EXIT: - return (eError); -} - -/* -* GetComponent Version -*/ -OMX_ERRORTYPE OMXBase_GetComponentVersion(OMX_HANDLETYPE hComponent, - OMX_STRING pComponentName, - OMX_VERSIONTYPE *pComponentVersion, - OMX_VERSIONTYPE *pSpecVersion, - OMX_UUIDTYPE *pComponentUUID) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - (void)pComponentUUID; - - OMX_CHECK((hComponent != NULL) && - (pComponentName != NULL) && - (pComponentVersion != NULL) && - (pSpecVersion != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); - - OSAL_Memcpy(pComponentName, pBaseComp->cComponentName, OMX_MAX_STRINGNAME_SIZE); - - *pComponentVersion = pBaseComp->nComponentVersion; - *pSpecVersion = pComp->nVersion; - -EXIT: - return (eError); -} - -/* -* GetState -*/ -OMX_ERRORTYPE OMXBase_GetState(OMX_HANDLETYPE hComponent, - OMX_STATETYPE *pState) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - - OMX_CHECK((hComponent != NULL) && - (pState != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - - *pState = pBaseComp->tCurState; - -EXIT: - return (eError); -} - -/* -* Base Component DeInit -*/ -OMX_ERRORTYPE OMXBase_ComponentDeinit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 i = 0; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMX_CHECK(pBaseComp != NULL, OMX_ErrorBadParameter); - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - OSAL_ObtainMutex(pBaseComp->pMutex, OSAL_SUSPEND); - - /*If component transitioned to invalid state suddenly then dio close and - deinit might have not been called - in that case calle them now */ - if( pBaseComp->tCurState != OMX_StateLoaded ) { - for( i=0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - if( pPort != NULL ) { - if( pPort->hDIO != NULL ) { - eTmpError = OMXBase_DIO_Close(hComponent, - (i + pBaseComp->nMinStartPortIndex)); - if( eTmpError != OMX_ErrorNone ) { - eError = eTmpError; - } - eTmpError = OMXBase_DIO_Deinit(hComponent, - (i + pBaseComp->nMinStartPortIndex)); - if( eTmpError != OMX_ErrorNone ) { - eError = eTmpError; - } - } - } - } - } - - /* deinitialize ports and freeup the memory */ - eTmpError = OMXBase_DeinitializePorts(hComponent); - if( eTmpError != OMX_ErrorNone ) { - eError = eTmpError; - } - - OSAL_ReleaseMutex(pBaseComp->pMutex); - - if (pBaseCompPvt) { - OMXBase_PrivateDeInit(hComponent); - } - - tStatus = OSAL_DeleteMutex(pBaseComp->pMutex); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseComp->pMutex = NULL; - - OSAL_Free(pBaseCompPvt); - pBaseCompPvt = NULL; - -EXIT: - return (eError); -} - -/* -* OMXBase SendCommand -*/ -OMX_ERRORTYPE OMXBase_SendCommand(OMX_HANDLETYPE hComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam1, - OMX_PTR pCmdData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMXBase_CmdParams sCmdParams, sErrorCmdParams; - OMX_U32 nPorts, nStartPortNumber, nIndex; - OMX_PTR pLocalCmdData = NULL; - OMX_BOOL bFreeCmdDataIfError = OMX_TRUE; - OMX_U32 i = 0; - uint32_t nActualSize = 0, nCmdCount = 0; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - if( OMX_CommandMarkBuffer == Cmd ) { - OMX_CHECK(pCmdData != NULL, OMX_ErrorBadParameter); - } - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - nPorts = pBaseComp->nNumPorts; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); - - switch( Cmd ) { - case OMX_CommandStateSet : - /*Return error if unknown state is provided*/ - OMX_CHECK(((OMX_STATETYPE)nParam1 <= - OMX_StateWaitForResources), OMX_ErrorBadParameter); - - /*Mutex protection is for multiple SendCommands on the same - component parallely. This can especially happen in error handling - scenarios. Mutex protection ensure that the NewState variable is not - overwritten.*/ - OSAL_ObtainMutex(pBaseCompPvt->pNewStateMutex, - OSAL_SUSPEND); - /*Multiple state transitions at the same time is not allowed. - Though it is allowed by the spec, we prohibit it in our - implementation*/ - if( OMX_StateMax != pBaseComp->tNewState ) { - eError = OMX_ErrorIncorrectStateTransition; - OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); - goto EXIT; - } - pBaseComp->tNewState = (OMX_STATETYPE)nParam1; - OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); - break; - - case OMX_CommandPortDisable : - /* Index of the port to disable should be less than - * no of ports or equal to OMX_ALL */ - OMX_CHECK((nParam1 < (nStartPortNumber + nPorts)) || - (nParam1 == OMX_ALL), OMX_ErrorBadPortIndex); - if( OMX_ALL == nParam1 ) { - /*Dont want to return same port state error if it never enters - the for loop*/ - if( nPorts > 0 ) { - eError = (OMX_ERRORTYPE)OMX_ErrorNone; - } - - for( nIndex = 0; nIndex < nPorts; nIndex++ ) { - pPort = pBaseComp->pPorts[nIndex]; - /*Atleast 1 port is enabled - dont send same port state error*/ - if( pPort->sPortDef.bEnabled ) { - pPort->sPortDef.bEnabled = OMX_FALSE; - pPort->bIsInTransition = OMX_TRUE; - eError = OMX_ErrorNone; - } - } - } else { - nIndex = nParam1 - nStartPortNumber; - pPort = pBaseComp->pPorts[nIndex]; - if( pPort->sPortDef.bEnabled ) { - pPort->sPortDef.bEnabled = OMX_FALSE; - pPort->bIsInTransition = OMX_TRUE; - } else { - eError = (OMX_ERRORTYPE)OMX_ErrorNone; - } - } - break; - - case OMX_CommandPortEnable : - /* Index of the port to enable should be less than - * no of ports or equal to OMX_ALL */ - OMX_CHECK((nParam1 < (nStartPortNumber + nPorts)) || - (nParam1 == OMX_ALL), OMX_ErrorBadPortIndex); - if( OMX_ALL == nParam1 ) { - /*Dont want to return same port state error if it never enters - the for loop*/ - if( nPorts > 0 ) { - eError = (OMX_ERRORTYPE)OMX_ErrorNone; - } - - for( nIndex = 0; nIndex < nPorts; nIndex++ ) { - pPort = pBaseComp->pPorts[nIndex]; - /*Atleast 1 port is disabled - dont send same port state error*/ - if( !pPort->sPortDef.bEnabled ) { - eError = OMX_ErrorNone; - pPort->sPortDef.bEnabled = OMX_TRUE; - pPort->bIsInTransition = OMX_TRUE; - } - } - } else { - nIndex = nParam1 - nStartPortNumber; - pPort = pBaseComp->pPorts[nIndex]; - if( !pPort->sPortDef.bEnabled ) { - pPort->sPortDef.bEnabled = OMX_TRUE; - pPort->bIsInTransition = OMX_TRUE; - } else { - eError = (OMX_ERRORTYPE)OMX_ErrorNone; - } - } - break; - - case OMX_CommandMarkBuffer : - /*For mark buffer pCmdData points to a structure of type OMX_MARKTYPE. - This may not be valid once send commmand returns so allocate memory and - copy this info there. This memory will be freed up during the command - complete callback for mark buffer.*/ - OMX_CHECK((nParam1 < (nStartPortNumber + nPorts)) || - (nParam1 == OMX_ALL), OMX_ErrorBadPortIndex); - pLocalCmdData = OSAL_Malloc(sizeof(OMX_MARKTYPE)); - OMX_CHECK(pLocalCmdData != NULL, OMX_ErrorInsufficientResources); - OSAL_Memcpy(pLocalCmdData, pCmdData, sizeof(OMX_MARKTYPE)); - break; - - case OMX_CommandFlush : - OMX_CHECK((nParam1 < (nStartPortNumber + nPorts)) || - (nParam1 == OMX_ALL), OMX_ErrorBadPortIndex); - break; - - default : - OMX_CHECK(OMX_FALSE, OMX_ErrorBadParameter); - } - - /*Return error if port enable/disable command is sent on an already - enabled/disabled port*/ - OMX_CHECK(eError == OMX_ErrorNone, eError); - /*For mark buffer store pCmdData in a separate pipe - to be freed up during - command complete callback*/ - if( Cmd == OMX_CommandMarkBuffer ) { - /*If pipe is full, return error - thus a limitation that currently - cannot queue up more than OMXBase_MAXCMDS mark buffer commands*/ - tStatus = OSAL_WriteToPipe(pBaseCompPvt->pCmdDataPipe, - &pLocalCmdData, sizeof(OMX_PTR), OSAL_NO_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - } - /*Obtain mutex for writing to command pipe*/ - tStatus = OSAL_ObtainMutex(pBaseCompPvt->pCmdPipeMutex, OSAL_SUSPEND); - if((tStatus != OSAL_ErrNone) && (Cmd == OMX_CommandMarkBuffer)) { - bFreeCmdDataIfError = OMX_FALSE; - } - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - - /* keep this info, and process later */ - sCmdParams.eCmd = Cmd; - sCmdParams.unParam = nParam1; - if( Cmd == OMX_CommandMarkBuffer ) { - sCmdParams.pCmdData = pLocalCmdData; - } else { - sCmdParams.pCmdData = pCmdData; - } - tStatus = OSAL_WriteToPipe(pBaseCompPvt->pCmdPipe, &sCmdParams, - sizeof(sCmdParams), OSAL_SUSPEND); - if( tStatus != OSAL_ErrNone ) { - /*Do not free pLocalCmdData in this case since it has been pushed to - pipe and will now be freed during deinit when pipe is deleted*/ - if( Cmd == OMX_CommandMarkBuffer ) { - bFreeCmdDataIfError = OMX_FALSE; - } - /*Release the locked mutex and exit with error*/ - eError = OMX_ErrorInsufficientResources; - tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); - goto EXIT; - } - /* This call invokes the process function directly incase if comp - * does process in client context, otherwise triggers compo thread */ - eError = pBaseCompPvt->fpInvokeProcessFunction(hComponent, CMDEVENT); - if( eError != OMX_ErrorNone ) { - if( Cmd == OMX_CommandMarkBuffer ) { - /*Do not free pLocalCmdData in this case since it has been pushed to - pipe and will now be freed during deinit when pipe is deleted*/ - bFreeCmdDataIfError = OMX_FALSE; - } - /*Get the count in cmd pipe - this is to be used for popping the - recently added cmd to the pipe since that is no longer valid*/ - tStatus = OSAL_GetPipeReadyMessageCount(pBaseCompPvt->pCmdPipe, - &nCmdCount); - if( tStatus != OSAL_ErrNone ) { - /*Release mutex and return error*/ - eError = OMX_ErrorUndefined; - tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); - goto EXIT; - } - - for( i = 0; i < nCmdCount; i++ ) { - /*Clear the last command from pipe since error has occured*/ - tStatus = OSAL_ReadFromPipe(pBaseCompPvt->pCmdPipe, &sErrorCmdParams, - sizeof(sErrorCmdParams), &nActualSize, - OSAL_SUSPEND); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - break; - } - if( OSAL_Memcmp(&sErrorCmdParams, &sCmdParams, sizeof(OMXBase_CmdParams)) == 0 ) { - OSAL_ErrorTrace("Found the command to discard"); - break; - } else { - /*This is not the command to be discarded - write it back to - pipe*/ - tStatus = OSAL_WriteToPipe(pBaseCompPvt->pCmdPipe, - &sErrorCmdParams, sizeof(sErrorCmdParams), - OSAL_SUSPEND); - if( tStatus != OSAL_ErrNone ) { - OSAL_ErrorTrace("Write to pipe failed"); - eError = OMX_ErrorUndefined; - break; - } - } - } - - if( i == nCmdCount ) { - /*The command to discard was not found even after going through the - pipe*/ - OSAL_ErrorTrace("Command to be discarded not found in pipe"); - eError = OMX_ErrorUndefined; - } - } - tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - -EXIT: - if( eError != OMX_ErrorNone ) { - if( pLocalCmdData && bFreeCmdDataIfError ) { - OSAL_Free(pLocalCmdData); - pLocalCmdData = NULL; - } - } - return (eError); -} - -/* -* OMX Base Get Parameter -*/ -OMX_ERRORTYPE OMXBase_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nParamIndex, - OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; - OMX_PRIORITYMGMTTYPE *pPriorityMgmt = NULL; - OMX_PARAM_BUFFERSUPPLIERTYPE *pBufSupplier = NULL; - OMX_U32 nStartPortNumber, nPorts, nPortIndex; - - - OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - nPorts = pBaseComp->nNumPorts; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); - - switch( nParamIndex ) { - case OMX_IndexParamAudioInit : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); - if( pBaseComp->pAudioPortParams == NULL ) { - OMX_BASE_INIT_STRUCT_PTR((OMX_PORT_PARAM_TYPE *)(pParamStruct), - OMX_PORT_PARAM_TYPE); - ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts = 0; - ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber = 0; - break; - } - *(OMX_PORT_PARAM_TYPE *)pParamStruct = *(pBaseComp->pAudioPortParams); - break; - - case OMX_IndexParamImageInit : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); - if( pBaseComp->pImagePortParams == NULL ) { - OMX_BASE_INIT_STRUCT_PTR((OMX_PORT_PARAM_TYPE *)(pParamStruct), - OMX_PORT_PARAM_TYPE); - ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts = 0; - ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber = 0; - break; - } - *(OMX_PORT_PARAM_TYPE *)pParamStruct = *(pBaseComp->pImagePortParams); - break; - - case OMX_IndexParamVideoInit : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); - if( pBaseComp->pVideoPortParams == NULL ) { - OMX_BASE_INIT_STRUCT_PTR((OMX_PORT_PARAM_TYPE *)(pParamStruct), - OMX_PORT_PARAM_TYPE); - ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts = 0; - ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber = 0; - break; - } - *(OMX_PORT_PARAM_TYPE *)pParamStruct = - *(pBaseComp->pVideoPortParams); - break; - - case OMX_IndexParamOtherInit : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); - if( pBaseComp->pOtherPortParams == NULL ) { - OMX_BASE_INIT_STRUCT_PTR((OMX_PORT_PARAM_TYPE *)(pParamStruct), - OMX_PORT_PARAM_TYPE); - ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts = 0; - ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber = 0; - break; - } - *(OMX_PORT_PARAM_TYPE *)pParamStruct = *(pBaseComp->pOtherPortParams); - break; - - case OMX_IndexParamPortDefinition : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, - eError); - pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - nPortIndex = pPortDef->nPortIndex - nStartPortNumber; - /* check for valid port index */ - OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex); - *pPortDef = pBaseComp->pPorts[nPortIndex]->sPortDef; - - break; - - case OMX_IndexParamCompBufferSupplier : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_BUFFERSUPPLIERTYPE, eError); - pBufSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)pParamStruct; - nPortIndex = pBufSupplier->nPortIndex - nStartPortNumber; - /* check for valid port index */ - OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex); - pPort = pBaseComp->pPorts[nPortIndex]; - pBufSupplier->eBufferSupplier = 0x0; - break; - - case OMX_IndexParamPriorityMgmt : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PRIORITYMGMTTYPE, eError); - pPriorityMgmt = (OMX_PRIORITYMGMTTYPE *)pParamStruct; - break; - - default : - OSAL_ErrorTrace("Unknown Index received "); - eError = OMX_ErrorUnsupportedIndex; - break; - } - -EXIT: - return (eError); -} - -/* -* OMX Base SetParameter -*/ -OMX_ERRORTYPE OMXBase_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_PRIORITYMGMTTYPE *pPriorityMgmt = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pLocalPortDef; - OMX_PARAM_BUFFERSUPPLIERTYPE *pBufSupplier = NULL; - OMX_U32 nStartPortNumber, nPorts, nPortIndex; - OMX_PARAM_BUFFERSUPPLIERTYPE sTunBufSupplier; - OMX_TI_PARAMUSENATIVEBUFFER *pParamNativeBuffer = NULL; - - OMX_CHECK((hComponent != NULL) && - (pParamStruct != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - nPorts = pBaseComp->nNumPorts; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, - OMX_ErrorInvalidState); - /* This method is not allowed when the component is not in the loaded - * state or the the port is not disabled */ - if((OMX_IndexParamPriorityMgmt == nIndex - || OMX_IndexParamAudioInit == nIndex - || OMX_IndexParamVideoInit == nIndex - || OMX_IndexParamImageInit == nIndex - || OMX_IndexParamOtherInit == nIndex) - && (pBaseComp->tCurState != OMX_StateLoaded)) { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - switch( (int) nIndex ) { - case OMX_IndexParamPriorityMgmt : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PRIORITYMGMTTYPE, eError); - pPriorityMgmt = (OMX_PRIORITYMGMTTYPE *)pParamStruct; - break; - - case OMX_IndexParamPortDefinition : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, - eError); - pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - - nPortIndex = pPortDef->nPortIndex - nStartPortNumber; - /* check for valid port index */ - OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex); - pPort = pBaseComp->pPorts[nPortIndex]; - /* successfully only when the comp is in loaded or disabled port */ - OMX_CHECK((pBaseComp->tCurState == OMX_StateLoaded) || - (pPort->sPortDef.bEnabled == OMX_FALSE), - OMX_ErrorIncorrectStateOperation); - - pLocalPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - /*Copying only the modifiabke fields. Rest are all read only fields*/ - pBaseComp->pPorts[nPortIndex]->sPortDef.nBufferCountActual = - pLocalPortDef->nBufferCountActual; - pBaseComp->pPorts[nPortIndex]->sPortDef.format = pLocalPortDef->format; - break; - - /*These are compulsory parameters hence being supported by base*/ - case OMX_IndexParamAudioInit : - case OMX_IndexParamVideoInit : - case OMX_IndexParamImageInit : - case OMX_IndexParamOtherInit : - /*All fields of OMX_PORT_PARAM_TYPE are read only so SetParam will just - return and not overwrite anything*/ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); - break; - - case OMX_TI_IndexUseNativeBuffers: - pParamNativeBuffer = (OMX_TI_PARAMUSENATIVEBUFFER* )pParamStruct; - if(pParamNativeBuffer->bEnable == OMX_TRUE) { - pBaseComp->pPorts[pParamNativeBuffer->nPortIndex - nStartPortNumber]->sProps.eBufMemoryType = MEM_GRALLOC; - } else { - pBaseComp->pPorts[pParamNativeBuffer->nPortIndex - nStartPortNumber]->sProps.eBufMemoryType = MEM_CARVEOUT; - } - break; - - default : - eError = OMX_ErrorUnsupportedIndex; - break; - } - -EXIT: - return (eError); -} - -/* -* OMX Base AllocatBuffer -*/ -OMX_ERRORTYPE OMXBase_AllocateBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * *ppBufferHdr, - OMX_U32 nPortIndex, - OMX_PTR pAppPrivate, - OMX_U32 nSizeBytes) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_DIO_CreateParams sDIOCreateParams; - OMX_DIO_OpenParams sDIOOpenParams; - OMX_U32 nStartPortNumber = 0, nPorts = 0; - - OMX_CHECK((hComponent != NULL) && (nSizeBytes > 0), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - OSAL_ObtainMutex(pBaseCompPvt->pPortDisableMutex, OSAL_SUSPEND); - - nStartPortNumber = pBaseComp->nMinStartPortIndex; - nPorts = pBaseComp->nNumPorts; - OMX_CHECK(nPortIndex >= nStartPortNumber && nPortIndex < nPorts, - OMX_ErrorBadPortIndex); - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, - OMX_ErrorInvalidState); - - pPort = pBaseComp->pPorts[nPortIndex - nStartPortNumber]; - - /*Buffer size should be >= the minimum buffer size specified in - port definition*/ - OMX_CHECK(nSizeBytes >= pPort->sPortDef.nBufferSize, - OMX_ErrorBadParameter); - if((pBaseComp->tCurState == OMX_StateLoaded || - pBaseComp->tCurState == OMX_StateWaitForResources) && - (pBaseComp->tNewState == OMX_StateIdle) && - (pPort->sPortDef.bEnabled)) { - /*Allowed during loaded/waitforresources --> idle transition if port is - enabled*/ - } else if((pPort->bIsInTransition) && - (pBaseComp->tCurState != OMX_StateLoaded) && - (pBaseComp->tCurState != OMX_StateWaitForResources)) { - /*Allowed when port is transitioning to enabled if current state is not - loaded/waitforresources*/ - } else { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - /*Port should not be already populated*/ - OMX_CHECK(pPort->sPortDef.bPopulated == OMX_FALSE, - OMX_ErrorBadParameter); - if( pPort->nBufferCnt == 0 ) { - /* Initialize DIO and open as a supplier */ - pPort->bIsBufferAllocator = OMX_TRUE; - sDIOCreateParams.hComponent = hComponent; - sDIOCreateParams.nPortIndex = pPort->sPortDef.nPortIndex; - sDIOCreateParams.pAppCallbacks = &(pBaseCompPvt->sAppCallbacks); - if( pPort->sPortDef.eDir == OMX_DirOutput ) { - sDIOOpenParams.nMode = OMX_DIO_WRITER; - } else { - sDIOOpenParams.nMode = OMX_DIO_READER; - } - - sDIOOpenParams.nBufSize = nSizeBytes; - eError = OMXBase_DIO_Init(hComponent, nPortIndex, "OMX.DIO.NONTUNNEL", - &sDIOCreateParams); - OMX_CHECK(eError == OMX_ErrorNone, eError); - eError = OMXBase_DIO_Open(hComponent, nPortIndex, &sDIOOpenParams); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - /*update buffer header from buffer list */ - *ppBufferHdr = pPort->pBufferlist[pPort->nBufferCnt]; - if( pPort->sPortDef.eDir == OMX_DirInput ) { - (*ppBufferHdr)->nInputPortIndex = pPort->sPortDef.nPortIndex; - (*ppBufferHdr)->nOutputPortIndex = OMX_NOPORT; - } else if( pPort->sPortDef.eDir == OMX_DirOutput ) { - (*ppBufferHdr)->nOutputPortIndex = pPort->sPortDef.nPortIndex; - (*ppBufferHdr)->nInputPortIndex = OMX_NOPORT; - } - (*ppBufferHdr)->pAppPrivate = pAppPrivate; - (*ppBufferHdr)->nAllocLen = nSizeBytes; - - pPort->nBufferCnt++; - if( pPort->sPortDef.nBufferCountActual == pPort->nBufferCnt ) { - pPort->sPortDef.bPopulated = OMX_TRUE; - tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, BUF_ALLOC_EVENT, - OSAL_EVENT_OR); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - } - -EXIT: - if ((hComponent != NULL) && (nSizeBytes > 0)) { - OSAL_ReleaseMutex(pBaseCompPvt->pPortDisableMutex); - } - return (eError); -} - -/* -* OMX Base UseBuffer -*/ -OMX_ERRORTYPE OMXBase_UseBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * *ppBufferHdr, - OMX_U32 nPortIndex, - OMX_PTR pAppPrivate, - OMX_U32 nSizeBytes, - OMX_U8 *pBuffer) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_DIO_CreateParams sDIOCreateParams; - OMX_DIO_OpenParams sDIOOpenParams; - OMX_U32 nStartPortNumber = 0, nPorts = 0; - - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - OSAL_ObtainMutex(pBaseCompPvt->pPortDisableMutex, OSAL_SUSPEND); - - nStartPortNumber = pBaseComp->nMinStartPortIndex; - nPorts = pBaseComp->nNumPorts; - OMX_CHECK(nPortIndex >= nStartPortNumber && nPortIndex < nPorts, - OMX_ErrorBadPortIndex); - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, - OMX_ErrorInvalidState); - - pPort = pBaseComp->pPorts[nPortIndex - nStartPortNumber]; - - if((pBaseComp->tCurState == OMX_StateLoaded || - pBaseComp->tCurState == OMX_StateWaitForResources) && - (pBaseComp->tNewState == OMX_StateIdle) && - (pPort->sPortDef.bEnabled)) { - /*Allowed during loaded/waitforresources --> idle transition if port is - enabled*/ - } else if((pPort->bIsInTransition) && - (pBaseComp->tCurState != OMX_StateLoaded) && - (pBaseComp->tCurState != OMX_StateWaitForResources)) { - /*Allowed when port is transitioning to enabled if current state is not - loaded/waitforresources*/ - } else { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - OMX_CHECK(pPort->sPortDef.bPopulated == OMX_FALSE, - OMX_ErrorBadParameter); - - if( pPort->nBufferCnt == 0 ) { - /* Initialize DIO if not initialized and open as a non supplier */ - pPort->bIsBufferAllocator = OMX_FALSE; - if( pPort->hDIO == NULL) { - sDIOCreateParams.hComponent = hComponent; - sDIOCreateParams.nPortIndex = pPort->sPortDef.nPortIndex; - sDIOCreateParams.pAppCallbacks = &(pBaseCompPvt->sAppCallbacks); - - if( pPort->sPortDef.eDir == OMX_DirOutput ) { - sDIOOpenParams.nMode = OMX_DIO_WRITER; - } else { - sDIOOpenParams.nMode = OMX_DIO_READER; - } - - sDIOOpenParams.nBufSize = nSizeBytes; - eError = OMXBase_DIO_Init(hComponent, nPortIndex, - "OMX.DIO.NONTUNNEL", &sDIOCreateParams); - OMX_CHECK(eError == OMX_ErrorNone, eError); - eError = OMXBase_DIO_Open(hComponent, nPortIndex, &sDIOOpenParams); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - } - /*update buffer header from buffer list */ - pPort->pBufferlist[pPort->nBufferCnt]->pBuffer = pBuffer; - *ppBufferHdr = pPort->pBufferlist[pPort->nBufferCnt]; - if( pPort->sPortDef.eDir == OMX_DirInput ) { - (*ppBufferHdr)->nInputPortIndex = pPort->sPortDef.nPortIndex; - (*ppBufferHdr)->nOutputPortIndex = OMX_NOPORT; - } else if( pPort->sPortDef.eDir == OMX_DirOutput ) { - (*ppBufferHdr)->nOutputPortIndex = pPort->sPortDef.nPortIndex; - (*ppBufferHdr)->nInputPortIndex = OMX_NOPORT; - } - (*ppBufferHdr)->pAppPrivate = pAppPrivate; - (*ppBufferHdr)->nAllocLen = nSizeBytes; - - if (pBaseComp->fpXlateBuffHandle != NULL) { - eError = pBaseComp->fpXlateBuffHandle(hComponent, (OMX_PTR)(*ppBufferHdr), OMX_TRUE); - } - - pPort->nBufferCnt++; - if( pPort->sPortDef.nBufferCountActual == pPort->nBufferCnt ) { - pPort->sPortDef.bPopulated = OMX_TRUE; - tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, BUF_ALLOC_EVENT, - OSAL_EVENT_OR); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - } -EXIT: - if (hComponent != NULL) { - OSAL_ReleaseMutex(pBaseCompPvt->pPortDisableMutex); - } - return (eError); -} - -/* -* OMX Base FreeBuffer -*/ -OMX_ERRORTYPE OMXBase_FreeBuffer(OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_BUFFERHEADERTYPE *pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 nStartPortNumber = 0, nPorts = 0; - - OMX_CHECK((hComponent != NULL) && - (pBuffHeader != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - nPorts = pBaseComp->nNumPorts; - OMX_CHECK(nPortIndex >= nStartPortNumber && nPortIndex < nPorts, - OMX_ErrorBadPortIndex); - - pPort = pBaseComp->pPorts[nPortIndex - nStartPortNumber]; - - OMX_BASE_CHK_VERSION(pBuffHeader, OMX_BUFFERHEADERTYPE, eError); - /*Free buffer should not be called on a port after all buffers have been - freed*/ - OMX_CHECK(pPort->nBufferCnt != 0, OMX_ErrorBadParameter); - - /* unregister the buffer with decoder for non-allocator port*/ - if (!pPort->bIsBufferAllocator && pBaseComp->fpXlateBuffHandle != NULL) { - eError = pBaseComp->fpXlateBuffHandle(hComponent, (OMX_PTR)(pBuffHeader), OMX_FALSE); - } - - /* Just decrement the buffer count and unpopulate the port, - * buffer header pool is freed up once all the buffers are received */ - pPort->nBufferCnt--; - pPort->sPortDef.bPopulated = OMX_FALSE; - if( pBaseComp->tCurState == OMX_StateIdle && - pBaseComp->tNewState == OMX_StateLoaded && pPort->sPortDef.bEnabled ) { - /*Allowed on idle --> loaded transition if port is enabled*/ - } else if((pPort->bIsInTransition) && - (pBaseComp->tCurState != OMX_StateLoaded) && - (pBaseComp->tCurState != OMX_StateWaitForResources)) { - /*Allowed during port disable if current state is not - loaded/waitforresources*/ - } else { - eError = pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventError, (OMX_U32)OMX_ErrorPortUnpopulated, - nPortIndex, " PortUnpopulated "); - /*Ideally callback should never return error*/ - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - if( pPort->nBufferCnt == 0 ) { - tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, BUF_FREE_EVENT, - OSAL_EVENT_OR); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - } - -EXIT: - if((eTmpError != OMX_ErrorNone) && (eError == OMX_ErrorNone)) { - /*An error occured earlier but we still continued cleanup to avoid leaks. - Setting the return value to the error code now*/ - eError = eTmpError; - } - return (eError); -} - -/* -* Empty This Buffer -*/ -OMX_ERRORTYPE OMXBase_EmptyThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE *pBuffer) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 nPorts, nStartPortNumber; - - OMX_CHECK((hComponent != NULL) && - (pBuffer != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - nPorts = pBaseComp->nNumPorts; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); - /* check for valid port index */ - OMX_CHECK(pBuffer->nInputPortIndex < (nPorts + nStartPortNumber), OMX_ErrorBadPortIndex); - - pPort = pBaseComp->pPorts[pBuffer->nInputPortIndex - nStartPortNumber]; - if( pPort->sPortDef.eDir != OMX_DirInput ) { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - /* This method is allowed only when the comp is in or a transition - * to executing or pause state */ - OMX_CHECK((pBaseComp->tCurState == OMX_StateIdle && - pBaseComp->tNewState == OMX_StateExecuting) || - (pBaseComp->tCurState == OMX_StateExecuting || - pBaseComp->tCurState == OMX_StatePause), - OMX_ErrorIncorrectStateOperation); - - /*Following two checks are based on the 1.1.2 AppNote*/ - /*Supplier ports can accept buffers even if current state is disabled - if they are transitioning from port enable to disable*/ - if( pPort->sPortDef.bEnabled != OMX_TRUE ) { - if((!pPort->bIsInTransition) || (!pPort->bIsBufferAllocator)) { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - /*Non-supplier ports can't accept buffers when transitioning to Idle - or when port is being transitioned to disabled*/ - if( !pPort->bIsBufferAllocator) { - if((pBaseComp->tNewState == OMX_StateIdle) || (pPort->bIsInTransition)) { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - eError = OMXBase_DIO_Queue(hComponent, pBuffer->nInputPortIndex, pBuffer); - OMX_CHECK(eError == OMX_ErrorNone, eError); - ((OMXBase_BufHdrPvtData *)(pBuffer->pPlatformPrivate))->bufSt = OWNED_BY_US; - - /*If another buffer comes after eos then reset the variable that causes - watermark to become meaningless on this port*/ - if( pPort->bEosRecd == OMX_TRUE ) { - pPort->bEosRecd = OMX_FALSE; - } - /*If EOS buffer or CodecConfig buffer then force notify to derived component*/ - if( pBuffer->nFlags & OMX_BUFFERFLAG_EOS ) { - pPort->bEosRecd = OMX_TRUE; - } - eError = pBaseCompPvt->fpInvokeProcessFunction(hComponent, DATAEVENT); - -EXIT: - return (eError); -} - -/* -* OMX Base FillThisBuffer -*/ -OMX_ERRORTYPE OMXBase_FillThisBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE *pBuffer) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 nPorts, nStartPortNumber; - - OMX_CHECK((hComponent != NULL) && (pBuffer != NULL), OMX_ErrorBadParameter); - OMX_CHECK(pBuffer->pBuffer != NULL, OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - nPorts = pBaseComp->nNumPorts; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, - OMX_ErrorInvalidState); - - /* check for valid port index */ - OMX_CHECK(pBuffer->nOutputPortIndex < (nPorts + - nStartPortNumber), OMX_ErrorBadPortIndex); - - pPort = pBaseComp->pPorts[pBuffer->nOutputPortIndex - nStartPortNumber]; - if( pPort->sPortDef.eDir != OMX_DirOutput ) { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - - /* This method is allowed only when the comp is in or a transition - * to executing or pause state */ - OMX_CHECK((pBaseComp->tCurState == OMX_StateIdle && - pBaseComp->tNewState == OMX_StateExecuting) || - (pBaseComp->tCurState == OMX_StateExecuting || - pBaseComp->tCurState == OMX_StatePause), - OMX_ErrorIncorrectStateOperation); - /*Following two checks are based on the 1.1.2 AppNote*/ - /*Supplier ports can accept buffers even if current state is disabled - if they are transitioning from port enable to disable*/ - if( pPort->sPortDef.bEnabled != OMX_TRUE ) { - if((!pPort->bIsInTransition) || (!pPort->bIsBufferAllocator)) { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - /*Non-supplier ports can't accept buffers when transitioning to Idle - or when port is being transitioned to disabled*/ - if( !pPort->bIsBufferAllocator) { - if((pBaseComp->tNewState == OMX_StateIdle) || - (pPort->bIsInTransition)) { - eError = OMX_ErrorIncorrectStateOperation; - goto EXIT; - } - } - eError = OMXBase_DIO_Queue(hComponent, pBuffer->nOutputPortIndex, pBuffer); - OMX_CHECK(eError == OMX_ErrorNone, eError); - ((OMXBase_BufHdrPvtData *)(pBuffer->pPlatformPrivate))->bufSt = OWNED_BY_US; - eError = pBaseCompPvt->fpInvokeProcessFunction(hComponent, DATAEVENT); - -EXIT: - return (eError); -} - -/* -* OMX Base SetConfig -*/ -OMX_ERRORTYPE OMXBase_SetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 nStartPortNumber, nPortIndex, nPorts; - - OMX_CHECK((hComponent != NULL) && - (pComponentConfigStructure != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - nPorts = pBaseComp->nNumPorts; - - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, - OMX_ErrorInvalidState); - - switch( nIndex ) { - default : - eError = OMX_ErrorUnsupportedIndex; - break; - } - -EXIT: - return (eError); -} - -/* -* OMX Base GetConfig -*/ -OMX_ERRORTYPE OMXBase_GetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentConfigStructure) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 nStartPortNumber, nPortIndex, nPorts; - - OMX_CHECK((hComponent != NULL) && - (pComponentConfigStructure != NULL), OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - nPorts = pBaseComp->nNumPorts; - - /*Can't be invoked when the comp is in invalid state*/ - OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); - - switch( nIndex ) { - default : - eError = OMX_ErrorUnsupportedIndex; - break; - } - -EXIT: - return (eError); -} - -/* -* OMX Base UseEGLImage -*/ -OMX_ERRORTYPE OMXBase_UseEGLImage(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * *ppBufferHdr, - OMX_U32 nPortIndex, - OMX_PTR pAppPrivate, - void *eglImage) -{ - (void)hComponent, ppBufferHdr, nPortIndex, pAppPrivate, eglImage; - return (OMX_ErrorNotImplemented); -} - -/* -* OMX Base GetExtentionIndex -*/ -OMX_ERRORTYPE OMXBase_GetExtensionIndex(OMX_HANDLETYPE hComponent, - OMX_STRING cParameterName, - OMX_INDEXTYPE *pIndexType) -{ - (void)hComponent, cParameterName, pIndexType; - return (OMX_ErrorNotImplemented); -} - -/* -* OMX Base ComponentRoleEnum -*/ -OMX_ERRORTYPE OMXBase_ComponentRoleEnum(OMX_HANDLETYPE hComponent, - OMX_U8 *cRole, - OMX_U32 nIndex) -{ - (void)hComponent, cRole, nIndex; - return (OMX_ErrorNotImplemented); -} - diff --git a/omx/base/omx_base_comp/src/omx_base_callbacks.c b/omx/base/omx_base_comp/src/omx_base_callbacks.c deleted file mode 100644 index 687a418..0000000 --- a/omx/base/omx_base_comp/src/omx_base_callbacks.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_BASE_CALLBACKS" - -#include <OMX_Core.h> -#include <omx_base.h> - -/* -* OMX Base callback ReturnEventNotify -*/ -OMX_ERRORTYPE OMXBase_CB_ReturnEventNotify(OMX_HANDLETYPE hComponent, - OMX_EVENTTYPE eEvent, - OMX_U32 nData1, OMX_U32 nData2, - OMX_PTR pEventData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OSAL_ERROR tStatus = OSAL_ErrNone; - uint32_t nActualSize = 0; - OMX_PTR pCmdData = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - switch( eEvent ) { - case OMX_EventCmdComplete : - if((OMX_COMMANDTYPE)nData1 == OMX_CommandStateSet ) { - OSAL_SetEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdStateSet, OSAL_EVENT_OR); - } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandPortEnable ) { - OSAL_SetEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdPortEnable, OSAL_EVENT_OR); - } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandPortDisable ) { - OSAL_SetEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdPortDisable, OSAL_EVENT_OR); - } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandFlush ) { - OSAL_SetEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdFlush, OSAL_EVENT_OR); - } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandMarkBuffer ) { - /*The derived component has completed the mark buffer command so - the memory allocated for pCmdData is no longer needed - it can - be freed up*/ - tStatus = OSAL_ReadFromPipe(pBaseCompPvt->pCmdDataPipe, - &pCmdData, sizeof(OMX_PTR), &nActualSize, - OSAL_NO_SUSPEND); - /*Read from pipe should return immediately with valid value - if - it does not, return error callback to the client*/ - if( OSAL_ErrNone != tStatus ) { - OSAL_ErrorTrace("pCmdData not available to freed up at mark \ - buffer command completion. Returning error event."); - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, OMX_EventError, - (OMX_U32)OMX_ErrorInsufficientResources, 0, NULL); - goto EXIT; - } - OSAL_Free(pCmdData); - /*For mark buffer cmd complete, directly send callback to the - client. This callback is not being handled in - OMXBase_EventNotifyToClient since this can happen much later - than the time when the mark comand was received*/ - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, - pEventData); - } - break; - - case OMX_EventError : - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - - case OMX_EventMark : - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - - case OMX_EventPortSettingsChanged : - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - - case OMX_EventBufferFlag : - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - - case OMX_EventResourcesAcquired : - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - - case OMX_EventComponentResumed : - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - - case OMX_EventDynamicResourcesAvailable : - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - - case OMX_EventPortFormatDetected : - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - - default : - OSAL_ErrorTrace("Unknown event received - still making callback"); - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); - break; - } - -EXIT: - return (eError); -} - diff --git a/omx/base/omx_base_comp/src/omx_base_internal.c b/omx/base/omx_base_comp/src/omx_base_internal.c deleted file mode 100644 index a575491..0000000 --- a/omx/base/omx_base_comp/src/omx_base_internal.c +++ /dev/null @@ -1,1580 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_BASE_INTERNAL" - -#include <string.h> - -#include <OMX_Core.h> -#include <OMX_Component.h> -#include <omx_base.h> -#include <omx_base_dio_plugin.h> -#include <osal_semaphores.h> - -#define OMXBase_TASKDEL_TRIES 1000 -#define OMXBase_TASKDEL_SLEEP 2 -#define BUFFER_ALLOC_FREE_TIMEOUT 900 //900ms - -#define OMX_BASE_HANDLE_IDLE_TO_LOADED_TRANSITION() do { \ - for( i=0; i < pBaseComp->nNumPorts; i++ ) \ - { \ - pPort = pBaseComp->pPorts[i]; \ - if( pPort->pBufAllocFreeEvent ) \ - { \ - tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, \ - BUF_FAIL_EVENT, OSAL_EVENT_OR); \ - if( tStatus != OSAL_ErrNone ) { \ - eError = OMX_ErrorUndefined; } \ - } \ - } \ - retEvents = 0; \ - tStatus = OSAL_RetrieveEvent( \ - pBaseCompPvt->pErrorCmdcompleteEvent, \ - ERROR_EVENT, OSAL_EVENT_OR_CONSUME, &retEvents, \ - STATE_TRANSITION_LONG_TIMEOUT); \ - OMX_CHECK(tStatus == OSAL_ErrNone, \ - OMX_ErrorUndefined); \ -} while( 0 ) - - -/* -* OMX Base Private Init -*/ -OMX_ERRORTYPE OMXBase_PrivateInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp*)pComp->pComponentPrivate; - OMX_CHECK(pBaseComp != NULL, OMX_ErrorBadParameter); - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - /*Create the new state mutex*/ - tStatus = OSAL_CreateMutex(&(pBaseCompPvt->pNewStateMutex)); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - /* create a fixed size command pipe to queueup commands */ - tStatus = OSAL_CreatePipe(&(pBaseCompPvt->pCmdPipe), - OMXBase_MAXCMDS * sizeof(OMXBase_CmdParams), - sizeof(OMXBase_CmdParams), 1); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - - /* create a fixed size pipe to queueup command data pointers */ - tStatus = OSAL_CreatePipe(&(pBaseCompPvt->pCmdDataPipe), - OMXBase_MAXCMDS * sizeof(OMX_PTR), - sizeof(OMX_PTR), 1); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - /*create an Event for Command completion to be set by Dervived Component */ - tStatus = OSAL_CreateEvent(&(pBaseCompPvt->pCmdCompleteEvent)); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - /*create an Event for state transition notifications for complete tear down of compoenent */ - tStatus = OSAL_CreateEvent(&(pBaseCompPvt->pErrorCmdcompleteEvent)); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - /*Create mutex for cmd pipe*/ - tStatus = OSAL_CreateMutex(&(pBaseCompPvt->pCmdPipeMutex)); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - pBaseCompPvt->fpInvokeProcessFunction = OMXBase_ProcessEvents; - - tStatus = OSAL_CreateEvent(&(pBaseCompPvt->pTriggerEvent)); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - /*Create mutex for port disable*/ - tStatus = OSAL_CreateMutex(&(pBaseCompPvt->pPortDisableMutex)); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - OSAL_Memcpy(pBaseCompPvt->cTaskName, pBaseComp->cComponentName, strlen(pBaseComp->cComponentName)); - pBaseCompPvt->nStackSize = OMX_BASE_THREAD_STACKSIZE; - pBaseCompPvt->nPrioirty = OMX_BASE_THREAD_PRIORITY; - - tStatus = OSAL_CreateTask(&pBaseCompPvt->pThreadId, - (OSAL_TaskProc)OMXBase_CompThreadEntry, 0, - (void *)hComponent, - pBaseCompPvt->nStackSize, - pBaseCompPvt->nPrioirty, - (OMX_S8 *)pBaseCompPvt->cTaskName); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - - pBaseCompPvt->fpInvokeProcessFunction = OMXBase_ProcessTriggerEvent; - - /* Set hooks from Derived to Base communicattion */ - pBaseCompPvt->fpDioGetCount = OMXBase_DIO_GetCount; - pBaseCompPvt->fpDioQueue = OMXBase_DIO_Queue; - pBaseCompPvt->fpDioDequeue = OMXBase_DIO_Dequeue; - pBaseCompPvt->fpDioSend = OMXBase_DIO_Send; - pBaseCompPvt->fpDioCancel = OMXBase_DIO_Cancel; - pBaseCompPvt->fpDioControl = OMXBase_DIO_Control; - -EXIT: - return eError; -} - -/* -* OMX Base Private DeInit -*/ - -OMX_ERRORTYPE OMXBase_PrivateDeInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMX_U32 i = 0, nTries = 0; - uint32_t nCount = 0; - OMX_PTR pData = NULL; - uint32_t nActualSize = 0; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMX_CHECK(pBaseComp != NULL, OMX_ErrorBadParameter); - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - /* set an ENDEVENT before destroying thread */ - pBaseCompPvt->fpInvokeProcessFunction(hComponent, ENDEVENT); - tStatus = OSAL_DeleteTask(pBaseCompPvt->pThreadId); - - while( tStatus == OSAL_ErrNotReady && - nTries < OMXBase_TASKDEL_TRIES ) { - //Wait for some time and try again - OSAL_SleepTask(OMXBase_TASKDEL_SLEEP); - nTries++; - tStatus = OSAL_DeleteTask(pBaseCompPvt->pThreadId); - } - - /* - * Obtain the mutex after deleting the task. The task may be - * currently executing and may need access to the mutex to - * properly exit - */ - OSAL_ObtainMutex(pBaseCompPvt->pNewStateMutex, OSAL_SUSPEND); - - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorTimeout; - OSAL_ErrorTrace("Error while deleting task"); - } - if( pBaseCompPvt->pTriggerEvent ) { - tStatus = OSAL_DeleteEvent(pBaseCompPvt->pTriggerEvent); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseCompPvt->pTriggerEvent = NULL; - } - - if( pBaseCompPvt->pCmdCompleteEvent ) { - tStatus = OSAL_DeleteEvent(pBaseCompPvt->pCmdCompleteEvent); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseCompPvt->pCmdCompleteEvent = NULL; - } - if( pBaseCompPvt->pErrorCmdcompleteEvent ) { - tStatus = OSAL_DeleteEvent(pBaseCompPvt->pErrorCmdcompleteEvent); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseCompPvt->pErrorCmdcompleteEvent = NULL; - } - if( pBaseCompPvt->pCmdPipe ) { - tStatus = OSAL_DeletePipe(pBaseCompPvt->pCmdPipe); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseCompPvt->pCmdPipe = NULL; - } - if( pBaseCompPvt->pCmdDataPipe ) { - /*If pipe still has some data then empty the data and free the memory*/ - tStatus = OSAL_GetPipeReadyMessageCount(pBaseCompPvt->pCmdDataPipe, - &nCount); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } else { - while( nCount > 0 ) { - tStatus = OSAL_ReadFromPipe(pBaseCompPvt->pCmdDataPipe, - pData, sizeof(OMX_PTR), &nActualSize, OSAL_NO_SUSPEND); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - break; - } - OSAL_Free(pData); - nCount--; - } - } - tStatus = OSAL_DeletePipe(pBaseCompPvt->pCmdDataPipe); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseCompPvt->pCmdDataPipe = NULL; - } - if( pBaseCompPvt->pCmdPipeMutex ) { - tStatus = OSAL_DeleteMutex(pBaseCompPvt->pCmdPipeMutex); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseCompPvt->pCmdPipeMutex = NULL; - } - if (pBaseCompPvt->pPortDisableMutex) { - tStatus = OSAL_DeleteMutex(pBaseCompPvt->pPortDisableMutex); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseCompPvt->pPortDisableMutex = NULL; - } - - OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); - - if( pBaseCompPvt->pNewStateMutex ) { - tStatus = OSAL_DeleteMutex(pBaseCompPvt->pNewStateMutex); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pBaseCompPvt->pNewStateMutex = NULL; - } - -EXIT: - return (eError); -} - -/* -* OMX Base InitializePorts -*/ -OMX_ERRORTYPE OMXBase_InitializePorts(OMX_HANDLETYPE hComponent) -{ - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_U32 i = 0; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - - pBaseComp->pPorts = (OMXBase_Port **)OSAL_Malloc(sizeof(OMXBase_Port *) * - pBaseComp->nNumPorts); - OMX_CHECK(pBaseComp->pPorts != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pBaseComp->pPorts, 0, sizeof(OMXBase_Port *) * - pBaseComp->nNumPorts); - - for( i = 0; i < pBaseComp->nNumPorts; i++ ) { - pBaseComp->pPorts[i] = (OMXBase_Port *)OSAL_Malloc(sizeof(OMXBase_Port)); - OMX_CHECK(pBaseComp->pPorts[i] != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pBaseComp->pPorts[i], 0x0, sizeof(OMXBase_Port)); - - OMX_BASE_INIT_STRUCT_PTR(&(pBaseComp->pPorts[i]->sPortDef), - OMX_PARAM_PORTDEFINITIONTYPE); - pBaseComp->pPorts[i]->sPortDef.nPortIndex = i; - - tStatus = OSAL_CreateEvent(&(pBaseComp->pPorts[i]->pBufAllocFreeEvent)); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - tStatus = OSAL_CreateSemaphore(&(pBaseComp->pPorts[i]->pDioOpenCloseSem), 0); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - } - -EXIT: - if( OMX_ErrorNone != eError ) { - eTmpError = eError; - eError = OMXBase_DeinitializePorts(hComponent); - eError = eTmpError; - } - return (eError); -} - -/* -* OMX Base DeInitialize Ports -*/ -OMX_ERRORTYPE OMXBase_DeinitializePorts(OMX_HANDLETYPE hComponent) -{ - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBase_Port *pPort = NULL; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_U32 i = 0; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMX_CHECK(pBaseComp != NULL, eError); - - for( i=0; i < pBaseComp->nNumPorts; i++ ) { - if( !(pBaseComp->pPorts)) { - break; - } - pPort = pBaseComp->pPorts[i]; - if( pPort == NULL ) { - continue; - } - if( pPort->pDioOpenCloseSem ) { - tStatus = OSAL_DeleteSemaphore(pPort->pDioOpenCloseSem); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - } - /*If any tasks are waiting on this event then send fail event to - indicate that component is being unloaded*/ - if( pPort->pBufAllocFreeEvent ) { - tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, - BUF_FAIL_EVENT, OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - tStatus = OSAL_DeleteEvent(pPort->pBufAllocFreeEvent); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - } - OSAL_Free(pPort); - pPort = NULL; - } - - if( pBaseComp->pPorts ) { - OSAL_Free(pBaseComp->pPorts); - pBaseComp->pPorts = NULL; - } - -EXIT: - return (eError); -} - - -/* -* OMX Base SetDefault Properties -*/ -OMX_ERRORTYPE OMXBase_SetDefaultProperties(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMX_U32 nIndx = 0; - - for( nIndx = 0; nIndx < (pBaseComp->nNumPorts); nIndx++ ) { - pBaseComp->pPorts[nIndx]->sProps.nWatermark = 1; - /*Frame mode is the default mode*/ - pBaseComp->pPorts[nIndx]->sProps.eDataAccessMode = MemAccess_8Bit; - - /*Buffer allocation type is set to default*/ - pBaseComp->pPorts[nIndx]->sProps.eBufMemoryType = MEM_CARVEOUT; - /*Number of component buffers set to 1*/ - pBaseComp->pPorts[nIndx]->sProps.nNumComponentBuffers = 1; - /*No bufefr params by default. To be used in case of 2D buffers*/ - // pBaseComp->pPortProperties[nIndx]->pBufParams = NULL; - pBaseComp->pPorts[nIndx]->sProps.nTimeoutForDequeue = OSAL_SUSPEND; - } - - pBaseComp->bNotifyForAnyPort = OMX_TRUE; - - return (eError); -} - - -/* -* OMX Base ThreadEntry -*/ -void OMXBase_CompThreadEntry(void *arg) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)arg; - uint32_t retrievedEvents = 0; - - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - while( 1 ) { - /* wait for Any of the event/s to process */ - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pTriggerEvent, - (CMDEVENT | DATAEVENT | ENDEVENT), - OSAL_EVENT_OR_CONSUME, - &retrievedEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorInsufficientResources); - /* terminate the process when it acquires an ENDEVENT */ - if( retrievedEvents & ENDEVENT ) { - break; - } - /* Process Event that has retrieved */ - if( retrievedEvents & CMDEVENT ) { - while( OSAL_IsPipeReady(pBaseCompPvt->pCmdPipe) == - OSAL_ErrNone ) { - eError = OMXBase_ProcessEvents(pComp, retrievedEvents); - /*Callback for error will be sent in the above function*/ - eError = OMX_ErrorNone; - } - retrievedEvents &= ~CMDEVENT; - } - if( retrievedEvents & DATAEVENT ) { - eError = OMXBase_ProcessEvents(pComp, retrievedEvents); - /*Callback for error will be sent in the above function*/ - eError = OMX_ErrorNone; - } - } - -EXIT: - if( OMX_ErrorNone != eError ) { - pBaseCompPvt->sAppCallbacks.EventHandler((OMX_HANDLETYPE)pComp, - pComp->pApplicationPrivate, - OMX_EventError, eError, - 0, NULL); - } -} - - -/* -* OMX Base Disable Port -*/ -OMX_ERRORTYPE OMXBase_DisablePort(OMX_HANDLETYPE hComponent, - OMX_U32 nParam) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBase_Port *pPort = NULL; - OMX_U32 nStartPortNum; - - nStartPortNum = pBaseComp->nMinStartPortIndex; - - pPort = pBaseComp->pPorts[nParam - nStartPortNum]; - /* If comp is in loaded state, then there wont be any buffers to free up */ - if((pBaseComp->tCurState == OMX_StateLoaded) - || (pBaseComp->tCurState == OMX_StateWaitForResources)) { - goto EXIT; - } - eError = OMXBase_DIO_Control(hComponent, nParam, - OMX_DIO_CtrlCmd_Stop, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - -EXIT: - return (eError); - -} - -/* -* OMX Base EnablePort -*/ -OMX_ERRORTYPE OMXBase_EnablePort(OMX_HANDLETYPE hComponent, - OMX_U32 nParam) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *) pComp->pComponentPrivate; - OMXBase_Port *pPort = NULL; - OMX_U32 nStartPortNum = 0; - OMX_DIO_OpenParams sDIOParams; - - nStartPortNum = pBaseComp->nMinStartPortIndex; - - pPort = pBaseComp->pPorts[nParam - nStartPortNum]; - if( pBaseComp->tCurState != OMX_StateLoaded && - pBaseComp->tCurState != OMX_StateWaitForResources ) { - if( pPort->sPortDef.eDir == OMX_DirOutput ) { - sDIOParams.nMode = OMX_DIO_WRITER; - } else { - sDIOParams.nMode = OMX_DIO_READER; - } - } - -EXIT: - return (eError); -} - -/* -* OMX Base Flush Buffers -*/ -OMX_ERRORTYPE OMXBase_FlushBuffers(OMX_HANDLETYPE hComponent, - OMX_U32 nParam) -{ - return(OMXBase_DIO_Control(hComponent, nParam, OMX_DIO_CtrlCmd_Flush, - NULL)); -} - - -/* -* OMX Base Handle Transition -*/ -OMX_ERRORTYPE OMXBase_HandleStateTransition(OMX_HANDLETYPE hComponent, - OMX_U32 nParam) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - OMXBase_Port *pPort = NULL; - OMX_U32 i = 0, nStartPortNum = 0, nPorts = 0; - uint32_t retEvents = 0; - OMX_DIO_OpenParams sDIOParams; - - nPorts = pBaseComp->nNumPorts; - nStartPortNum = pBaseComp->nMinStartPortIndex; - - /* currnet and new state should not be same */ - OMX_CHECK(pBaseComp->tCurState != pBaseComp->tNewState, OMX_ErrorSameState); - /* Transition to invaild state by IL client is disallowed */ - if( pBaseComp->tNewState == OMX_StateInvalid ) { - /* Notify to Derived Component */ - pBaseComp->fpCommandNotify(hComponent, OMX_CommandStateSet, nParam, NULL); - /*Derived component has returned*/ - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdStateSet, OSAL_EVENT_OR_CONSUME, - &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorInsufficientResources); - - /* - For this case we wont go through OMXBase_EventNotifyToClient function - The state will be set here and error callback will be made by - OMXBase_ProcessEvents function - */ - pBaseComp->tCurState = pBaseComp->tNewState; - eError = OMX_ErrorInvalidState; - goto EXIT; - } - - switch( pBaseComp->tCurState ) { - case OMX_StateLoaded : - if( pBaseComp->tNewState == OMX_StateIdle ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent( - pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdStateSet, OSAL_EVENT_OR_CONSUME, - &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, - OMX_ErrorInsufficientResources); - - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; - /*If port is disabled then nothing needs to be done*/ - if( pPort->sPortDef.bEnabled == OMX_FALSE ) { - continue; - } - if( pPort->sPortDef.eDir == OMX_DirOutput ) { - sDIOParams.nMode = OMX_DIO_WRITER; - } else { - sDIOParams.nMode = OMX_DIO_READER; - } - } - } else if( pBaseComp->tNewState == OMX_StateWaitForResources ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - } else { - eError = OMX_ErrorIncorrectStateTransition; - goto EXIT; - } - break; - - case OMX_StateIdle : - if( pBaseComp->tNewState == OMX_StateLoaded ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - } else if( pBaseComp->tNewState == OMX_StateExecuting ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - } else if( pBaseComp->tNewState == OMX_StatePause ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - } else { - eError = OMX_ErrorIncorrectStateTransition; - goto EXIT; - } - break; - - case OMX_StateExecuting : - if( pBaseComp->tNewState == OMX_StateIdle ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; - if( pPort->hDIO != NULL ) { - eError = OMXBase_DIO_Control(hComponent, i, - OMX_DIO_CtrlCmd_Stop, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } - } else if( pBaseComp->tNewState == OMX_StatePause ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - } else { - eError = OMX_ErrorIncorrectStateTransition; - goto EXIT; - } - break; - - case OMX_StatePause : - if( pBaseComp->tNewState == OMX_StateExecuting ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - - /*Pause to Executing so start processing buffers*/ - pBaseCompPvt->fpInvokeProcessFunction(pComp, DATAEVENT); - } else if( pBaseComp->tNewState == OMX_StateIdle ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; - if( pPort->hDIO != NULL ) { - eError = OMXBase_DIO_Control(hComponent, i, - OMX_DIO_CtrlCmd_Stop, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } - } else { - eError = OMX_ErrorIncorrectStateTransition; - goto EXIT; - } - break; - - case OMX_StateWaitForResources : - if( pBaseComp->tNewState == OMX_StateLoaded ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - } else if( pBaseComp->tNewState == OMX_StateIdle ) { - /* Notify to Derived Component */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, nParam, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, - OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; - /*If port is disabled then nothing needs to be done*/ - if( pPort->sPortDef.bEnabled == OMX_FALSE ) { - continue; - } - if( pPort->sPortDef.eDir == OMX_DirOutput ) { - sDIOParams.nMode = OMX_DIO_WRITER; - } else { - sDIOParams.nMode = OMX_DIO_READER; - } - } - } else { - eError = OMX_ErrorIncorrectStateTransition; - goto EXIT; - } - break; - - default : - OSAL_ErrorTrace(" unknown command "); - break; - } - -EXIT: - if( eError != OMX_ErrorNone ) { - /* Since no state transition is in progress put the new state again to OMX_StateMax */ - pBaseComp->tNewState = OMX_StateMax; - } - return (eError); -} - -/* -* OMX Base Event Notufy to Client -*/ -OMX_ERRORTYPE OMXBase_EventNotifyToClient(OMX_HANDLETYPE hComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, - OMX_PTR pCmdData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - OMXBase_Port *pPort = NULL; - uint32_t retEvents = 0; - OMX_U32 i, nStartPortNum, nPorts; - OMX_BOOL bStartFlag = OMX_FALSE; - (void)pCmdData; - - nPorts = pBaseComp->nNumPorts; - nStartPortNum = pBaseComp->nMinStartPortIndex; - - switch( Cmd ) { - case OMX_CommandStateSet : - if(((pBaseComp->tCurState == OMX_StateLoaded || - pBaseComp->tCurState == OMX_StateWaitForResources) && - pBaseComp->tNewState == OMX_StateIdle) || - (pBaseComp->tCurState == OMX_StateIdle && - pBaseComp->tNewState == OMX_StateLoaded)) { - /* Incase of loaded to idle and idle to loaded state transition, comp - * should wait for buffers to be allocated/freed for enabled ports */ - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = pBaseComp->pPorts[i - nStartPortNum]; - if( pPort->sPortDef.bEnabled == OMX_TRUE ) { - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, - (BUF_ALLOC_EVENT | BUF_FREE_EVENT | - BUF_FAIL_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - BUFFER_ALLOC_FREE_TIMEOUT); - - if (tStatus == OSAL_ErrTimeOut) { - tStatus = OSAL_ErrNone; - retEvents = BUF_FAIL_EVENT; - } - - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - if( retEvents & BUF_FAIL_EVENT ) { - /*Fail event so free up all DIO resources and move - back to loaded state*/ - OMXBase_HandleFailEvent(hComponent, Cmd, nParam); - if( pBaseComp->tCurState == OMX_StateIdle && - pBaseComp->tNewState == OMX_StateLoaded ) { - eError = OMX_ErrorPortUnresponsiveDuringDeallocation; - } else { - eError = OMX_ErrorPortUnresponsiveDuringAllocation; - } - goto EXIT; - } - /* free up the pool incase if idle to loaded */ - if( pBaseComp->tCurState == OMX_StateIdle && - pBaseComp->tNewState == OMX_StateLoaded ) { - eError = OMXBase_DIO_Close(hComponent, i); - OMX_CHECK(OMX_ErrorNone == eError, eError); - eError = OMXBase_DIO_Deinit(hComponent, i); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } - } - } else if( pBaseComp->tCurState == OMX_StateIdle && - (pBaseComp->tNewState == OMX_StatePause || - pBaseComp->tNewState == OMX_StateExecuting)) { - bStartFlag = OMX_TRUE; - } - OSAL_ObtainMutex(pBaseCompPvt->pNewStateMutex, OSAL_SUSPEND); - - pBaseComp->tCurState = pBaseComp->tNewState; - pBaseComp->tNewState = OMX_StateMax; - /* Notify Completion to the Client */ - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventCmdComplete, OMX_CommandStateSet, - nParam, NULL); - if( bStartFlag ) { - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; - if( pPort->hDIO != NULL ) { - eError = OMXBase_DIO_Control(hComponent, i, - OMX_DIO_CtrlCmd_Start, NULL); - if( OMX_ErrorNone != eError ) { - OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); - goto EXIT; - } - } - } - } - OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); - break; - - case OMX_CommandPortEnable : - if( OMX_ALL == nParam ) { - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = pBaseComp->pPorts[i - nStartPortNum]; - if( pBaseComp->tCurState != OMX_StateLoaded ) { - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, - (BUF_ALLOC_EVENT | BUF_FAIL_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - BUFFER_ALLOC_FREE_TIMEOUT); - if (tStatus == OSAL_ErrTimeOut) { - tStatus = OSAL_ErrNone; - retEvents = BUF_FAIL_EVENT; - } - - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - if( retEvents & BUF_FAIL_EVENT ) { - /*Fail event so free up all DIO resources and move - back to port in disabled state*/ - OMXBase_HandleFailEvent(hComponent, Cmd, nParam); - eError = OMX_ErrorPortUnresponsiveDuringAllocation; - - for( i = 0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - pPort->bIsInTransition = OMX_FALSE; - pPort->sPortDef.bEnabled = OMX_FALSE; - } - goto EXIT; - } - } - pPort->bIsInTransition = OMX_FALSE; - /* Notify Completion to the Client */ - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventCmdComplete, OMX_CommandPortEnable, - i, NULL); - /*If current state is executing, start buffer transfer*/ - if( pBaseComp->tCurState == OMX_StateExecuting ) { - eError = OMXBase_DIO_Control(hComponent, i, - OMX_DIO_CtrlCmd_Start, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } - } else { - pPort = pBaseComp->pPorts[nParam - nStartPortNum]; - if( pBaseComp->tCurState != OMX_StateLoaded ) { - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, - (BUF_ALLOC_EVENT | BUF_FAIL_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - BUFFER_ALLOC_FREE_TIMEOUT); - if (tStatus == OSAL_ErrTimeOut) { - tStatus = OSAL_ErrNone; - retEvents = BUF_FAIL_EVENT; - } - - OMX_CHECK(tStatus == OSAL_ErrNone, - tStatus != OSAL_ErrTimeOut ? - OMX_ErrorUndefined : OMX_ErrorPortUnresponsiveDuringAllocation); - - if( retEvents & BUF_FAIL_EVENT ) { - /*Fail event so free up all DIO resources and move - back to port in disabled state*/ - OMXBase_HandleFailEvent(hComponent, Cmd, nParam); - eError = OMX_ErrorPortUnresponsiveDuringAllocation; - pPort->bIsInTransition = OMX_FALSE; - pPort->sPortDef.bEnabled = OMX_FALSE; - goto EXIT; - } - } - pPort->bIsInTransition = OMX_FALSE; - - /* Notify Completion to the Client */ - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventCmdComplete, OMX_CommandPortEnable, - nParam, NULL); - /*If current state is executing, start buffer transfer*/ - if( pBaseComp->tCurState == OMX_StateExecuting ) { - eError = OMXBase_DIO_Control(hComponent, nParam, - OMX_DIO_CtrlCmd_Start, NULL); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } - break; - - case OMX_CommandPortDisable : - if( OMX_ALL == nParam ) { - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = pBaseComp->pPorts[i - nStartPortNum]; - if( pBaseComp->tCurState != OMX_StateLoaded ) { - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, - (BUF_FREE_EVENT | BUF_FAIL_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - BUFFER_ALLOC_FREE_TIMEOUT); - - if (tStatus == OSAL_ErrTimeOut) { - tStatus = OSAL_ErrNone; - retEvents = BUF_FAIL_EVENT; - } - - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - if( retEvents & BUF_FAIL_EVENT ) { - /*Fail event so free up all DIO resources and move - port to disabled state*/ - OMXBase_HandleFailEvent(hComponent, Cmd, nParam); - eError = OMX_ErrorPortUnresponsiveDuringDeallocation; - - for( i = 0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - pPort->bIsInTransition = OMX_FALSE; - } - goto EXIT; - } - eError = OMXBase_DIO_Close(hComponent, i); - OMX_CHECK(OMX_ErrorNone == eError, eError); - eError = OMXBase_DIO_Deinit(hComponent, i); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - pPort->bIsInTransition = OMX_FALSE; - /* Notify Completion to the Client */ - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventCmdComplete, OMX_CommandPortDisable, - i, NULL); - } - } else { - pPort = pBaseComp->pPorts[nParam - nStartPortNum]; - if( pBaseComp->tCurState != OMX_StateLoaded ) { - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, - (BUF_FREE_EVENT | BUF_FAIL_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - BUFFER_ALLOC_FREE_TIMEOUT); - - if (tStatus == OSAL_ErrTimeOut) { - tStatus = OSAL_ErrNone; - retEvents = BUF_FAIL_EVENT; - } - - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - if( retEvents & BUF_FAIL_EVENT ) { - /*Fail event so free up all DIO resources and move - back to port in disabled state*/ - OMXBase_HandleFailEvent(hComponent, Cmd, nParam); - eError = OMX_ErrorPortUnresponsiveDuringDeallocation; - pPort->bIsInTransition = OMX_FALSE; - goto EXIT; - } - eError = OMXBase_DIO_Close(hComponent, nParam); - OMX_CHECK(OMX_ErrorNone == eError, eError); - eError = OMXBase_DIO_Deinit(hComponent, nParam); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - pPort->bIsInTransition = OMX_FALSE; - /* Notify Completion to the Client */ - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventCmdComplete, OMX_CommandPortDisable, - nParam, NULL); - } - break; - - case OMX_CommandFlush : - if( nParam == OMX_ALL ) { - for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { - pPort = pBaseComp->pPorts[i - nStartPortNum]; - /* Notify Completion to the Client */ - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventCmdComplete, OMX_CommandFlush, - i, NULL); - } - } else { - /* Notify Completion to the Client */ - pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventCmdComplete, OMX_CommandFlush, - nParam, NULL); - } - break; - - case OMX_CommandMarkBuffer : - - break; - - default : - OSAL_ErrorTrace("InValid command"); - } - -EXIT: - return (eError); -} - -/* -* OMX Base IsCmdPending -*/ -OMX_BOOL OMXBase_IsCmdPending (OMX_HANDLETYPE hComponent) -{ - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - OMX_BOOL bRetVal = OMX_FALSE; - - if( OSAL_IsPipeReady(pBaseCompPvt->pCmdPipe) == OSAL_ErrNone ) { - /*Set data event so that derived component can get data notification - after it processes the pending command*/ - pBaseCompPvt->bForceNotifyOnce = OMX_TRUE; - pBaseCompPvt->fpInvokeProcessFunction(hComponent, DATAEVENT); - bRetVal = OMX_TRUE; - } - - return (bRetVal); -} - - -/* -* OMX Base Is DIO Ready -*/ -OMX_BOOL OMXBase_IsDioReady(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex) -{ - OMX_BOOL bRet = OMX_TRUE; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 nStartPortNumber = 0; - - if( pBaseComp == NULL ) { - OSAL_ErrorTrace("Pvt structure is NULL - DIO cannot be used"); - bRet = OMX_FALSE; - goto EXIT; - } - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - if( pBaseCompPvt == NULL ) { - OSAL_ErrorTrace("Base internal structure is NULL - DIO cannot be used"); - bRet = OMX_FALSE; - goto EXIT; - } - if( pBaseComp->pPorts == NULL ) { - OSAL_ErrorTrace("No port has been initialized - DIO cannot be used"); - bRet = OMX_FALSE; - goto EXIT; - } - nStartPortNumber = pBaseComp->nMinStartPortIndex; - pPort = (OMXBase_Port *) - pBaseComp->pPorts[nPortIndex - nStartPortNumber]; - if( pPort == NULL ) { - OSAL_ErrorTrace("This port is not initialized - DIO cannot be used"); - bRet = OMX_FALSE; - goto EXIT; - } - if( pPort->hDIO == NULL ) { - OSAL_ErrorTrace("DIO handle is NULL - DIO cannot be used"); - bRet = OMX_FALSE; - goto EXIT; - } - if( !(((OMX_DIO_Object *)pPort->hDIO)->bOpened)) { - OSAL_ErrorTrace("DIO has not yet been opened"); - bRet = OMX_FALSE; - goto EXIT; - } - -EXIT: - return (bRet); -} - -/* -* OMX Base Get UV Buffer shared fd -*/ -OMX_ERRORTYPE OMXBase_GetUVBuffer(OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pBufHdr, OMX_PTR *pUVBuffer) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - (void)hComponent, nPortIndex; - - OMX_CHECK(pBufHdr != NULL, OMX_ErrorBadParameter); - OMX_CHECK(((OMX_BUFFERHEADERTYPE *)pBufHdr)->pPlatformPrivate != - NULL, OMX_ErrorBadParameter); - - *pUVBuffer = (void*)((OMXBase_BufHdrPvtData *)((OMX_BUFFERHEADERTYPE *)pBufHdr)-> - pPlatformPrivate)->sMemHdr[1].dma_buf_fd; - -EXIT: - return (eError); -} - - -/* -* OMXBase Error Handling for WaitForResource State -*/ -OMX_ERRORTYPE OMXBase_Error_HandleWFRState(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - uint32_t retEvents = 0; - - eError = OMXBase_SendCommand(hComponent, OMX_CommandStateSet, OMX_StateLoaded, NULL); - - //Wait for WaitForResources state transition to complete. - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - (STATE_LOADED_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - STATE_TRANSITION_LONG_TIMEOUT); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - -EXIT: - return (eError); -} - -/* -* OMX Base Error handling for Idle State -*/ -OMX_ERRORTYPE OMXBase_Error_HandleIdleState(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - OMXBase_Port *pPort = NULL; - OMX_U32 i = 0, j = 0; - uint32_t retEvents = 0; - - eError = OMXBase_SendCommand(hComponent, OMX_CommandStateSet, OMX_StateLoaded, NULL); - - //Send free buffers to complete the Idle transition. - for( i=0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - if( pPort->sPortDef.bEnabled == OMX_TRUE ) { - for( j=0; j < pPort->sPortDef.nBufferCountActual; j++ ) { - OMXBase_FreeBuffer(hComponent, - i + pBaseComp->nMinStartPortIndex, - pPort->pBufferlist[j]); - } - } - } - - //Wait for Idle state transition to complete. - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - (STATE_LOADED_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - STATE_TRANSITION_LONG_TIMEOUT); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); - -EXIT: - return (eError); -} - -/* -* OMX Base UtilCleanup On Error -*/ -OMX_ERRORTYPE OMXBase_UtilCleanupIfError(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - OMXBase_Port *pPort = NULL; - OMX_U32 i = 0; - uint32_t retEvents = 0; - OMX_BOOL bPortTransitioning = OMX_FALSE; - - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - if((pBaseComp->tCurState == OMX_StateLoaded) && (pBaseComp->tNewState == OMX_StateMax)) { - for( i=0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - if( pPort->bIsInTransition) { - bPortTransitioning = OMX_TRUE; - break; - } - } - - if( bPortTransitioning == OMX_FALSE ) { - goto EXIT; - } - } - pBaseCompPvt->sAppCallbacks.EventHandler = OMXBase_Error_EventHandler; - pBaseCompPvt->sAppCallbacks.EmptyBufferDone = OMXBase_Error_EmptyBufferDone; - pBaseCompPvt->sAppCallbacks.FillBufferDone = OMXBase_Error_FillBufferDone; - - if((pBaseComp->tCurState == OMX_StateWaitForResources) && (pBaseComp->tNewState == OMX_StateMax)) { - for( i=0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - if( pPort->bIsInTransition) { - bPortTransitioning = OMX_TRUE; - break; - } - } - - if( bPortTransitioning == OMX_FALSE ) { - OSAL_ErrorTrace("Free Handle called in WaitForResources state, attempting a transition to LOADED state"); - eError = OMXBase_Error_HandleWFRState(pComp); - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); - } else { - OSAL_ErrorTrace("Cleanup from WaitForResources state is successful"); - } - goto EXIT; - } - } - //Wait for timeout to let any pending send commands complete. - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - (STATE_LOADED_EVENT | STATE_IDLE_EVENT - | STATE_EXEC_EVENT | STATE_PAUSE_EVENT - | ERROR_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - STATE_TRANSITION_TIMEOUT); - if( tStatus != OSAL_ErrNone && tStatus != OSAL_ErrTimeOut ) { - eError = OMX_ErrorUndefined; - OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); - } - //Clear any port disable/enable events which are pending. - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - (PORT_ENABLE_EVENT | PORT_DISABLE_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - OSAL_NO_SUSPEND); - if( tStatus != OSAL_ErrNone && tStatus != OSAL_ErrTimeOut ) { - eError = OMX_ErrorUndefined; - OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); - } - - //This is for the condition if freehandle is being sent while port enable/disable is ongoing. - for( i=0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - if( pPort->bIsInTransition) { - tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, - BUF_FAIL_EVENT, OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - //Wait for port to transition to disable. - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - ERROR_EVENT, OSAL_EVENT_OR_CONSUME, &retEvents, - STATE_TRANSITION_TIMEOUT); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); - } - if( pPort->bIsInTransition) { - pPort->bIsInTransition = OMX_FALSE; - } - } - } - - if( pBaseComp->tCurState == OMX_StateLoaded && pBaseComp->tNewState == OMX_StateMax ) { - goto EXIT; - } - - switch( pBaseComp->tCurState ) { - case OMX_StateLoaded : - OMX_BASE_HANDLE_IDLE_TO_LOADED_TRANSITION(); - break; - - case OMX_StateWaitForResources : - // Since BUFFER FAIL done in cleanup utility happened successfully, all that is required is switch to LOADED state. - if( pBaseComp->tCurState == OMX_StateWaitForResources && pBaseComp->tNewState == OMX_StateMax ) { - eError = OMXBase_Error_HandleWFRState(hComponent); - } else { - OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); - } - break; - - case OMX_StateIdle : - if( pBaseComp->tCurState == OMX_StateIdle && pBaseComp->tNewState == OMX_StateMax ) { - eError = OMXBase_Error_HandleIdleState(hComponent); - } else { // This is to handle scenerio if there is a crash in Idle to Loaded transition - OMX_BASE_HANDLE_IDLE_TO_LOADED_TRANSITION(); - } - break; - - case OMX_StateExecuting : - // Move the component to Idle State. - OMXBase_SendCommand(hComponent, OMX_CommandStateSet, OMX_StateIdle, NULL); - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - STATE_IDLE_EVENT, - OSAL_EVENT_OR_CONSUME, &retEvents, - STATE_TRANSITION_LONG_TIMEOUT); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - OSAL_ErrorTrace("I am here b'cs of TIMEOUT in ER"); - } - eError = OMXBase_Error_HandleIdleState(hComponent); - break; - - case OMX_StatePause : - // Move the component to Idle State. - OMXBase_SendCommand(hComponent, OMX_CommandStateSet, OMX_StateIdle, NULL); - retEvents = 0; - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - (STATE_IDLE_EVENT), - OSAL_EVENT_OR_CONSUME, &retEvents, - STATE_TRANSITION_LONG_TIMEOUT); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - OSAL_ErrorTrace("I am here b'cs of TIMEOUT in ER"); - } - eError = OMXBase_Error_HandleIdleState(hComponent); - break; - - default : - OSAL_ErrorTrace("Invalid state requested"); - } - -EXIT: - return (eError); -} - -/* -* OMX Base Error handling for Empty Buffer Done -*/ -OMX_ERRORTYPE OMXBase_Error_EmptyBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, - OMX_BUFFERHEADERTYPE *pBuffer) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - (void)hComponent, pAppData, pBuffer; - - return (eError); -} - -/* -* OMX Base Error Handling for FillBufferDone -*/ -OMX_ERRORTYPE OMXBase_Error_FillBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, - OMX_BUFFERHEADERTYPE *pBuffer) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - (void)hComponent, pAppData, pBuffer; - - return (eError); -} - -/* -* OMX Base Error Handling for EventHandler -*/ -OMX_ERRORTYPE OMXBase_Error_EventHandler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, - OMX_EVENTTYPE eEvent, OMX_U32 nData1, - OMX_U32 nData2, OMX_PTR pEventData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - (void)pAppData, pEventData; - - if( eEvent == OMX_EventCmdComplete ) { - if((OMX_COMMANDTYPE)nData1 == OMX_CommandPortEnable ) { - tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - PORT_ENABLE_EVENT, OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandPortEnable ) { - tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - PORT_DISABLE_EVENT, OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandStateSet ) { - switch((OMX_STATETYPE) nData2 ) { - case OMX_StateLoaded : - tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - STATE_LOADED_EVENT, OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - break; - - case OMX_StateIdle : - tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - STATE_IDLE_EVENT, OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - break; - - case OMX_StateExecuting : - tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - STATE_EXEC_EVENT, OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - break; - - case OMX_StatePause : - tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - STATE_PAUSE_EVENT, OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - break; - - default: - OSAL_ErrorTrace("Invalid command"); - } - } - } else if( eEvent == OMX_EventError ) { - if(((OMX_ERRORTYPE)nData1 == OMX_ErrorPortUnresponsiveDuringDeallocation) || - ((OMX_ERRORTYPE)nData1 == OMX_ErrorPortUnresponsiveDuringAllocation)) { - tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, - ERROR_EVENT, OSAL_EVENT_OR); - } - } - return (eError); -} - -/* -* OMX Base Handle Fail Event -*/ -void OMXBase_HandleFailEvent(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE eCmd, - OMX_U32 nPortIndex) -{ - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - OMXBase_Port *pPort = NULL; - OSAL_ERROR retval = OSAL_ErrNone; - OMX_U32 i = 0; - uint32_t retEvents = 0; - OMX_ERRORTYPE eError = OMX_ErrorNone; - - switch( eCmd ) { - case OMX_CommandStateSet : - OSAL_ObtainMutex(pBaseCompPvt->pNewStateMutex, OSAL_SUSPEND); - if(((pBaseComp->tCurState == OMX_StateLoaded || - pBaseComp->tCurState == OMX_StateWaitForResources) && - pBaseComp->tNewState == OMX_StateIdle) || - (pBaseComp->tCurState == OMX_StateIdle && - pBaseComp->tNewState == OMX_StateLoaded)) { - /*Failure in L --> I transition. First step is to tell the derived component - to revert back to loaded state*/ - if(((pBaseComp->tCurState == OMX_StateLoaded) || - (pBaseComp->tCurState == OMX_StateWaitForResources)) && - (pBaseComp->tNewState == OMX_StateIdle)) { - /*Force setting states*/ - pBaseComp->tCurState = OMX_StateIdle; - pBaseComp->tNewState = OMX_StateLoaded; - /*Return error values dont matter here since this is cleanup*/ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandStateSet, OMX_StateLoaded, NULL); - if( eError == OMX_ErrorNone ) { - OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdStateSet, OSAL_EVENT_OR_CONSUME, &retEvents, - OSAL_SUSPEND); - } - } - - /*If DIO for any port is open close those*/ - for( i = 0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - if( pPort != NULL ) { - if( pPort->hDIO != NULL ) { - OMXBase_DIO_Close(hComponent, - (i + pBaseComp->nMinStartPortIndex)); - - OMXBase_DIO_Deinit(hComponent, - (i + pBaseComp->nMinStartPortIndex)); - } - } - } - /*Force setting states*/ - pBaseComp->tCurState = OMX_StateLoaded; - pBaseComp->tNewState = OMX_StateMax; - } - OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); - break; - - case OMX_CommandPortEnable : - /*Tell derived comp to move back to disabled state*/ - pBaseComp->fpCommandNotify(hComponent, - OMX_CommandPortDisable, nPortIndex, NULL); - - OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdPortDisable, OSAL_EVENT_OR_CONSUME, &retEvents, - OSAL_SUSPEND); - if( nPortIndex == OMX_ALL ) { - for( i = 0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - pPort->bIsInTransition = OMX_FALSE; - } - } else { - pPort = pBaseComp->pPorts[ - nPortIndex - pBaseComp->nMinStartPortIndex]; - pPort->bIsInTransition = OMX_FALSE; - } - /*NO break to OMX_CommandPortEnable case :::Intention is to have a fall through logic to the port disable*/ - - case OMX_CommandPortDisable : - /*Close DIO on the relevant ports for both enable as well as disable - commands*/ - OSAL_ObtainMutex(pBaseCompPvt->pPortDisableMutex, OSAL_SUSPEND); - if( nPortIndex == OMX_ALL ) { - for( i = 0; i < pBaseComp->nNumPorts; i++ ) { - pPort = pBaseComp->pPorts[i]; - if( pPort != NULL ) { - if( pPort->hDIO != NULL ) { - OMXBase_DIO_Close(hComponent, (i + pBaseComp->nMinStartPortIndex)); - - OMXBase_DIO_Deinit(hComponent, (i + pBaseComp->nMinStartPortIndex)); - } - } - } - } else { - pPort = pBaseComp->pPorts[nPortIndex - pBaseComp->nMinStartPortIndex]; - if( pPort != NULL ) { - if( pPort->hDIO != NULL ) { - OMXBase_DIO_Close(hComponent, nPortIndex); - OMXBase_DIO_Deinit(hComponent, nPortIndex); - } - } - } - OSAL_ReleaseMutex(pBaseCompPvt->pPortDisableMutex); - break; - - default : - OSAL_ErrorTrace("Invalid Command"); - } - - return; -} - - diff --git a/omx/base/omx_base_comp/src/omx_base_process.c b/omx/base/omx_base_comp/src/omx_base_process.c deleted file mode 100644 index 72f5382..0000000 --- a/omx/base/omx_base_comp/src/omx_base_process.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_BASE_PROCESS" - -#include <OMX_Core.h> -#include <OMX_Component.h> -#include <omx_base.h> -#include <OMX_TI_Custom.h> - -static OMX_ERRORTYPE OMXBase_ProcessDataEvent(OMX_HANDLETYPE hComponent); - -static OMX_ERRORTYPE OMXBase_ProcessCmdEvent(OMX_HANDLETYPE hComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, - OMX_PTR pCmdData); - - -/* -* OMX Base ProcessTrigger Event -*/ -OMX_ERRORTYPE OMXBase_ProcessTriggerEvent(OMX_HANDLETYPE hComponent, - OMX_U32 EventToSet) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 i, nStartPort, nCount = 0; - OMX_BOOL bNotify = OMX_TRUE; - - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - nStartPort = pBaseComp->nMinStartPortIndex; - if( EventToSet == DATAEVENT ) { - /*This var mey be accessed by multiple threads but it need not be mutex - protected*/ - if( pBaseCompPvt->bForceNotifyOnce ) { - pBaseCompPvt->bForceNotifyOnce = OMX_FALSE; - bNotify = OMX_TRUE; - goto EXIT; - } - - for( i = 0; i < (pBaseComp->nNumPorts); i++ ) { - pPort = pBaseComp->pPorts[i]; - /*If port is disabled then move on*/ - if( !pPort->sPortDef.bEnabled ) { - continue; - } - /*If EOS has been recd. on any one port then always send notification*/ - if( pPort->sPortDef.eDir == OMX_DirInput && pPort->bEosRecd ) { - bNotify = OMX_TRUE; - goto EXIT; - } - } - - if( pBaseComp->bNotifyForAnyPort == OMX_TRUE ) { - bNotify = OMX_FALSE; - for( i = 0; i < (pBaseComp->nNumPorts); i++ ) { - pPort = pBaseComp->pPorts[i]; - /*If port is disabled then move on*/ - if( !pPort->sPortDef.bEnabled || - pPort->bIsInTransition) { - continue; - } - eError = pBaseCompPvt->fpDioGetCount(hComponent, nStartPort + i, - &nCount); - OMX_CHECK((eError == OMX_ErrorNone || eError == - (OMX_ERRORTYPE)OMX_TI_WarningEosReceived), eError); - /*Resetting to ErrorNone in case EOS warning is recd.*/ - eError = OMX_ErrorNone; - if((nCount >= pBaseComp->pPorts[i]->sProps.nWatermark)) { - bNotify = OMX_TRUE; - break; - } - } - } else { - for( i = 0; i < (pBaseComp->nNumPorts); i++ ) { - pPort = pBaseComp->pPorts[i]; - /*If port is disabled then move on*/ - if( !pPort->sPortDef.bEnabled || - pPort->bIsInTransition) { - continue; - } - eError = pBaseCompPvt->fpDioGetCount(hComponent, nStartPort + i, - &nCount); - OMX_CHECK((eError == OMX_ErrorNone || eError == - (OMX_ERRORTYPE)OMX_TI_WarningEosReceived), eError); - /*Resetting to ErrorNone in case EOS warning is recd.*/ - eError = OMX_ErrorNone; - if((nCount < pBaseComp->pPorts[i]->sProps.nWatermark)) { - bNotify = OMX_FALSE; - break; - } - } - } - } - -EXIT: - if( bNotify == OMX_TRUE && eError == OMX_ErrorNone ) { - tStatus = OSAL_SetEvent(pBaseCompPvt->pTriggerEvent, EventToSet, - OSAL_EVENT_OR); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - } - return (eError); -} - -/* -* OMX Base ProcessDataNotify -*/ -OMX_ERRORTYPE OMXBase_ProcessDataNotify(OMX_HANDLETYPE hComponent) -{ - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - pBaseCompPvt->bForceNotifyOnce = OMX_FALSE; - return (OMXBase_ProcessTriggerEvent(hComponent, DATAEVENT)); -} - -/* -* OMXBase Process Events -*/ -OMX_ERRORTYPE OMXBase_ProcessEvents(OMX_HANDLETYPE hComponent, - OMX_U32 retEvent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_ERRORTYPE eErrorAux = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMXBase_CmdParams sCmdParams; - uint32_t actualSize = 0; - OMX_BOOL bHandleFailEvent = OMX_FALSE; - - - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - if( retEvent & CMDEVENT ) { - tStatus = OSAL_ObtainMutex(pBaseCompPvt->pCmdPipeMutex, - OSAL_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - /* process command event */ - tStatus = OSAL_IsPipeReady(pBaseCompPvt->pCmdPipe); - if( tStatus != OSAL_ErrNone ) { - /*No command in pipe - return*/ - tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - goto EXIT; - } - tStatus = OSAL_ReadFromPipe(pBaseCompPvt->pCmdPipe, &sCmdParams, - sizeof(OMXBase_CmdParams), &actualSize, OSAL_NO_SUSPEND); - if( OSAL_ErrNone != tStatus ) { - eError = OMX_ErrorUndefined; - } - tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - OMX_CHECK(eError == OMX_ErrorNone, eError); - - eError = OMXBase_ProcessCmdEvent(hComponent, sCmdParams.eCmd, - sCmdParams.unParam, sCmdParams.pCmdData); - if( OMX_ErrorNone != eError ) { - bHandleFailEvent = OMX_TRUE; - goto EXIT; - } - } else if( retEvent & DATAEVENT ) { - /* process data Event */ - eError = OMXBase_ProcessDataEvent(hComponent); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } -EXIT: - if( OMX_ErrorNone != eError ) { - if(eError != OMX_ErrorDynamicResourcesUnavailable) { - eErrorAux = pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventError, eError, - OMX_StateInvalid, NULL); - } else { - eErrorAux = pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, - pComp->pApplicationPrivate, - OMX_EventError, eError, - OMX_StateLoaded, NULL); - } - /*Component can do nothing if callback returns error*/ - /*Just calling OMXBase_HandleFailEvent for SetState since it was the - * the intention. When Allocation fails while Dynamic Resources Allocation - * we are experiencing hang waiting forever for PortDisable event completion - * after attempted an unsuccessful PortEnable. - */ - if( bHandleFailEvent && (eError != OMX_ErrorDynamicResourcesUnavailable) ) { - OMXBase_HandleFailEvent(hComponent, sCmdParams.eCmd, sCmdParams.unParam); - } - } - if( (OMX_ErrorNone != eError) && (eError != OMX_ErrorDynamicResourcesUnavailable) ) { - return (eError); //return actual error if any - } - - return (eErrorAux); -} - -/* -* OMX Base Process Command Event -*/ -static OMX_ERRORTYPE OMXBase_ProcessCmdEvent(OMX_HANDLETYPE hComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, - OMX_PTR pCmdData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMX_U32 i, nPorts, nStartPortNum; - uint32_t retEvents = 0; - - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - nPorts = pBaseComp->nNumPorts; - nStartPortNum = pBaseComp->nMinStartPortIndex; - - switch( Cmd ) { - case OMX_CommandStateSet : - eError = OMXBase_HandleStateTransition(hComponent, nParam); - OMX_CHECK(OMX_ErrorNone == eError, eError); - break; - - case OMX_CommandPortDisable : - /* Notify to Derived Component here so that derived component - receives correct param - ALL or specific port no. */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandPortDisable, nParam, pCmdData); - OMX_CHECK(OMX_ErrorNone == eError, eError); - - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdPortDisable, OSAL_EVENT_OR_CONSUME, - &retEvents, OSAL_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, - OMX_ErrorInsufficientResources); - if( nParam == OMX_ALL ) { - for( i = nStartPortNum; i < nPorts; i++ ) { - eError = OMXBase_DisablePort(hComponent, i); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } else { - eError = OMXBase_DisablePort(hComponent, nParam); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - break; - - case OMX_CommandPortEnable : - /* Notify to Derived Component here so that derived component - receives correct param - ALL or specific port no. */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandPortEnable, nParam, pCmdData); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdPortEnable, OSAL_EVENT_OR_CONSUME, - &retEvents, OSAL_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, - OMX_ErrorInsufficientResources); - if( nParam == OMX_ALL ) { - for( i = nStartPortNum; i < nPorts; i++ ) { - eError = OMXBase_EnablePort(hComponent, i); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } else { - eError = OMXBase_EnablePort(hComponent, nParam); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - break; - - case OMX_CommandFlush : - if( pBaseComp->tCurState == OMX_StateLoaded || - pBaseComp->tCurState == OMX_StateWaitForResources ) { - } else if((nParam != OMX_ALL) && (pBaseComp->pPorts - [nParam - nStartPortNum]->sPortDef.bEnabled == OMX_FALSE)) { - /*Nothing to be done for disabled port, just exit*/ - } else { - /* Notify to Derived Component here so that derived component - receives correct param - ALL or specific port no. */ - eError = pBaseComp->fpCommandNotify(hComponent, - OMX_CommandFlush, nParam, pCmdData); - OMX_CHECK(OMX_ErrorNone == eError, eError); - tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, - OMXBase_CmdFlush, OSAL_EVENT_OR_CONSUME, - &retEvents, OSAL_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - if( nParam == OMX_ALL ) { - for( i = nStartPortNum; i < nPorts; i++ ) { - eError = OMXBase_FlushBuffers(hComponent, i); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } else { - eError = OMXBase_FlushBuffers(hComponent, nParam); - OMX_CHECK(OMX_ErrorNone == eError, eError); - } - } - break; - - case OMX_CommandMarkBuffer : - eError = pBaseComp->fpCommandNotify(hComponent, Cmd, - nParam, pCmdData); - OMX_CHECK(OMX_ErrorNone == eError, eError); - break; - - default : - OSAL_ErrorTrace(" unknown command received "); - break; - } - - eError = OMXBase_EventNotifyToClient(hComponent, Cmd, nParam, pCmdData); - OMX_CHECK(OMX_ErrorNone == eError, eError); - -EXIT: - return (eError); -} - -/* -* OMX Base Process Data Event -*/ -static OMX_ERRORTYPE OMXBase_ProcessDataEvent(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = NULL; - - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - eError = pBaseComp->fpDataNotify(hComponent); - OMX_CHECK(OMX_ErrorNone == eError, eError); - -EXIT: - return (eError); -} - diff --git a/omx/base/omx_base_dio_plugin/inc/omx_base_dio_plugin.h b/omx/base/omx_base_dio_plugin/inc/omx_base_dio_plugin.h deleted file mode 100644 index 3059afe..0000000 --- a/omx/base/omx_base_dio_plugin/inc/omx_base_dio_plugin.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_BASE_DIO_PLUGIN_H -#define _OMX_BASE_DIO_PLUGIN_H - -#ifdef _cplusplus -extern "C" { -#endif - -#include <OMX_Core.h> -#include <OMX_Component.h> - -#define OMX_BASE_MAXNAMELEN OMX_MAX_STRINGNAME_SIZE - -/* The OMX_DIO_OpenMode enumeration is used to - * sepcify the open mode type i.e reader or writer - */ -typedef enum OMX_DIO_OpenMode { - OMX_DIO_READER = 0x0, - OMX_DIO_WRITER = 0x1 -}OMX_DIO_OpenMode; - -/** OMX_DIO_CreateParams : - * This structure contains the parameters required to - * create DIO object - * - * @param cChannelName : channel name - * @param hComponent : Handle of Component - * @param nPortIndex : Index of the port - * @param pAppCallbacks : Application callbacks - */ -typedef struct OMX_DIO_CreateParams { - char cChannelName[OMX_BASE_MAXNAMELEN]; - OMX_HANDLETYPE hComponent; - OMX_U8 nPortIndex; - OMX_CALLBACKTYPE *pAppCallbacks; -}OMX_DIO_CreateParams; - - -/** OMX_DIO_OpenParams : - * This structure contains the open parameters for DIO object - * @param nMode : open mode reader or writer - * @param bCacheFlag : cache access flag - true if buffer is accessed via - * processor/cache - * @param nBufSize : used by non-tunnel open as allocate buffer call - * can specify a different size - */ -typedef struct OMX_DIO_OpenParams { - OMX_U32 nMode; - OMX_BOOL bCacheFlag; - OMX_U32 nBufSize; -}OMX_DIO_OpenParams; - -typedef OMX_ERRORTYPE (*OMX_DIO_Init)(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pCreateParams); - -/* OMX_DIO_Register : - * This structure contains the params used to register the DIO object - * @param pChannelName : Channel Name - * @param pInitialize : DIO instace initialization function - */ -typedef struct OMX_DIO_Register { - const char *cChannelType; - OMX_DIO_Init pInitialize; -}OMX_DIO_Register; - -extern OMX_DIO_Register OMX_DIO_Registered[2]; -/* - * The OMX_DIO_CtrlCmd_TYPE : This enumeration is used to - * specify the action in the - * OMX_DIO_Control Macro. - * - * @ param OMX_DIO_CtrlCmd_Flush : Flush the buffers on this port. - * This command is used only by - * omx_base for now. - * @ param OMX_DIO_CtrlCmd_Start : Start buffer processing on this - * port. This command is used only by - * omx_base for now. - * @ param OMX_DIO_CtrlCmd_Stop : Stop buffer processing on this - * port. This command is used only by - * omx_base for now. - * @ param OMX_DIO_CtrlCmd_GetCtrlAttribute : To get the attribute pending - * on this port. A pointer to structure - * of type - * OMXBase_CodecConfig is - * passed as the parameter to the - * control command. This should be used - * if dio_dequeue returns - * OMX_WarningAttributePending - * indicating that an attribute buffer - * is pending. - * @ param OMX_DIO_CtrlCmd_SetCtrlAttribute : To send some attribute on - * this port. A pointer to structure of - * type OMXBase_CodecConfig - * is passed as the parameter to the - * control command. - * @ param OMX_DIO_CtrlCmd_ExtnStart : If some specific DIO - * implementation wants to have control - * commands specific for that DIO then - * these extended commands can be added - * after this. - */ -typedef enum OMX_DIO_CtrlCmdType { - OMX_DIO_CtrlCmd_Flush = 0x1, - OMX_DIO_CtrlCmd_Start = 0x2, - OMX_DIO_CtrlCmd_Stop = 0x3, - OMX_DIO_CtrlCmd_GetCtrlAttribute = 0x4, - OMX_DIO_CtrlCmd_SetCtrlAttribute = 0x5, - OMX_DIO_CtrlCmd_ExtnStart = 0xA -}OMX_DIO_CtrlCmdType; - - -/** OMX_DIO_Object : - * This structure contains the params and interface to access the DIO object - * - * @param pContext : pointer to the DIO private data area - * @param (*open) : DIO object open Implementation - * @param (*close) : DIO object close Implementation - * @param (*queue) : DIO object queue Implementation - * @param (*dequeue) : DIO object dequeu Implementation - * @param (*send) : DIO object send Implementation - * @param (*cancel) : DIO object cancel Implementation - * @param (*control) : DIO object control Implementation - * @param (*getcount) : DIO object getcount Implementation - * @param (*deinit) : DIO object deinit Implementation - * @param bOpened : Indicates whether DIO has been opened on this port - */ -typedef struct OMX_DIO_Object { - - OMX_PTR pContext; - - OMX_ERRORTYPE (*open)(OMX_HANDLETYPE handle, - OMX_DIO_OpenParams *pParams); - - OMX_ERRORTYPE (*close)(OMX_HANDLETYPE handle); - - OMX_ERRORTYPE (*queue)(OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader); - - OMX_ERRORTYPE (*dequeue)(OMX_HANDLETYPE handle, - OMX_PTR *pBuffHeader); - - OMX_ERRORTYPE (*send)(OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader); - - OMX_ERRORTYPE (*cancel)(OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader); - - OMX_ERRORTYPE (*control)(OMX_HANDLETYPE handle, - OMX_DIO_CtrlCmdType nCmdType, - OMX_PTR pParams); - - OMX_ERRORTYPE (*getcount)(OMX_HANDLETYPE handle, - OMX_U32 *pCount); - - OMX_ERRORTYPE (*deinit)(OMX_HANDLETYPE handle); - - OMX_BOOL bOpened; - -}OMX_DIO_Object; - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/omx/base/omx_base_dio_plugin/src/omx_base_dio.c b/omx/base/omx_base_dio_plugin/src/omx_base_dio.c deleted file mode 100644 index a97351e..0000000 --- a/omx/base/omx_base_dio_plugin/src/omx_base_dio.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ -#define LOG_TAG "OMX_BASE_DIO" - -#include <string.h> -#include <omx_base.h> - -static OMX_PTR OMXBase_DIO_GetPort(OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex); -/* -* OMXBase DIO Init -*/ -OMX_ERRORTYPE OMXBase_DIO_Init (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_STRING cChannelType, - OMX_PTR pCreateParams) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - OMX_BOOL bFound = OMX_FALSE; - OMX_U32 i = 0; - - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - - OMX_CHECK(NULL != cChannelType, OMX_ErrorBadParameter); - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - while( NULL != OMX_DIO_Registered[i].cChannelType ) { - if( strcmp(cChannelType, OMX_DIO_Registered[i].cChannelType) == 0 ) { - bFound = OMX_TRUE; - break; - } - i++; - } - - if( bFound ) { - hDIO = (OMX_DIO_Object *) OSAL_Malloc(sizeof(OMX_DIO_Object)); - OMX_CHECK(NULL != hDIO, OMX_ErrorInsufficientResources); - OSAL_Memset(hDIO, 0x0, sizeof(OMX_DIO_Object)); - - /* Initialize the DIO object depending on the ChannelType */ - eError = OMX_DIO_Registered[i].pInitialize(hDIO, pCreateParams); - OMX_CHECK(OMX_ErrorNone == eError, eError); - - /* Assign DIO handle to port */ - pPort->hDIO = hDIO; - } else { - OMX_CHECK(OMX_FALSE, OMX_ErrorUndefined); - } - -EXIT: - return (eError); -} - -/* -* OMXBase DIO DeInit -*/ -OMX_ERRORTYPE OMXBase_DIO_Deinit (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - eError = hDIO->deinit(hDIO); - - OSAL_Free(pPort->hDIO); - pPort->hDIO = NULL; - -EXIT: - return (eError); -} - -/* -* OMXBase DIO Open -*/ -OMX_ERRORTYPE OMXBase_DIO_Open (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pOpenParams) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - eError = hDIO->open(hDIO, (OMX_DIO_OpenParams *)pOpenParams); - -EXIT: - if( eError == OMX_ErrorNone ) { - hDIO->bOpened = OMX_TRUE; - } - return (eError); -} - -/* -* OMX Base DIO close -*/ -OMX_ERRORTYPE OMXBase_DIO_Close (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - hDIO->bOpened = OMX_FALSE; - eError = hDIO->close(hDIO); - -EXIT: - return (eError); -} - -/* -* OMX Base DIO Queue -*/ -OMX_ERRORTYPE OMXBase_DIO_Queue (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - eError = hDIO->queue(hDIO, pBuffHeader); - -EXIT: - return (eError); -} - -/* -* OMXBase DIO Dequeue -*/ -OMX_ERRORTYPE OMXBase_DIO_Dequeue (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR *pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - eError = hDIO->dequeue(hDIO, pBuffHeader); - -EXIT: - return (eError); -} - -/* -* OMXBase DIO Send -*/ -OMX_ERRORTYPE OMXBase_DIO_Send (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - eError = hDIO->send(hDIO, pBuffHeader); - -EXIT: - return (eError); -} - -/* -* OMXBase DIO Cancel -*/ -OMX_ERRORTYPE OMXBase_DIO_Cancel (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_PTR pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - eError = hDIO->cancel(hDIO, pBuffHeader); - -EXIT: - return (eError); -} - -/* -* OMXBase DIO Control -*/ -OMX_ERRORTYPE OMXBase_DIO_Control (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_DIO_CtrlCmdType nCmdType, - OMX_PTR pParams) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - eError = hDIO->control(hDIO, nCmdType, pParams); - -EXIT: - return (eError); -} - -/* -* OMX Base DIO GetCount -*/ -OMX_ERRORTYPE OMXBase_DIO_GetCount (OMX_HANDLETYPE hComponent, - OMX_U32 nPortIndex, - OMX_U32 *pCount) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = NULL; - OMXBase_Port *pPort = NULL; - - /*Resetting count to 0 initially*/ - *pCount = 0; - pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); - OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); - - hDIO = (OMX_DIO_Object *)pPort->hDIO; - OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); - - eError = hDIO->getcount(hDIO, pCount); - -EXIT: - return (eError); -} - - -/* -* OMX Base DIO GetPort from the PortIndex -*/ -static OMX_PTR OMXBase_DIO_GetPort(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex) -{ - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; - OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - OMXBase_Port *pPort = NULL; - OMX_U32 nStartPortNumber = 0; - - nStartPortNumber = pBaseComp->nMinStartPortIndex; - if( pBaseComp->pPorts == NULL ) { - pPort = NULL; - goto EXIT; - } - pPort = (OMXBase_Port *)pBaseComp->pPorts[nPortIndex - nStartPortNumber]; - -EXIT: - return (pPort); -} - - - - diff --git a/omx/base/omx_base_dio_plugin/src/omx_base_dio_non_tunnel.c b/omx/base/omx_base_dio_plugin/src/omx_base_dio_non_tunnel.c deleted file mode 100644 index 868a2da..0000000 --- a/omx/base/omx_base_dio_plugin/src/omx_base_dio_non_tunnel.c +++ /dev/null @@ -1,647 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_BASE_DIO_NONTUNNEL" - -#include <omx_base.h> -#include <memplugin.h> -#include <OMX_TI_Custom.h> - -typedef struct DIO_NonTunnel_Attrs { - OMX_DIO_CreateParams sCreateParams; - OMX_U32 nFlags; - OMX_PTR pPipeHandle; - OMX_PTR pHdrPool; - OMX_PTR pPlatformPrivatePool; -}DIO_NonTunnel_Attrs; - - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Open (OMX_HANDLETYPE handle, - OMX_DIO_OpenParams *pParams); - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Close (OMX_HANDLETYPE handle); - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Queue (OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader); - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Dequeue (OMX_HANDLETYPE handle, - OMX_PTR *pBuffHeader); - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Send (OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader); - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Cancel (OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader); - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Control (OMX_HANDLETYPE handle, - OMX_DIO_CtrlCmdType nCmdType, - OMX_PTR pParams); - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Getcount (OMX_HANDLETYPE handle, - OMX_U32 *pCount); - -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Deinit (OMX_HANDLETYPE handle); - -/* -* _DIO_GetPort from Port Index -*/ -static OMX_PTR _DIO_GetPort(OMX_HANDLETYPE handle, OMX_U32 nPortIndex) -{ - OMX_COMPONENTTYPE *pComp; - OMXBaseComp *pBaseComp; - OMXBase_Port *pPort = NULL; - OMX_U32 nStartPortNumber = 0; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - - pComp = (OMX_COMPONENTTYPE *)(pContext->sCreateParams.hComponent); - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - - nStartPortNumber = pBaseComp->nMinStartPortIndex; - if( pBaseComp->pPorts == NULL ) { - pPort = NULL; - goto EXIT; - } - - pPort = (OMXBase_Port *)pBaseComp->pPorts[nPortIndex - nStartPortNumber]; - -EXIT: - return (pPort); -} - -/* -* DIO NoneTunnel Init -*/ -OMX_ERRORTYPE OMX_DIO_NonTunnel_Init(OMX_HANDLETYPE handle, - OMX_PTR pCreateParams) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - - OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)(((OMX_DIO_CreateParams *)(pCreateParams))->hComponent); - OMXBaseComp *pBaseComPvt = (OMXBaseComp *)pComp->pComponentPrivate; - - /* creating memory for DIO object private area */ - hDIO->pContext = OSAL_Malloc(sizeof(DIO_NonTunnel_Attrs)); - OMX_CHECK(NULL != hDIO->pContext, OMX_ErrorInsufficientResources); - - OSAL_Memset(hDIO->pContext, 0x0, sizeof(DIO_NonTunnel_Attrs)); - - hDIO->open = OMX_DIO_NonTunnel_Open; - hDIO->close = OMX_DIO_NonTunnel_Close; - hDIO->queue = OMX_DIO_NonTunnel_Queue; - hDIO->dequeue = OMX_DIO_NonTunnel_Dequeue; - hDIO->send = OMX_DIO_NonTunnel_Send; - hDIO->cancel = OMX_DIO_NonTunnel_Cancel; - hDIO->control = OMX_DIO_NonTunnel_Control; - hDIO->getcount = OMX_DIO_NonTunnel_Getcount; - hDIO->deinit = OMX_DIO_NonTunnel_Deinit; - - pContext = hDIO->pContext; - /* Initialize private data */ - pContext->sCreateParams = *(OMX_DIO_CreateParams *)pCreateParams; - -EXIT: - return (eError); -} - -/* -* DIO NonTunnel DeInit -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Deinit (OMX_HANDLETYPE handle) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - if( NULL != pContext ) { - OSAL_Free(pContext); - pContext = NULL; - } - - return (eError); -} - -/* -* DIO NonTunnel Open -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Open (OMX_HANDLETYPE handle, - OMX_DIO_OpenParams *pParams) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 i = 0; - OMX_U32 nPortIndex = 0; - OMX_U32 nStartPortNumber = 0; - OMX_U8 *pTmpBuffer = NULL; - OMX_U32 nLocalComBuffers = 0; - OMX_PTR *pBufArr = NULL; - - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); - pComp = (OMX_COMPONENTTYPE *)(pContext->sCreateParams.hComponent); - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - nStartPortNumber = pBaseComp->nMinStartPortIndex; - nPortIndex = pContext->sCreateParams.nPortIndex; - - /* supplier should allocate both the buffer and buffer headers - non supplier should allocate only the buffer headers */ - pPort->pBufferlist = (OMX_BUFFERHEADERTYPE * *)OSAL_Malloc( - (pPort->sPortDef.nBufferCountActual * sizeof(OMX_BUFFERHEADERTYPE *))); - - OMX_CHECK(NULL != pPort->pBufferlist, OMX_ErrorInsufficientResources); - OSAL_Memset(pPort->pBufferlist, 0, (pPort->sPortDef.nBufferCountActual - * sizeof(OMX_BUFFERHEADERTYPE *))); - /* create a buffer header pool */ - pContext->pHdrPool = (OMX_PTR)OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE) - * (pPort->sPortDef.nBufferCountActual)); - OMX_CHECK(NULL != pContext->pHdrPool, OMX_ErrorInsufficientResources); - OSAL_Memset(pContext->pHdrPool, 0, sizeof(OMX_BUFFERHEADERTYPE) * - (pPort->sPortDef.nBufferCountActual)); - - pContext->pPlatformPrivatePool = (OMX_PTR)OSAL_Malloc(pPort->sPortDef.nBufferCountActual - * sizeof(OMXBase_BufHdrPvtData)); - OMX_CHECK(NULL != pContext->pPlatformPrivatePool, OMX_ErrorInsufficientResources); - - /*Setting platform port pvt pool to 0*/ - OSAL_Memset(pContext->pPlatformPrivatePool, 0, - pPort->sPortDef.nBufferCountActual * - sizeof(OMXBase_BufHdrPvtData)); - - if( pPort->bIsBufferAllocator) { - //Setting up fields for calling configure - nLocalComBuffers = pBaseComp->pPorts[nPortIndex - nStartPortNumber]->sProps. - nNumComponentBuffers; - if( nLocalComBuffers != 1 && pBaseComp-> - pPorts[nPortIndex - nStartPortNumber]->sProps.eBufMemoryType != - MEM_TILER8_2D ) { - //For non 2D buffers multiple component buffers not supported - OMX_CHECK(OMX_FALSE, OMX_ErrorBadParameter); - } - - pBufArr = OSAL_Malloc(sizeof(OMX_PTR) * nLocalComBuffers); - OMX_CHECK(NULL != pBufArr, OMX_ErrorInsufficientResources); - } - - /* update buffer list with buffer and buffer headers */ - for( i = 0; i < pPort->sPortDef.nBufferCountActual; i++ ) { - pPort->pBufferlist[i] = (OMX_BUFFERHEADERTYPE *)(pContext->pHdrPool) + i; - OMX_BASE_INIT_STRUCT_PTR(pPort->pBufferlist[i], OMX_BUFFERHEADERTYPE); - pPort->pBufferlist[i]->pPlatformPrivate = - (OMXBase_BufHdrPvtData *)(pContext->pPlatformPrivatePool) + i; - - ((OMXBase_BufHdrPvtData *)(pPort->pBufferlist[i]->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; - ((OMXBase_BufHdrPvtData *)(pPort->pBufferlist[i]->pPlatformPrivate))->bIsLocked = OMX_FALSE; - - if( pPort->bIsBufferAllocator) { - MemHeader *h = &(((OMXBase_BufHdrPvtData *)(pPort->pBufferlist[i]->pPlatformPrivate))->sMemHdr[0]); - pPort->pBufferlist[i]->pBuffer = memplugin_alloc_noheader(h, pParams->nBufSize, 1, MEM_CARVEOUT, 0, 0); - if( nLocalComBuffers == 2 ) { - OMX_CHECK(OMX_FALSE, OMX_ErrorNotImplemented); - } - } - } - - /* create a fixed size OS pipe */ - tStatus = OSAL_CreatePipe(&pContext->pPipeHandle, - (sizeof(OMX_BUFFERHEADERTYPE *) * - pPort->sPortDef.nBufferCountActual), - sizeof(OMX_BUFFERHEADERTYPE *), 1); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); - pPort->nCachedBufferCnt = pPort->sPortDef.nBufferCountActual; - - -EXIT: - if( pBufArr != NULL ) { - OSAL_Free(pBufArr); - pBufArr = NULL; - } - if( OMX_ErrorNone != eError ) { - OMX_DIO_NonTunnel_Close(handle); - } - return (eError); -} - -/* -* DIO NonTunnel Close -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Close(OMX_HANDLETYPE handle) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - OMXBase_Port *pPort = NULL; - OMX_U32 i = 0, j =0, nPortIndex = 0, nStartPortNumber = 0, nCompBufs = 0; - OMX_PTR pTmpBuffer = NULL; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - OMX_CHECK(pContext != NULL, OMX_ErrorNone); - - pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); - if( pPort ) { - pComp = (OMX_COMPONENTTYPE *)(pContext->sCreateParams.hComponent); - if( pComp ) { - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - } - if( pBaseComp ) { - nStartPortNumber = pBaseComp->nMinStartPortIndex; - nPortIndex = pPort->sPortDef.nPortIndex; - nCompBufs = pBaseComp->pPorts[nPortIndex - nStartPortNumber]->sProps.nNumComponentBuffers; - } - if( pPort->pBufferlist ) { - for( i = 0; i < pPort->nCachedBufferCnt; i++ ) { - if( pPort->pBufferlist[i] ) { - if( pPort->bIsBufferAllocator) { - MemHeader *h = &(((OMXBase_BufHdrPvtData *)(pPort->pBufferlist[i]->pPlatformPrivate))->sMemHdr[0]); - memplugin_free_noheader(h); - if( nCompBufs == 2 ) { - OMX_CHECK(OMX_FALSE, OMX_ErrorNotImplemented); - } - } - } - } - /* freeup the buffer list */ - OSAL_Free(pPort->pBufferlist); - pPort->pBufferlist = NULL; - pPort->nCachedBufferCnt = 0; - } - } - - if( pContext->pPlatformPrivatePool ) { - OSAL_Free(pContext->pPlatformPrivatePool); - } - pContext->pPlatformPrivatePool = NULL; - if( pContext->pHdrPool ) { - OSAL_Free(pContext->pHdrPool); - } - pContext->pHdrPool = NULL; - /* delete a OS pipe */ - if( pContext->pPipeHandle != NULL ) { - tStatus = OSAL_DeletePipe(pContext->pPipeHandle); - if( tStatus != OSAL_ErrNone ) { - eError = OMX_ErrorUndefined; - } - pContext->pPipeHandle = NULL; - } - -EXIT: - return (eError); -} - -/* -* DIO NonTunnel Queue -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Queue (OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - OMX_BUFFERHEADERTYPE *pOMXBufHeader; - OMXBase_Port *pPort; - - pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) pBuffHeader; - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - - pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); - tStatus = OSAL_WriteToPipe(pContext->pPipeHandle, &pOMXBufHeader, - sizeof(pOMXBufHeader), OSAL_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - -EXIT: - return (eError); -} - -/* -* DIO NonTunnel Dequeue -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Dequeue (OMX_HANDLETYPE handle, - OMX_PTR *pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - OMXBase_Port *pPort; - uint32_t actualSize = 0; - OMX_BUFFERHEADERTYPE *pOrigOMXBufHeader = NULL; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMX_U32 nPortIndex, nTimeout; - - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); - pComp = (OMX_COMPONENTTYPE *)pContext->sCreateParams.hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - nPortIndex = pPort->sPortDef.nPortIndex; - nTimeout = pBaseComp->pPorts[nPortIndex]->sProps.nTimeoutForDequeue; - /* dequeue the buffer from the data pipe */ - tStatus = OSAL_ReadFromPipe(pContext->pPipeHandle, &pOrigOMXBufHeader, - sizeof(pOrigOMXBufHeader), &actualSize, nTimeout); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - - /*Cancel the buffer and return warning so that derived component may call - GetAttribute*/ - if( pOrigOMXBufHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG ) { - /*Reset codec config flag on o/p port*/ - if( OMX_DirOutput == pPort->sPortDef.eDir ) { - pOrigOMXBufHeader->nFlags &= (~OMX_BUFFERFLAG_CODECCONFIG); - } else { - tStatus = OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, &pOrigOMXBufHeader, - sizeof(pOrigOMXBufHeader), OSAL_NO_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - eError = (OMX_ERRORTYPE)OMX_TI_WarningAttributePending; - goto EXIT; - } - } - *pBuffHeader = (OMX_PTR)pOrigOMXBufHeader; - -EXIT: - return (eError); -} - -/* -* DIO NonTunnel Send -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Send (OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - OMXBase_Port *pPort = NULL; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMX_CALLBACKTYPE *pAppCallbacks = NULL; - OMX_BUFFERHEADERTYPE *pOMXBufHeader; - - pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) pBuffHeader; - - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); - pComp = (OMX_COMPONENTTYPE *)pContext->sCreateParams.hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pAppCallbacks = (OMX_CALLBACKTYPE *)pContext->sCreateParams.pAppCallbacks; - - /* return the buffer back to the Application using EBD or FBD - * depending on the direction of the port (input or output) */ - if (((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->bufSt != OWNED_BY_CLIENT) { - ((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; - if( OMX_DirInput == pPort->sPortDef.eDir ) { - eError = pAppCallbacks->EmptyBufferDone(pComp, - pComp->pApplicationPrivate, pOMXBufHeader); - } else if( OMX_DirOutput == pPort->sPortDef.eDir ) { - eError = pAppCallbacks->FillBufferDone(pComp, - pComp->pApplicationPrivate, pOMXBufHeader); - } - } -EXIT: - return (eError); -} - -/* -* DIO NonTunnel Cancel -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Cancel (OMX_HANDLETYPE handle, - OMX_PTR pBuffHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - OMXBase_Port *pPort = NULL; - OMX_BUFFERHEADERTYPE *pOMXBufHeader; - OMX_COMPONENTTYPE *pComp; - OMXBaseComp *pBaseComp; - OMXBaseComp_Pvt *pBaseCompPvt; - OMX_BOOL bCallProcess = OMX_FALSE; - - pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) pBuffHeader; - - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - pPort = (OMXBase_Port*)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); - - pComp = (OMX_COMPONENTTYPE *)pContext->sCreateParams.hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - - tStatus = OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, &pOMXBufHeader, - sizeof(pOMXBufHeader), OSAL_NO_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - - if( bCallProcess ) { - /*Calling process fn so that event to process the buffer can be generated*/ - pBaseCompPvt->fpInvokeProcessFunction(pComp, DATAEVENT); - } - -EXIT: - return (eError); -} - - -/* -* DIO NonTunnel Control -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Control (OMX_HANDLETYPE handle, - OMX_DIO_CtrlCmdType nCmdType, - OMX_PTR pParams) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - OMXBase_Port *pPort = NULL; - OMX_COMPONENTTYPE *pComp = NULL; - OMXBaseComp *pBaseComp = NULL; - OMXBaseComp_Pvt *pBaseCompPvt = NULL; - OMX_CALLBACKTYPE *pAppCallbacks = NULL; - OMX_BUFFERHEADERTYPE *pBuffHeader = NULL; - MemHeader *pAttrDesc = NULL; - uint32_t elementsInpipe = 0; - uint32_t actualSize = 0; - - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - pComp = (OMX_COMPONENTTYPE *)pContext->sCreateParams.hComponent; - pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; - pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; - pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); - pAppCallbacks = (OMX_CALLBACKTYPE *)pContext->sCreateParams.pAppCallbacks; - - switch( nCmdType ) { - /* Flush the queues or buffers on a port. Both Flush and Stop perform - the same operation i.e. send all the buffers back to the client */ - case OMX_DIO_CtrlCmd_Stop : - case OMX_DIO_CtrlCmd_Flush : - /* return all buffers to the IL client using EBD/FBD depending - * on the direction(input or output) of port */ - - OSAL_GetPipeReadyMessageCount(pContext->pPipeHandle, &elementsInpipe); - - while( elementsInpipe ) { - OSAL_ReadFromPipe(pContext->pPipeHandle, &pBuffHeader, - sizeof(pBuffHeader), &actualSize, OSAL_NO_SUSPEND); - elementsInpipe--; - if (((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt != OWNED_BY_CLIENT) { - ((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; - if( OMX_DirInput == pPort->sPortDef.eDir ) { - eError = pAppCallbacks->EmptyBufferDone(pComp, - pComp->pApplicationPrivate, pBuffHeader); - } else if( OMX_DirOutput == pPort->sPortDef.eDir ) { - pBuffHeader->nFilledLen = 0; - eError = pAppCallbacks->FillBufferDone(pComp, - pComp->pApplicationPrivate, pBuffHeader); - } - } - } - break; - - case OMX_DIO_CtrlCmd_Start : - /*If there are buffers in the pipe in case of pause to executing - then start processing them*/ - OSAL_GetPipeReadyMessageCount(pContext->pPipeHandle, &elementsInpipe); - if( elementsInpipe ) { - pBaseCompPvt->fpInvokeProcessFunction(pComp, DATAEVENT); - } else { - OSAL_ErrorTrace(" Nothing to do "); - } - break; - - case OMX_DIO_CtrlCmd_GetCtrlAttribute : - /*Buffer should be available when calling GetAttribute*/ - tStatus = OSAL_IsPipeReady(pContext->pPipeHandle); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - - tStatus = OSAL_ReadFromPipe(pContext->pPipeHandle, &pBuffHeader, - sizeof(pBuffHeader), &actualSize, OSAL_NO_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - if( !(pBuffHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) { - /*This buffer does not contain codec config*/ - eError = OMX_ErrorUndefined; - /*Write the buffer back to front of pipe*/ - OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, &pBuffHeader, - sizeof(pBuffHeader), OSAL_SUSPEND); - goto EXIT; - } - pAttrDesc = ((OMXBase_CodecConfigBuf*)pParams)->sBuffer; - if( pAttrDesc->size < pBuffHeader->nFilledLen ) { - tStatus = OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, - &pBuffHeader, sizeof(pBuffHeader), OSAL_SUSPEND); - pAttrDesc->size = pBuffHeader->nFilledLen; - - eError = (OMX_ERRORTYPE)OMX_TI_WarningInsufficientAttributeSize; - goto EXIT; - } - pAttrDesc->size = pBuffHeader->nFilledLen; - OSAL_Memcpy(H2P(pAttrDesc), pBuffHeader->pBuffer + pBuffHeader->nOffset, - pAttrDesc->size); - - /*Send the buffer back*/ - pBuffHeader->nFlags &= (~OMX_BUFFERFLAG_CODECCONFIG); - if (((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt != OWNED_BY_CLIENT) { - ((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; - if( OMX_DirInput == pPort->sPortDef.eDir ) { - eError = pAppCallbacks->EmptyBufferDone(pComp, - pComp->pApplicationPrivate, pBuffHeader); - } else if( OMX_DirOutput == pPort->sPortDef.eDir ) { - /*So that the other port does not try to interpret any garbage - data that may be present*/ - pBuffHeader->nFilledLen = 0; - eError = pAppCallbacks->FillBufferDone(pComp, - pComp->pApplicationPrivate, pBuffHeader); - } - } - break; - - case OMX_DIO_CtrlCmd_SetCtrlAttribute : - /*Buffer should be available when calling SetAttribute*/ - tStatus = OSAL_IsPipeReady(pContext->pPipeHandle); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - - tStatus = OSAL_ReadFromPipe(pContext->pPipeHandle, &pBuffHeader, - sizeof(pBuffHeader), &actualSize, OSAL_NO_SUSPEND); - OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); - - pBuffHeader->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; - pAttrDesc = ((OMXBase_CodecConfigBuf *)pParams)->sBuffer; - if( pBuffHeader->nAllocLen < pAttrDesc->size ) { - OSAL_ErrorTrace("Cannot send attribute data, size is too large"); - tStatus = OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, - &pBuffHeader, sizeof(pBuffHeader), OSAL_SUSPEND); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - pBuffHeader->nFilledLen = pAttrDesc->size; - OSAL_Memcpy(pBuffHeader->pBuffer, pAttrDesc->ptr, pAttrDesc->size); - if (((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt != OWNED_BY_CLIENT) { - ((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; - /*Send the buffer*/ - if( OMX_DirInput == pPort->sPortDef.eDir ) { - eError = pAppCallbacks->EmptyBufferDone(pComp, - pComp->pApplicationPrivate, pBuffHeader); - } else if( OMX_DirOutput == pPort->sPortDef.eDir ) { - eError = pAppCallbacks->FillBufferDone(pComp, - pComp->pApplicationPrivate, pBuffHeader); - } - } - break; - - default : - OSAL_ErrorTrace(" Invalid Command received \n"); - eError = OMX_ErrorUnsupportedIndex; - break; - } - -EXIT: - return (eError); -} - - -/* -* DIO Non Tunnel GEtCount -*/ -static OMX_ERRORTYPE OMX_DIO_NonTunnel_Getcount (OMX_HANDLETYPE handle, - OMX_U32 *pCount) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; - DIO_NonTunnel_Attrs *pContext = NULL; - OMXBase_Port *pPort = NULL; - - pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; - pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); - if( pPort->bEosRecd && pPort->sPortDef.eDir == OMX_DirInput ) { - eError = (OMX_ERRORTYPE)OMX_TI_WarningEosReceived; - } - - OSAL_GetPipeReadyMessageCount(pContext->pPipeHandle, (uint32_t*)pCount); - - return (eError); -} - - diff --git a/omx/base/omx_base_dio_plugin/src/omx_base_dio_table.c b/omx/base/omx_base_dio_plugin/src/omx_base_dio_table.c deleted file mode 100644 index e6ec96b..0000000 --- a/omx/base/omx_base_dio_plugin/src/omx_base_dio_table.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <string.h> -#include "omx_base_internal.h" -#include "omx_base_dio_plugin.h" - - -extern OMX_ERRORTYPE OMX_DIO_NonTunnel_Init(OMX_HANDLETYPE handle, - OMX_PTR pCreateParams); - -OMX_DIO_Register OMX_DIO_Registered[] = -{ - { "OMX.DIO.NONTUNNEL", &OMX_DIO_NonTunnel_Init }, - { NULL, NULL } - -}; - diff --git a/omx/base/omx_core/inc/OMX_ComponentRegistry.h b/omx/base/omx_core/inc/OMX_ComponentRegistry.h deleted file mode 100755 index e4bed35..0000000 --- a/omx/base/omx_core/inc/OMX_ComponentRegistry.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <dirent.h> - -#define MAX_ROLES 20 -#define MAX_TABLE_SIZE 50 - -typedef struct _ComponentTable { - OMX_STRING name; - OMX_U16 nRoles; - OMX_STRING pRoleArray[MAX_ROLES]; -}ComponentTable; - -OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( - OMX_IN OMX_STRING compName, - OMX_INOUT OMX_U32 *pNumRoles, - OMX_OUT OMX_U8 **roles); - -OMX_ERRORTYPE OMX_PrintComponentTable(); -OMX_ERRORTYPE OMX_BuildComponentTable(); -OMX_ERRORTYPE ComponentTable_EventHandler( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, - OMX_IN OMX_U32 nData2, - OMX_IN OMX_PTR pEventData); - -OMX_ERRORTYPE ComponentTable_EmptyBufferDone( - OMX_OUT OMX_HANDLETYPE hComponent, - OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); - -OMX_ERRORTYPE ComponentTable_FillBufferDone( - OMX_OUT OMX_HANDLETYPE hComponent, - OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); diff --git a/omx/base/omx_core/inc/OMX_Core_Wrapper.h b/omx/base/omx_core/inc/OMX_Core_Wrapper.h deleted file mode 100755 index 5d1adaf..0000000 --- a/omx/base/omx_core/inc/OMX_Core_Wrapper.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -/** OMX_Core_Wrapper.h -*/ - -#ifndef OMX_Core_Wrapper_h -#define OMX_Core_Wrapper_h - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Each OMX header shall include all required header files to allow the - * header to compile without errors. The includes below are required - * for this header file to compile successfully - */ - -#include <OMX_Core.h> - -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_Init(void); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_Deinit(void); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_ComponentNameEnum( - OMX_OUT OMX_STRING cComponentName, - OMX_IN OMX_U32 nNameLength, - OMX_IN OMX_U32 nIndex); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_GetHandle( - OMX_OUT OMX_HANDLETYPE* pHandle, - OMX_IN OMX_STRING cComponentName, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_CALLBACKTYPE* pCallBacks); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_FreeHandle( - OMX_IN OMX_HANDLETYPE hComponent); -OMX_API OMX_ERRORTYPE TIOMX_GetComponentsOfRole ( - OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 *pNumComps, - OMX_INOUT OMX_U8 **compNames); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_SetupTunnel( - OMX_IN OMX_HANDLETYPE hOutput, - OMX_IN OMX_U32 nPortOutput, - OMX_IN OMX_HANDLETYPE hInput, - OMX_IN OMX_U32 nPortInput); -OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_GetContentPipe( - OMX_OUT OMX_HANDLETYPE *hPipe, - OMX_IN OMX_STRING szURI); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/omx/base/omx_core/inc/OMX_TI_Custom.h b/omx/base/omx_core/inc/OMX_TI_Custom.h deleted file mode 100644 index 7fbe9e5..0000000 --- a/omx/base/omx_core/inc/OMX_TI_Custom.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef OMX_TI_Custom_H -#define OMX_TI_Custom_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <OMX_IVCommon.h> - -/** -* A pointer to this struct is passed to the OMX_SetParameter when the extension -* index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension -* is given. -* The corresponding extension Index is OMX_TI_IndexUseNativeBuffers. -* This will be used to inform OMX about the presence of gralloc pointers instead -* of virtual pointers -*/ -typedef struct OMX_TI_PARAMUSENATIVEBUFFER { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnable; -} OMX_TI_PARAMUSENATIVEBUFFER; - -/** -* A pointer to this struct is passed to OMX_GetParameter when the extension -* index for the 'OMX.google.android.index.getAndroidNativeBufferUsage' -* extension is given. -* The corresponding extension Index is OMX_TI_IndexAndroidNativeBufferUsage. -* The usage bits returned from this query will be used to allocate the Gralloc -* buffers that get passed to the useAndroidNativeBuffer command. -*/ -typedef struct OMX_TI_PARAMNATIVEBUFFERUSAGE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_U32 nUsage; -} OMX_TI_PARAMNATIVEBUFFERUSAGE; - -typedef enum OMX_TI_INDEXTYPE { - OMX_TI_IndexUseNativeBuffers = ((OMX_INDEXTYPE)OMX_IndexVendorStartUnused + 1), - OMX_TI_IndexAndroidNativeBufferUsage, - OMX_TI_IndexParamTimeStampInDecodeOrder, - OMX_TI_IndexEncoderReceiveMetadataBuffers, - OMX_TI_IndexDescribeColorFormat, - OMX_TI_IndexEnableDecoderZeroDisplayDelayMode, - OMX_TI_IndexPrepareForAdaptivePlayback - } OMX_TI_INDEXTYPE; - -typedef enum OMX_TI_ERRORTYPE -{ - /*Control attribute is pending - Dio_Dequeue will not work until attribute - is retreived*/ - OMX_TI_WarningAttributePending = (OMX_S32)((OMX_ERRORTYPE)OMX_ErrorVendorStartUnused + 1), - /*Attribute buffer size is insufficient - reallocate the attribute buffer*/ - OMX_TI_WarningInsufficientAttributeSize, - /*EOS buffer has been received*/ - OMX_TI_WarningEosReceived, - /*Port enable is called on an already enabled port*/ - OMX_TI_ErrorPortIsAlreadyEnabled, - /*Port disable is called on an already disabled port*/ - OMX_TI_ErrorPortIsAlreadyDisabled -} OMX_TI_ERRORTYPE; - - -/** -* OMX_TI_VIDEO_CONFIG_AVC_LTRP_INTERVAL : Structure to enable timestamps in decode order -* at i/p of decoders. -*/ -typedef struct OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_BOOL bEnabled; -} OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER; - - -/** -* OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE : Structure to enable Decoder zero display delay mode -* -*/ -typedef struct OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnabled; -} OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE; - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/omx/base/omx_core/src/OMX_Core.c b/omx/base/omx_core/src/OMX_Core.c deleted file mode 100644 index 88bbcd2..0000000 --- a/omx/base/omx_core/src/OMX_Core.c +++ /dev/null @@ -1,765 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_CORE" - -#include <dlfcn.h> /* For dynamic loading */ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <pthread.h> - -#include <OMX_Component.h> -#include <OMX_Core.h> -#include <OMX_ComponentRegistry.h> - -#include <memplugin.h> - -#include "osal_error.h" -#include "osal_trace.h" -#include "osal_mutex.h" - -/** size for the array of allocated components. Sets the maximum -* number of components that can be allocated at once -*/ -#define MAXCOMP (50) -#define MAXNAMESIZE (128) -#define EMPTY_STRING "\0" - -/** Determine the number of elements in an array */ -#define COUNTOF(x) (sizeof(x) / sizeof(x[0])) - -/** Array to hold the DLL pointers for each allocated component */ -static void *pModules[MAXCOMP] = { 0 }; - -/** Array to hold the component handles for each allocated component */ -static void *pComponents[COUNTOF(pModules)] = { 0 }; - -/* count for call OMX_Init() */ -int count = 0; -pthread_mutex_t mutex; -void *pCoreInitMutex = NULL; - -int tableCount = 0; -ComponentTable componentTable[MAX_TABLE_SIZE]; -char *sRoleArray[60][20]; -char compName[60][200]; -#define MAX_CONCURRENT_INSTANCES 5 //aligned with IPUMM definitions -int concurrent_instances = 0; - -char *tComponentName[MAXCOMP][MAX_ROLES] = -{ - /*video decoder */ - { "OMX.TI.DUCATI1.VIDEO.DECODER", - "video_decoder.mpeg4", - "video_decoder.avc", - "video_decoder.h263", - "video_decoder.mpeg2", - NULL }, - { "OMX.TI.DUCATI1.VIDEO.H264E", - "video_encoder.avc", NULL }, - /* terminate the table */ - { NULL, NULL }, -}; - -extern OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent); - -#define CORE_assert CORE_paramCheck -#define CORE_require CORE_paramCheck -#define CORE_ensure CORE_paramCheck - -#define CORE_paramCheck(C, V, S) do {\ - if( !(C)) { eError = V;\ - ALOGE("failed check: " # C);\ - ALOGE(" - returning error: " # V);\ - if( S ) { ALOGE(" - %s", S); }\ - goto EXIT; }\ -} while( 0 ) - -/* -* OMX_Init() -* -* Description:This method will initialize the OMX Core. It is the -* responsibility of the application to call OMX_Init to ensure the proper -* set up of core resources. -* -* Returns: OMX_NOERROR Successful -* -* Note -*/ -OMX_ERRORTYPE OMX_Init() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR eOsalError = OSAL_ErrNone; - - eOsalError = OSAL_ObtainMutex(pCoreInitMutex, OSAL_SUSPEND); - CORE_assert(eOsalError == OSAL_ErrNone, OMX_ErrorInsufficientResources, "Mutex lock failed"); - count++; - if( count == 1 ) { - pthread_mutex_init(&mutex, NULL); - eError = OMX_BuildComponentTable(); - memplugin_open(); - } - - eOsalError = OSAL_ReleaseMutex(pCoreInitMutex); - CORE_assert(eOsalError == OSAL_ErrNone, OMX_ErrorInsufficientResources, "Mutex release failed"); -EXIT: - return (eError); -} - -/* -* OMX_GetHandle -* -* Description: This method will create the handle of the COMPONENTTYPE -* If the component is currently loaded, this method will reutrn the -* hadle of existingcomponent or create a new instance of the component. -* It will call the OMX_ComponentInit function and then the setcallback -* method to initialize the callback functions -* Parameters: -* @param[out] pHandle Handle of the loaded components -* @param[in] cComponentName Name of the component to load -* @param[in] pAppData Used to identify the callbacks of component -* @param[in] pCallBacks Application callbacks -* -* @retval OMX_ErrorUndefined -* @retval OMX_ErrorInvalidComponentName -* @retval OMX_ErrorInvalidComponent -* @retval OMX_ErrorInsufficientResources -* @retval OMX_NOERROR Successful -* -* Note -*/ - -OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE *pHandle, - OMX_STRING cComponentName, OMX_PTR pAppData, - OMX_CALLBACKTYPE *pCallBacks) -{ - static const char prefix[] = "lib"; - static const char postfix[] = ".so"; - - OMX_ERRORTYPE (*pComponentInit)(OMX_HANDLETYPE *); - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *componentType; - int i; - char buf[sizeof(prefix) + MAXNAMESIZE + sizeof(postfix)]; - const char *pErr = dlerror(); - char *dlError = NULL; - if( pthread_mutex_lock(&mutex) != 0 ) { - OSAL_ErrorTrace("Core: Error in Mutex lock"); - } - - CORE_require(NULL != cComponentName, OMX_ErrorBadParameter, NULL); - CORE_require(NULL != pHandle, OMX_ErrorBadParameter, NULL); - CORE_require(NULL != pCallBacks, OMX_ErrorBadParameter, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, "OMX_GetHandle called without calling OMX_Init first"); - CORE_require(concurrent_instances < MAX_CONCURRENT_INSTANCES, OMX_ErrorInsufficientResources, "Max Concurrent Instances reached"); - - concurrent_instances++; - - /* Verify that the name is not too long and could cause a crash. Notice - * that the comparison is a greater than or equals. This is to make - * sure that there is room for the terminating NULL at the end of the - * name. */ - CORE_require(strlen(cComponentName) < MAXNAMESIZE, - OMX_ErrorInvalidComponentName, NULL); - - /* Locate the first empty slot for a component. If no slots - * are available, error out */ - for( i = 0; i < (int)COUNTOF(pModules); i++ ) { - if( pModules[i] == NULL ) { - break; - } - } - - CORE_assert(i != COUNTOF(pModules), OMX_ErrorInsufficientResources, NULL); - - /* load the component and check for an error. If filename is not an - * absolute path (i.e., it does not begin with a "/" ), then the - * file is searched for in the following locations: - * - * The LD_LIBRARY_PATH environment variable locations - * The library cache, /etc/ld.so.cache. - * /lib - * /usr/lib - * - * If there is an error, we can't go on, so set the error code and exit */ - strcpy(buf, prefix); /* the lengths are defined herein or have been */ - strcat(buf, cComponentName); /* checked already, so strcpy and strcat are */ - strcat(buf, postfix); /* are safe to use in this context. */ - - pModules[i] = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL); - if( pModules[i] == NULL ) { - dlError = (char *)dlerror(); - OSAL_ErrorTrace("Failed because %s", dlError); - eError = OMX_ErrorComponentNotFound; - goto EXIT; - } - - /* Get a function pointer to the "OMX_ComponentInit" function. If - * there is an error, we can't go on, so set the error code and exit */ - pComponentInit = dlsym(pModules[i], "OMX_ComponentInit"); - pErr = dlerror(); - CORE_assert(((pErr == NULL) && (pComponentInit != NULL)), OMX_ErrorInvalidComponent, NULL); - - /* We now can access the dll. So, we need to call the "OMX_ComponentInit" - * method to load up the "handle" (which is just a list of functions to - * call) and we should be all set. - */ - *pHandle = malloc(sizeof(OMX_COMPONENTTYPE)); - CORE_assert((*pHandle != NULL), OMX_ErrorInsufficientResources, "Malloc of pHandle* failed"); - - pComponents[i] = *pHandle; - componentType = (OMX_COMPONENTTYPE *) *pHandle; - componentType->nSize = sizeof(OMX_COMPONENTTYPE); - - componentType->nVersion.s.nVersionMajor = 1; - componentType->nVersion.s.nVersionMinor = 1; - componentType->nVersion.s.nRevision = 0; - componentType->nVersion.s.nStep = 0; - - eError = (*pComponentInit)(*pHandle); - if( OMX_ErrorNone == eError ) { - eError = (componentType->SetCallbacks)(*pHandle, pCallBacks, pAppData); - CORE_assert(eError == OMX_ErrorNone, eError, "Core: Error returned from component SetCallBack"); - } else { - /* when the component fails to initialize, release the - component handle structure */ - free(*pHandle); - /* mark the component handle as NULL to prevent the caller from - actually trying to access the component with it, should they - ignore the return code */ - *pHandle = NULL; - pComponents[i] = NULL; - dlclose(pModules[i]); - pModules[i] = NULL; - goto EXIT; - } - eError = OMX_ErrorNone; -EXIT: - if( pthread_mutex_unlock(&mutex) != 0 ) { - OSAL_ErrorTrace("Core: Error in Mutex unlock"); - } - return (eError); -} - -/* -* OMX_FreeHandle() -* -* Description:This method will unload the OMX component pointed by -* OMX_HANDLETYPE. It is the responsibility of the calling method to ensure that -* the Deinit method of the component has been called prior to unloading component -* -* Parameters: -* @param[in] hComponent the component to unload -* -* Returns: OMX_NOERROR Successful -* -* Note -* -*/ -OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorUndefined; - OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *) hComponent; - int i; - - if( pthread_mutex_lock(&mutex) != 0 ) { - OSAL_ErrorTrace("Core: Error in Mutex lock"); - } - - CORE_require(pHandle != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, "OMX_FreeHandle called without calling OMX_Init first"); - - /* Locate the component handle in the array of handles */ - for( i = 0; i < (int)COUNTOF(pModules); i++ ) { - if( pComponents[i] == hComponent ) { - break; - } - } - - CORE_assert(i != COUNTOF(pModules), OMX_ErrorBadParameter, NULL); - - eError = pHandle->ComponentDeInit(hComponent); - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("Error From ComponentDeInit.."); - } - - /* release the component and the component handle */ - dlclose(pModules[i]); - pModules[i] = NULL; - free(pComponents[i]); - - pComponents[i] = NULL; - - concurrent_instances--; - eError = OMX_ErrorNone; - -EXIT: - /* The unload is now complete, so set the error code to pass and exit */ - if( pthread_mutex_unlock(&mutex) != 0 ) { - OSAL_ErrorTrace("Core: Error in Mutex unlock"); - } - - return (eError); -} - -/* -* OMX_DeInit() -* -* Description:This method will release the resources of the OMX Core. It is the -* responsibility of the application to call OMX_DeInit to ensure the clean up of these -* resources. -* -* Returns: OMX_NOERROR Successful -* -* Note -* -*/ -OMX_ERRORTYPE OMX_Deinit() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR eOsalError = OSAL_ErrNone; - - eOsalError = OSAL_ObtainMutex(pCoreInitMutex, OSAL_SUSPEND); - if( eOsalError != OSAL_ErrNone ) { - OSAL_ErrorTrace("Mutex lock failed"); - } - /*Returning error none because of OMX spec limitation on error codes that - can be returned by OMX_Deinit */ - CORE_assert(count > 0, OMX_ErrorNone, "OMX_Deinit being called without a corresponding OMX_Init"); - count--; - - if( pthread_mutex_lock(&mutex) != 0 ) { - OSAL_ErrorTrace("Core: Error in Mutex lock"); - } - - if( count == 0 ) { - memplugin_close(); - if( pthread_mutex_unlock(&mutex) != 0 ) { - OSAL_ErrorTrace("Core: Error in Mutex unlock"); - } - if( pthread_mutex_destroy(&mutex) != 0 ) { - OSAL_ErrorTrace("%d :: Core: Error in Mutex destroy\n" ,__LINE__); - } - } else { - if( pthread_mutex_unlock(&mutex) != 0 ) { - OSAL_ErrorTrace("Core: Error in Mutex unlock"); - } - } - -EXIT: - eOsalError = OSAL_ReleaseMutex(pCoreInitMutex); - if( eOsalError != OSAL_ErrNone) { - OSAL_ErrorTrace("Mutex release failed"); - } - return (eError); -} - -/* -* OMX_SetupTunnel() -* -* Description: Setup the specified tunnel the two components -* -* Parameters: -* @param[in] hOutput Handle of the component to be accessed -* @param[in] nPortOutput Source port used in the tunnel -* @param[in] hInput Component to setup the tunnel with. -* @param[in] nPortInput Destination port used in the tunnel -* -* Returns: OMX_NOERROR Successful -* -* Note -* -*/ -/* OMX_SetupTunnel */ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel(OMX_IN OMX_HANDLETYPE - hOutput, OMX_IN OMX_U32 nPortOutput, OMX_IN OMX_HANDLETYPE hInput, - OMX_IN OMX_U32 nPortInput) -{ - OMX_ERRORTYPE eError = OMX_ErrorNotImplemented; - OMX_COMPONENTTYPE *pCompIn, *pCompOut; - OMX_TUNNELSETUPTYPE oTunnelSetup; - - if( hOutput == NULL && hInput == NULL ) { - return (OMX_ErrorBadParameter); - } - - oTunnelSetup.nTunnelFlags = 0; - oTunnelSetup.eSupplier = OMX_BufferSupplyUnspecified; - - pCompOut = (OMX_COMPONENTTYPE *) hOutput; - if( hOutput ) { - eError = pCompOut->ComponentTunnelRequest(hOutput, nPortOutput, - hInput, nPortInput, &oTunnelSetup); - } - - if( eError == OMX_ErrorNone && hInput ) { - pCompIn = (OMX_COMPONENTTYPE *) hInput; - eError = pCompIn->ComponentTunnelRequest(hInput, nPortInput, - hOutput, nPortOutput, &oTunnelSetup); - if( eError != OMX_ErrorNone && hOutput ) { - /* cancel tunnel request on output port since input port failed */ - pCompOut->ComponentTunnelRequest(hOutput, nPortOutput, NULL, 0, NULL); - } - } - return (eError); -} - -/* -* OMX_ComponentNameEnum() -* -* Description: This method will provide the name of the component at the given nIndex -* -* Parameters: -* @param[out] cComponentName The name of the component at nIndex -* @param[in] nNameLength The length of the component name -* @param[in] nIndex The index number of the component -* -* Returns: OMX_NOERROR Successful -* -* Note -* -*/ -OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(OMX_OUT OMX_STRING - cComponentName, OMX_IN OMX_U32 nNameLength, OMX_IN OMX_U32 nIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - CORE_require(cComponentName != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, "OMX_GetHandle called without calling OMX_Init first"); - - if( nIndex >= (OMX_U32)tableCount ) { - eError = OMX_ErrorNoMore; - } else if (strlen(componentTable[nIndex].name) > nNameLength) { - eError = OMX_ErrorBadParameter; - } else { - strcpy(cComponentName, componentTable[nIndex].name); - } -EXIT: - return (eError); -} - -/* -* OMX_GetRolesOfComponent() -* -* Description: This method will query the component for its supported roles -* -* Parameters: -* @param[in] cComponentName The name of the component to query -* @param[in] pNumRoles The number of roles supported by the component -* @param[in] roles The roles of the component -* -* Returns: OMX_NOERROR Successful -* OMX_ErrorBadParameter Faliure due to a bad input parameter -* -* Note -* -*/ -OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent(OMX_IN OMX_STRING - cComponentName, OMX_INOUT OMX_U32 *pNumRoles, OMX_OUT OMX_U8 * *roles) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U32 i = 0; - OMX_U32 j = 0; - OMX_BOOL bFound = OMX_FALSE; - - CORE_require(cComponentName != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(pNumRoles != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(strlen(cComponentName) < MAXNAMESIZE, - OMX_ErrorInvalidComponentName, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, "OMX_GetHandle called without calling OMX_Init first"); - - while( !bFound && i < (OMX_U32)tableCount ) { - if( strcmp(cComponentName, componentTable[i].name) == 0 ) { - bFound = OMX_TRUE; - } else { - i++; - } - } - - if( roles == NULL ) { - *pNumRoles = componentTable[i].nRoles; - goto EXIT; - } else { - if( bFound && (*pNumRoles == componentTable[i].nRoles)) { - for( j = 0; j < componentTable[i].nRoles; j++ ) { - strcpy((OMX_STRING) roles[j], - componentTable[i].pRoleArray[j]); - } - } - } -EXIT: - return (eError); -} - -/* -* OMX_GetComponentsOfRole() -* -* Description: This method will query the component for its supported roles -* -* Parameters: -* @param[in] role The role name to query for -* @param[in] pNumComps The number of components supporting the given role -* @param[in] compNames The names of the components supporting the given role -* -* Returns: OMX_NOERROR Successful -* -* Note -* -*/ -OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole(OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 *pNumComps, OMX_INOUT OMX_U8 * *compNames) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U32 i = 0; - OMX_U32 j = 0; - OMX_U32 k = 0; - - CORE_require(role != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(pNumComps != NULL, OMX_ErrorBadParameter, NULL); - CORE_require(count > 0, OMX_ErrorUndefined, "OMX_GetHandle called without calling OMX_Init first"); - - /* This implies that the componentTable is not filled */ - CORE_assert(componentTable[i].pRoleArray[j] != NULL, OMX_ErrorBadParameter, NULL); - - for( i = 0; i < (OMX_U32)tableCount; i++ ) { - for( j = 0; j < componentTable[i].nRoles; j++ ) { - if( strcmp(componentTable[i].pRoleArray[j], role) == 0 ) { - /* the first call to this function should only count the number - of roles so that for the second call compNames can be allocated - with the proper size for that number of roles */ - if( compNames != NULL ) { - strncpy((OMX_STRING) (compNames[k]), - (OMX_STRING) componentTable[i].name, MAXNAMESIZE); - } - k++; - } - } - *pNumComps = k; - } - -EXIT: - return (eError); -} - -/*************************************** -PRINT TABLE FOR DEBUGGING PURPOSES ONLY -***************************************/ - -OMX_API OMX_ERRORTYPE OMX_PrintComponentTable() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - int i = 0; - int j = 0; - - OSAL_Info("--------Component Table:: %d Components found-------------", - tableCount); - - for( i = 0; i < tableCount; i++ ) { - OSAL_Info("%i:: %s", i, componentTable[i].name); - - for( j = 0; j < componentTable[i].nRoles; j++ ) { - OSAL_Info("%s", componentTable[i].pRoleArray[j]); - } - } - - OSAL_Info("-----------------End Component Table ------------------"); - return (eError); -} - -OMX_ERRORTYPE OMX_BuildComponentTable() -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_CALLBACKTYPE sCallbacks; - -#ifndef STATIC_TABLE - OMX_HANDLETYPE hComp = 0; - OMX_U8 cRole[MAXNAMESIZE]; - OMX_STRING tempName = NULL; - OMX_STRING temp = NULL; - static OMX_STRING namePrefix = "OMX"; - static OMX_STRING filePrefix = "libOMX."; - static OMX_STRING suffix = ".so"; -#endif - int j = 0; - int numFiles = 0; - int i, k; - int componentfound = 0; - - /* set up dummy call backs */ - sCallbacks.EventHandler = ComponentTable_EventHandler; - sCallbacks.EmptyBufferDone = ComponentTable_EmptyBufferDone; - sCallbacks.FillBufferDone = ComponentTable_FillBufferDone; - -#ifndef STATIC_TABLE - /* scan the target/lib directory and create a list of files in the directory */ - numFiles = scandir(libdir, &namelist, 0, 0); - tableCount = 0; - - while( numFiles-- ) { - /* check if the file is an OMX component */ - if( strncmp(namelist[numFiles]->d_name, filePrefix, strlen(filePrefix)) == 0 ) { - /* if the file is an OMX component, trim the prefix and suffix */ - tempName = (OMX_STRING) malloc(sizeof(namelist[numFiles]->d_name) + 1); /* adding one ensures */ - memset(tempName, 0x00, sizeof(namelist[numFiles]->d_name) + 1); /* that a null terminator will */ - /* always be present */ - /* copy only the name without the suffix */ - strncpy(tempName, namelist[numFiles]->d_name, - strlen(namelist[numFiles]->d_name) - - strlen(suffix)); - /* set a pointer to be after the lib prefix, i.e the beginning of the component name */ - temp = strstr(tempName, namePrefix); - /* then copy the component name to the table */ - /* - compName[tableCount]= (OMX_STRING) malloc(MAXNAMESIZE); - */ - strncpy(compName[tableCount], temp, strlen(temp) + 1); - componentTable[tableCount].name = - compName[tableCount]; - - /* get the handle for the component and query for the roles of each component */ - eError = OMX_GetHandle(&hComp, componentTable[tableCount].name, 0x0, &sCallbacks); - if( eError == OMX_ErrorNone ) { - j = 0; - while( eError != OMX_ErrorNoMore ) { - eError = ((OMX_COMPONENTTYPE *) hComp)->ComponentRoleEnum(hComp, cRole, j++); - if( eError == OMX_ErrorNotImplemented ) { - j = 1; - break; - } - } - nRoles = j - 1; - componentTable[tableCount].nRoles = nRoles; - /* sRoleArray[tableCount] = (OMX_STRING *) malloc(nRoles * sizeof(OMX_STRING)); */ - if( nRoles > 0 ) { - /* sRoleArray[tableCount] = (OMX_STRING *) malloc(nRoles * sizeof(OMX_STRING)); */ - for( j = 0; j < nRoles; j++ ) { - sRoleArray[tableCount][j] = (OMX_STRING)malloc(sizeof(OMX_U8) *MAXNAMESIZE); - ((OMX_COMPONENTTYPE *)hComp)->ComponentRoleEnum(hComp, (OMX_U8 *)sRoleArray[tableCount][j], j); - componentTable[tableCount].pRoleArray[j] = sRoleArray[tableCount][j]; - } - } else { - /* sRoleArray[tableCount] = (OMX_STRING *) malloc(sizeof(OMX_STRING)); */ - sRoleArray[tableCount][j] = (OMX_STRING) malloc(sizeof(OMX_U8)* MAXNAMESIZE); - strcpy(sRoleArray[tableCount][j], EMPTY_STRING); - componentTable[tableCount].pRoleArray[j] = sRoleArray[tableCount][j]; - } - } - if( hComp ) { - /* free the component handle */ - eError = OMX_FreeHandle(hComp); - if( eError != OMX_ErrorNone ) { - goto EXIT; - } - } - /* increment the table counter index only if above was successful */ - tableCount++; - if( tempName != NULL ) { - free(tempName); - } - } - } -#endif - for( i = 0, numFiles = 0; i < MAXCOMP; i++ ) { - if( tComponentName[i][0] == NULL ) { - break; - } - - for( j = 0; j < numFiles; j++ ) { - if( !strcmp(componentTable[j].name, tComponentName[i][0])) { - componentfound = 1; - break; - } - } - - if( componentfound == 1 ) { - continue; - } - - if( j == numFiles ) { /* new component */ - k = 1; - while( tComponentName[i][k] != NULL ) { - componentTable[numFiles].pRoleArray[k - 1] = - tComponentName[i][k]; - k++; - } - - componentTable[numFiles].nRoles = k - 1; - strcpy(compName[numFiles], tComponentName[i][0]); - componentTable[numFiles].name = compName[numFiles]; - numFiles++; - } - } - - tableCount = numFiles; - CORE_assert(eError == OMX_ErrorNone, eError, "Could not build Component Table"); -EXIT: - return (eError); -} - -OMX_ERRORTYPE ComponentTable_EventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData) -{ - (void)hComponent, pAppData, eEvent, nData1, nData2, pEventData; - return (OMX_ErrorNotImplemented); -} - -OMX_ERRORTYPE ComponentTable_EmptyBufferDone(OMX_OUT OMX_HANDLETYPE - hComponent, OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE *pBuffer) -{ - (void)hComponent, pAppData, pBuffer; - - return (OMX_ErrorNotImplemented); -} - -OMX_ERRORTYPE ComponentTable_FillBufferDone(OMX_OUT OMX_HANDLETYPE hComponent, - OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_BUFFERHEADERTYPE *pBuffer) -{ - (void)hComponent, pAppData, pBuffer; - - return (OMX_ErrorNotImplemented); -} - -/* - * @fn Core_Setup : This function is called when the the OMX Core library is - * loaded. It creates a mutex, which is used during OMX_Init() - */ -void __attribute__ ((constructor)) Core_Setup(void) -{ - OSAL_ERROR eError = OSAL_ErrNone; - eError = OSAL_CreateMutex(&pCoreInitMutex); - if( eError != OSAL_ErrNone ) { - OSAL_ErrorTrace("Creation of default mutex failed"); - } -} - -/* - * @fn Core_Destroy : This function is called when the the OMX Core library is - * unloaded. It destroys the mutex which was created by - * Core_Setup(). - * - */ -void __attribute__ ((destructor)) Core_Destroy(void) -{ - OSAL_ERROR eError = OSAL_ErrNone; - eError = OSAL_DeleteMutex(pCoreInitMutex); - if( eError != OSAL_ErrNone ) { - OSAL_ErrorTrace("Destruction of default mutex failed"); - } -} - diff --git a/omx/base/omx_core/src/OMX_Core_Wrapper.c b/omx/base/omx_core/src/OMX_Core_Wrapper.c deleted file mode 100755 index c069ae3..0000000 --- a/omx/base/omx_core/src/OMX_Core_Wrapper.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_CORE_WRAPPER" - -#include <OMX_Component.h> -#include <OMX_Core.h> -#include <osal_trace.h> - -#include "OMX_ComponentRegistry.h" -#include "OMX_Core_Wrapper.h" - -/** determine capabilities of a component before acually using it */ -extern OMX_BOOL TIOMXConfigParser(OMX_PTR aInputParameters, - OMX_PTR aOutputParameters); - -OMX_ERRORTYPE TIComponentTable_EventHandler(OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_PTR pAppData, - OMX_IN OMX_EVENTTYPE eEvent, - OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData) -{ - (void)hComponent, pAppData, eEvent, nData1, nData2, pEventData; - - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE TIComponentTable_EmptyBufferDone(OMX_OUT OMX_HANDLETYPE - hComponent, OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE * pBuffer) -{ - (void)hComponent, pAppData, pBuffer; - - return OMX_ErrorNotImplemented; -} - -OMX_ERRORTYPE TIComponentTable_FillBufferDone(OMX_OUT OMX_HANDLETYPE - hComponent, OMX_OUT OMX_PTR pAppData, - OMX_OUT OMX_BUFFERHEADERTYPE * pBuffer) -{ - (void)hComponent, pAppData, pBuffer; - - return OMX_ErrorNotImplemented; -} - - -OMX_API OMX_ERRORTYPE TIOMX_Init(void) -{ - OSAL_Entering("TIOMX_Init\n"); - return OMX_Init(); -} - -OMX_API OMX_ERRORTYPE TIOMX_Deinit(void) -{ - OSAL_Entering("TIOMX_Deinit\n"); - return OMX_Deinit(); -} - -OMX_API OMX_ERRORTYPE TIOMX_ComponentNameEnum(OMX_OUT OMX_STRING - cComponentName, OMX_IN OMX_U32 nNameLength, OMX_IN OMX_U32 nIndex) -{ - OSAL_Entering("TIOMX_ComponentNameEnum\n"); - return OMX_ComponentNameEnum(cComponentName, nNameLength, nIndex); -} - -OMX_API OMX_ERRORTYPE TIOMX_GetHandle(OMX_OUT OMX_HANDLETYPE * pHandle, - OMX_IN OMX_STRING cComponentName, - OMX_IN OMX_PTR pAppData, OMX_IN OMX_CALLBACKTYPE * pCallBacks) -{ - OSAL_Entering("TIOMX_GetHandle\n"); - return OMX_GetHandle(pHandle, cComponentName, pAppData, pCallBacks); -} - -OMX_API OMX_ERRORTYPE TIOMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent) -{ - OSAL_Entering("TIOMX_FreeHandle\n"); - return OMX_FreeHandle(hComponent); -} - -OMX_API OMX_ERRORTYPE TIOMX_GetComponentsOfRole(OMX_IN OMX_STRING role, - OMX_INOUT OMX_U32 * pNumComps, OMX_INOUT OMX_U8 ** compNames) -{ - OSAL_Entering("TIOMX_GetComponentsOfRole\n"); - return OMX_GetComponentsOfRole(role, pNumComps, compNames); -} - -OMX_API OMX_ERRORTYPE TIOMX_GetRolesOfComponent(OMX_IN OMX_STRING compName, - OMX_INOUT OMX_U32 * pNumRoles, OMX_OUT OMX_U8 ** roles) -{ - OSAL_Entering("TIOMX_GetRolesOfComponent\n"); - return OMX_GetRolesOfComponent(compName, pNumRoles, roles); -} - -OMX_API OMX_ERRORTYPE TIOMX_SetupTunnel(OMX_IN OMX_HANDLETYPE hOutput, - OMX_IN OMX_U32 nPortOutput, - OMX_IN OMX_HANDLETYPE hInput, OMX_IN OMX_U32 nPortInput) -{ - OSAL_Entering("TIOMX_SetupTunnel\n"); - return OMX_SetupTunnel(hOutput, nPortOutput, hInput, nPortInput); -} - -OMX_API OMX_ERRORTYPE TIOMX_GetContentPipe(OMX_OUT OMX_HANDLETYPE * hPipe, - OMX_IN OMX_STRING szURI) -{ - (void)hPipe, szURI; - - OSAL_Entering("TIOMX_GetContentPipe\n"); - return 0; -} - diff --git a/omx/libstagefrighthw/Android.mk b/omx/libstagefrighthw/Android.mk deleted file mode 100644 index 9a7b176..0000000 --- a/omx/libstagefrighthw/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES := \ - TIOMXPlugin.cpp - -LOCAL_C_INCLUDES:= \ - $(TOP)/frameworks/native/include/media/openmax \ - $(TOP)/frameworks/native/include/media/hardware - -LOCAL_HEADER_LIBRARIES += media_plugin_headers - -LOCAL_SHARED_LIBRARIES := \ - libbinder \ - libutils \ - libcutils \ - liblog \ - libui \ - libdl \ - -LOCAL_MODULE := libstagefrighthw -LOCAL_VENDOR_MODULE := true - -include $(BUILD_SHARED_LIBRARY) - diff --git a/omx/libstagefrighthw/TIOMXPlugin.cpp b/omx/libstagefrighthw/TIOMXPlugin.cpp deleted file mode 100644 index 26a94db..0000000 --- a/omx/libstagefrighthw/TIOMXPlugin.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * 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. - */ - -#include "TIOMXPlugin.h" - -#include <dlfcn.h> - -#include <HardwareAPI.h> - -namespace android { - -extern "C" OMXPluginBase *createOMXPlugin() { - return new TIOMXPlugin; -} - -extern "C" void destroyOMXPlugin(OMXPluginBase *plugin) { - delete plugin; -} - -#define LIBOMX "libOMX_Core.so" - -TIOMXPlugin::TIOMXPlugin() - : mLibHandle(dlopen(LIBOMX, RTLD_NOW)), - mInit(NULL), - mDeinit(NULL), - mComponentNameEnum(NULL), - mGetHandle(NULL), - mFreeHandle(NULL), - mGetRolesOfComponentHandle(NULL) { - if (mLibHandle != NULL) { - mInit = (InitFunc)dlsym(mLibHandle, "TIOMX_Init"); - mDeinit = (DeinitFunc)dlsym(mLibHandle, "TIOMX_Deinit"); - - mComponentNameEnum = - (ComponentNameEnumFunc)dlsym(mLibHandle, "TIOMX_ComponentNameEnum"); - - mGetHandle = (GetHandleFunc)dlsym(mLibHandle, "TIOMX_GetHandle"); - mFreeHandle = (FreeHandleFunc)dlsym(mLibHandle, "TIOMX_FreeHandle"); - - mGetRolesOfComponentHandle = - (GetRolesOfComponentFunc)dlsym( - mLibHandle, "TIOMX_GetRolesOfComponent"); - - (*mInit)(); - } - else { - char const *err_str = dlerror(); - ALOGE("%s: failed to load %s, with error[%s]", __func__, LIBOMX, err_str?err_str:"unknown"); - } -} - -TIOMXPlugin::~TIOMXPlugin() { - if (mLibHandle != NULL) { - (*mDeinit)(); - - dlclose(mLibHandle); - mLibHandle = NULL; - } -} - -OMX_ERRORTYPE TIOMXPlugin::makeComponentInstance( - const char *name, - const OMX_CALLBACKTYPE *callbacks, - OMX_PTR appData, - OMX_COMPONENTTYPE **component) { - if (mLibHandle == NULL) { - return OMX_ErrorUndefined; - } - - return (*mGetHandle)( - reinterpret_cast<OMX_HANDLETYPE *>(component), - const_cast<char *>(name), - appData, const_cast<OMX_CALLBACKTYPE *>(callbacks)); -} - -OMX_ERRORTYPE TIOMXPlugin::destroyComponentInstance( - OMX_COMPONENTTYPE *component) { - if (mLibHandle == NULL) { - return OMX_ErrorUndefined; - } - - return (*mFreeHandle)(reinterpret_cast<OMX_HANDLETYPE *>(component)); -} - -OMX_ERRORTYPE TIOMXPlugin::enumerateComponents( - OMX_STRING name, - size_t size, - OMX_U32 index) { - if (mLibHandle == NULL) { - ALOGE("mLibHandle is NULL!"); - return OMX_ErrorUndefined; - } - - return (*mComponentNameEnum)(name, size, index); -} - -OMX_ERRORTYPE TIOMXPlugin::getRolesOfComponent( - const char *name, - Vector<String8> *roles) { - roles->clear(); - - if (mLibHandle == NULL) { - return OMX_ErrorUndefined; - } - - OMX_U32 numRoles; - OMX_ERRORTYPE err = (*mGetRolesOfComponentHandle)( - const_cast<OMX_STRING>(name), &numRoles, NULL); - - if (err != OMX_ErrorNone) { - return err; - } - - if (numRoles > 0) { - OMX_U8 **array = new OMX_U8 *[numRoles]; - for (OMX_U32 i = 0; i < numRoles; ++i) { - array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE]; - } - - err = (*mGetRolesOfComponentHandle)( - const_cast<OMX_STRING>(name), &numRoles, array); - - for (OMX_U32 i = 0; i < numRoles; ++i) { - if (err == OMX_ErrorNone) { - String8 s((const char *)array[i]); - roles->push(s); - } - - delete[] array[i]; - array[i] = NULL; - } - - delete[] array; - array = NULL; - } - - return err; -} - -} // namespace android diff --git a/omx/libstagefrighthw/TIOMXPlugin.h b/omx/libstagefrighthw/TIOMXPlugin.h deleted file mode 100644 index 7b2e982..0000000 --- a/omx/libstagefrighthw/TIOMXPlugin.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * 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. - */ - -#ifndef TI_OMX_PLUGIN_H_ - -#define TI_OMX_PLUGIN_H_ - -#include <OMXPluginBase.h> - -namespace android { - -struct TIOMXPlugin : public OMXPluginBase { - TIOMXPlugin(); - virtual ~TIOMXPlugin(); - - virtual OMX_ERRORTYPE makeComponentInstance( - const char *name, - const OMX_CALLBACKTYPE *callbacks, - OMX_PTR appData, - OMX_COMPONENTTYPE **component); - - virtual OMX_ERRORTYPE destroyComponentInstance( - OMX_COMPONENTTYPE *component); - - virtual OMX_ERRORTYPE enumerateComponents( - OMX_STRING name, - size_t size, - OMX_U32 index); - - virtual OMX_ERRORTYPE getRolesOfComponent( - const char *name, - Vector<String8> *roles); - -private: - void *mLibHandle; - - typedef OMX_ERRORTYPE (*InitFunc)(); - typedef OMX_ERRORTYPE (*DeinitFunc)(); - typedef OMX_ERRORTYPE (*ComponentNameEnumFunc)( - OMX_STRING, OMX_U32, OMX_U32); - - typedef OMX_ERRORTYPE (*GetHandleFunc)( - OMX_HANDLETYPE *, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE *); - - typedef OMX_ERRORTYPE (*FreeHandleFunc)(OMX_HANDLETYPE *); - - typedef OMX_ERRORTYPE (*GetRolesOfComponentFunc)( - OMX_STRING, OMX_U32 *, OMX_U8 **); - - InitFunc mInit; - DeinitFunc mDeinit; - ComponentNameEnumFunc mComponentNameEnum; - GetHandleFunc mGetHandle; - FreeHandleFunc mFreeHandle; - GetRolesOfComponentFunc mGetRolesOfComponentHandle; - - TIOMXPlugin(const TIOMXPlugin &); - TIOMXPlugin &operator=(const TIOMXPlugin &); -}; - -} // namespace android - -#endif // TI_OMX_PLUGIN_H_ diff --git a/omx/osal/Android.mk b/omx/osal/Android.mk deleted file mode 100644 index 200873c..0000000 --- a/omx/osal/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - src/osal_events.c \ - src/osal_memory.c \ - src/osal_mutex.c \ - src/osal_pipes.c \ - src/osal_semaphores.c \ - src/osal_task.c \ - -LOCAL_C_INCLUDES += \ - $(LOCAL_PATH)/inc - -LOCAL_SHARED_LIBRARIES := \ - libc \ - libutils \ - liblog \ - -LOCAL_MODULE:= libosal -LOCAL_MODULE_TAGS:= optional -LOCAL_VENDOR_MODULE := true - -include $(BUILD_SHARED_LIBRARY) diff --git a/omx/osal/inc/osal_error.h b/omx/osal/inc/osal_error.h deleted file mode 100755 index 1d25b04..0000000 --- a/omx/osal/inc/osal_error.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OSAL_ERROR_H_ -#define _OSAL_ERROR_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define OSAL_TRUE 1 -#define OSAL_FALSE 0 - -#define SUCCESS 0 -#define NO_SUCCESS -1 - -#define OSAL_SUSPEND 0xFFFFFFFFUL -#define OSAL_NO_SUSPEND 0x0 -#define OSAL_TIMED_OUT 0x7FFFFFFFUL - -typedef enum osal_error { - OSAL_ErrNone = 0, -/* General module error list */ - OSAL_ErrNoPermissions = -1, - OSAL_ErrNotSupported = -2, - OSAL_ErrAlloc = -3, - OSAL_ErrOutOfResource = -4, - OSAL_ErrTimeOut = -5, - OSAL_ErrParameter = -6, -/* Pipe Module error list */ - OSAL_ErrNotReady = -11, - OSAL_ErrPipeFull = -12, - OSAL_ErrPipeEmpty = -13, - OSAL_ErrPipeDeleted = -14, - OSAL_ErrPipeReset = -15, - OSAL_ErrPipeClose = -16, - OSAL_ErrPipeWrite = -17, - OSAL_ErrPipeRead = -18, -/* Semaphore module error list */ - OSAL_ErrSemCreate = -20, - OSAL_ErrSemDelete = -21, - OSAL_ErrSemPost = -22, - OSAL_ErrSemGetValue = -23, -/* message queue module error list */ - OSAL_ErrMsgSzieMismatch = -30, - OSAL_ErrMsgTypeNotFound = -31, - OSAL_ErrUnKnown = -32, -/* Mutex module error list */ - OSAL_ErrMutexCreate = -40, - OSAL_ErrMutexDestroy = -41, - OSAL_ErrMutexLock = -42, - OSAL_ErrMutexUnlock = -43, -/* Events module error list */ - OSAL_ErrEventCreate = -50, - OSAL_ErrEventDestroy = -51, - OSAL_ErrSetEvent = -52, - OSAL_ErrRetrieve = -53, - OSAL_ErrEventSignal = -54, -/* Thread module error list */ - OSAL_ErrThreadCreate = -60, - OSAL_ErrThreadDestroy = -61, -} OSAL_ERROR; - - -#ifdef __cplusplus -} -#endif - -#endif /*_OSAL_ERROR_H_*/ diff --git a/omx/osal/inc/osal_events.h b/omx/osal/inc/osal_events.h deleted file mode 100755 index 6c14595..0000000 --- a/omx/osal/inc/osal_events.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OSAL_EVENTS_H_ -#define _OSAL_EVENTS_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* -* OSAL EVENT Operations list -*/ -typedef enum osal_event_op -{ - OSAL_EVENT_AND, - OSAL_EVENT_AND_CONSUME, - OSAL_EVENT_OR, - OSAL_EVENT_OR_CONSUME -} OSAL_EventOp; - -OSAL_ERROR OSAL_CreateEvent(void **pEvents); - -OSAL_ERROR OSAL_DeleteEvent(void *pEvents); - -OSAL_ERROR OSAL_SetEvent(void *pEvents, uint32_t uEventFlag, OSAL_EventOp eOperation); - -OSAL_ERROR OSAL_RetrieveEvent(void *pEvents, uint32_t uRequestedEvents, OSAL_EventOp eOperation, - uint32_t *pRetrievedEvents, uint32_t uTimeOut); - -#ifdef __cplusplus -} -#endif - -#endif /* _OSAL_EVENTS_H_ */ diff --git a/omx/osal/inc/osal_memory.h b/omx/osal/inc/osal_memory.h deleted file mode 100755 index a278be8..0000000 --- a/omx/osal/inc/osal_memory.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OSAL_MEMORY_H_ -#define _OSAL_MEMORY_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "osal_error.h" - -void *OSAL_Malloc(uint32_t size); - -void OSAL_Free(void *pData); - -OSAL_ERROR OSAL_Memset(void *pBuffer, uint8_t uValue, uint32_t uSize); - -int32_t OSAL_Memcmp(void *pBuffer1, void *pBuffer2, uint32_t uSize); - -OSAL_ERROR OSAL_Memcpy(void *pBufDst, void *pBufSrc, uint32_t uSize); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OSAL_DEFINES_H_ */ diff --git a/omx/osal/inc/osal_mutex.h b/omx/osal/inc/osal_mutex.h deleted file mode 100755 index 5b141a9..0000000 --- a/omx/osal/inc/osal_mutex.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OSAL_MUTEX_H_ -#define _OSAL_MUTEX_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -OSAL_ERROR OSAL_CreateMutex(void **pMutex); -OSAL_ERROR OSAL_DeleteMutex(void *pMutex); -OSAL_ERROR OSAL_ObtainMutex(void *pMutex, uint32_t uTimeOut); -OSAL_ERROR OSAL_ReleaseMutex(void *pMutex); - -#ifdef __cplusplus -} -#endif - -#endif /* _OSAL_MUTEX_H_ */ diff --git a/omx/osal/inc/osal_pipes.h b/omx/osal/inc/osal_pipes.h deleted file mode 100755 index 2a77682..0000000 --- a/omx/osal/inc/osal_pipes.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OSAL_PIPES_H_ -#define _OSAL_PIPES_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -OSAL_ERROR OSAL_CreatePipe(void **pPipe, uint32_t pipeSize, uint32_t messageSize, uint8_t isFixedMessage); - -OSAL_ERROR OSAL_DeletePipe(void *pPipe); - -OSAL_ERROR OSAL_WriteToPipe(void *pPipe, void *pMessage, uint32_t size, int32_t timeout); - -OSAL_ERROR OSAL_WriteToFrontOfPipe(void *pPipe, void *pMessage, uint32_t, int32_t timeout); - -OSAL_ERROR OSAL_ReadFromPipe(void *pPipe, void *pMessage, uint32_t size, uint32_t *actualSize, int32_t timeout); - -OSAL_ERROR OSAL_ClearPipe(void *pPipe); - -OSAL_ERROR OSAL_IsPipeReady(void *pPipe); - -OSAL_ERROR OSAL_GetPipeReadyMessageCount(void *pPipe, uint32_t *count); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OSAL_PIPES_H_ */ diff --git a/omx/osal/inc/osal_semaphores.h b/omx/osal/inc/osal_semaphores.h deleted file mode 100755 index 1c125f5..0000000 --- a/omx/osal/inc/osal_semaphores.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OSAL_SEMAPHORE_H_ -#define _OSAL_SEMAPHORE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -OSAL_ERROR OSAL_CreateSemaphore(void **pSemaphore, uint32_t uInitCount); -OSAL_ERROR OSAL_DeleteSemaphore(void *pSemaphore); -OSAL_ERROR OSAL_ObtainSemaphore(void *pSemaphore, uint32_t uTimeOut); -OSAL_ERROR OSAL_ReleaseSemaphore(void *pSemaphore); -OSAL_ERROR OSAL_ResetSemaphore(void *pSemaphore, uint32_t uInitCount); -OSAL_ERROR OSAL_GetSemaphoreCount(void *pSemaphore, uint32_t *count); - -#ifdef __cplusplus -} -#endif - -#endif /* _OSAL_SEMAPHORE_H_ */ diff --git a/omx/osal/inc/osal_task.h b/omx/osal/inc/osal_task.h deleted file mode 100755 index cba0cd9..0000000 --- a/omx/osal/inc/osal_task.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OSAL_TASK_H_ -#define _OSAL_TASK_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef void *(*OSAL_TaskProc) (void *arg); - -OSAL_ERROR OSAL_CreateTask(void **pTask, OSAL_TaskProc pFunc, uint32_t uArgc, - void *pArgv, uint32_t uStackSize, uint32_t uPriority, int8_t * pName); - -OSAL_ERROR OSAL_DeleteTask(void *pTask); - -OSAL_ERROR OSAL_SleepTask(uint32_t mSec); - -#ifdef __cplusplus -} -#endif - -#endif /* _OSAL_TASK_H_ */ diff --git a/omx/osal/inc/osal_trace.h b/omx/osal/inc/osal_trace.h deleted file mode 100755 index 465fb2b..0000000 --- a/omx/osal/inc/osal_trace.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OSAL_TRACES_H_ -#define _OSAL_TRACES_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include <utils/Log.h> - -#define OSAL_ErrorTrace(fmt,...) ALOGE(fmt,##__VA_ARGS__); -#define OSAL_WarningTrace(fmt,...) ALOGE(fmt,##__VA_ARGS__); -#define OSAL_Info(fmt,...) ALOGD(fmt,##__VA_ARGS__); -#define OSAL_Entering(fmt,...) ALOGD(fmt,##__VA_ARGS__); -#define OSAL_Exiting(fmt,...) ALOGD(fmt,##__VA_ARGS__); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OSAL_TRACES_H_ */ diff --git a/omx/osal/src/osal_events.c b/omx/osal/src/osal_events.c deleted file mode 100755 index c8486fc..0000000 --- a/omx/osal/src/osal_events.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <stdio.h> -#include <pthread.h> /*for POSIX calls */ -#include <sys/time.h> -#include <errno.h> - -#include "osal_trace.h" -#include "osal_error.h" -#include "osal_memory.h" -#include "osal_events.h" - -/* -* Thread event internal structure -*/ -typedef struct -{ - uint8_t bSignaled; - uint32_t eFlags; - pthread_mutex_t mutex; - pthread_cond_t condition; -} OSAL_ThreadEvent; - -/* Event Create Method */ -OSAL_ERROR OSAL_CreateEvent(void **pEvents) -{ - OSAL_ERROR bRet = OSAL_ErrUnKnown; - OSAL_ThreadEvent *plEvent = (OSAL_ThreadEvent *) OSAL_Malloc(sizeof(OSAL_ThreadEvent)); - if (NULL == plEvent) { - bRet = OSAL_ErrAlloc; - goto EXIT; - } - plEvent->bSignaled = OSAL_FALSE; - plEvent->eFlags = 0; - - if (SUCCESS != pthread_mutex_init(&(plEvent->mutex), NULL)) { - OSAL_ErrorTrace("Event Create:Mutex Init failed !"); - bRet = OSAL_ErrMutexCreate; - goto EXIT; - } - - if (SUCCESS != pthread_cond_init(&(plEvent->condition), NULL)) { - OSAL_ErrorTrace("Event Create:Conditional Variable Init failed !"); - pthread_mutex_destroy(&(plEvent->mutex)); - bRet = OSAL_ErrEventCreate; - } else { - *pEvents = (void *) plEvent; - bRet = OSAL_ErrNone; - } -EXIT: - if ((OSAL_ErrNone != bRet) && (NULL != plEvent)) { - OSAL_Free(plEvent); - } - return bRet; -} - -/* -* Method to delete the event -*/ -OSAL_ERROR OSAL_DeleteEvent(void *pEvents) -{ - OSAL_ERROR bRet = OSAL_ErrNone; - OSAL_ThreadEvent *plEvent = (OSAL_ThreadEvent*) pEvents; - if (NULL == plEvent) { - bRet = OSAL_ErrParameter; - goto EXIT; - } - - if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) { - OSAL_ErrorTrace("Event Delete: Mutex Lock failed !"); - bRet = OSAL_ErrMutexLock; - } - if (SUCCESS != pthread_cond_destroy(&(plEvent->condition))) { - OSAL_ErrorTrace("Event Delete: Conditional Variable Destroy failed !"); - bRet = OSAL_ErrEventDestroy; - } - if (SUCCESS != pthread_mutex_unlock(&(plEvent->mutex))) { - OSAL_ErrorTrace("Event Delete: Mutex Unlock failed !"); - bRet = OSAL_ErrMutexUnlock; - } - if (SUCCESS != pthread_mutex_destroy(&(plEvent->mutex))) { - OSAL_ErrorTrace("Event Delete: Mutex Destory failed !"); - bRet = OSAL_ErrMutexDestroy; - } - OSAL_Free(plEvent); -EXIT: - return bRet; -} - -/* -* Method to set event operation -*/ -OSAL_ERROR OSAL_SetEvent(void *pEvents, uint32_t uEventFlags, OSAL_EventOp eOperation) -{ - OSAL_ThreadEvent *plEvent = (OSAL_ThreadEvent*) pEvents; - if (NULL == plEvent) { - return OSAL_ErrParameter; - } - if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) { - OSAL_ErrorTrace("Event Set: Mutex Lock failed !"); - return OSAL_ErrMutexLock; - } - - switch (eOperation) { - case OSAL_EVENT_AND: - plEvent->eFlags = plEvent->eFlags & uEventFlags; - break; - case OSAL_EVENT_OR: - plEvent->eFlags = plEvent->eFlags | uEventFlags; - break; - default: - OSAL_ErrorTrace("Event Set: Bad eOperation !"); - pthread_mutex_unlock(&plEvent->mutex); - return OSAL_ErrMutexUnlock; - }; - - plEvent->bSignaled = OSAL_TRUE; - if (SUCCESS != pthread_cond_signal(&plEvent->condition)) { - OSAL_ErrorTrace("Event Set: Condition Variable Signal failed !"); - pthread_mutex_unlock(&plEvent->mutex); - return OSAL_ErrEventSignal; - } - - if (SUCCESS != pthread_mutex_unlock(&plEvent->mutex)) { - OSAL_ErrorTrace("Event Set: Mutex Unlock failed !"); - return OSAL_ErrMutexUnlock; - } - return OSAL_ErrNone; -} - -/* -* @fn OSAL_RetrieveEvent -* Spurious wakeups from the pthread_cond_timedwait() or pthread_cond_wait() functions may occur. -* A representative sequence for using condition variables is shown below -* -* Thread A (Retrieve Events) |Thread B (Set Events) -*------------------------------------------------------------------------------------------------------------ -*1) Do work up to the point where a certain condition must occur |1)Do work -* (such as "count" value) -2) Lock associated mutex and check value of a global variable |2)Lock associated mutex -*3) Call pthread_cond_wait() to perform a blocking wait |3)Change the value of the global variable -* for signal from Thread-B. Note that a call to that Thread-A is waiting upon. -* pthread_cond_wait() automatically and atomically -* unlocks the associated mutex variable so that it can -* be used by Thread-B. -*4) When signalled, wake up. Mutex is automatically and |4)Check value of the global Thread-A wait -* atomically locked. variable. If it fulfills the desired -* condition, signal Thread-A. -*5) Explicitly unlock mutex |5) Unlock Mutex. -*6) Continue |6) Continue -*/ - -OSAL_ERROR OSAL_RetrieveEvent(void *pEvents, uint32_t uRequestedEvents, - OSAL_EventOp eOperation, uint32_t *pRetrievedEvents, uint32_t uTimeOutMsec) -{ - OSAL_ERROR bRet = OSAL_ErrUnKnown; - struct timespec timeout; - struct timeval now; - uint32_t timeout_us; - uint32_t isolatedFlags; - int status = -1; - int and_operation; - OSAL_ThreadEvent *plEvent = (OSAL_ThreadEvent *) pEvents; - if (NULL == plEvent) { - return OSAL_ErrParameter; - } - - /* Lock the mutex for access to the eFlags global variable */ - if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) { - OSAL_ErrorTrace("Event Retrieve: Mutex Lock failed !"); - bRet = OSAL_ErrMutexLock; - goto EXIT; - } - - /*Check the eOperation and put it in a variable */ - and_operation = (OSAL_EVENT_AND == eOperation || OSAL_EVENT_AND_CONSUME == eOperation); - /* Isolate the flags. The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation */ - isolatedFlags = plEvent->eFlags & uRequestedEvents; - /*Check if it is the AND operation. If yes then, all the flags must match */ - if (and_operation) { - isolatedFlags = (isolatedFlags == uRequestedEvents); - } - if (isolatedFlags) { - /*We have got required combination of the eFlags bits and will return it back */ - *pRetrievedEvents = plEvent->eFlags; - bRet = OSAL_ErrNone; - } else { - /*Required combination of bits is not yet available */ - if (OSAL_NO_SUSPEND == uTimeOutMsec) { - *pRetrievedEvents = 0; - bRet = OSAL_ErrNone; - } else if (OSAL_SUSPEND == uTimeOutMsec) { - /*Wait till we get the required combination of bits. We we get the required - *bits then we go out of the while loop - */ - while (!isolatedFlags) { - /*Wait on the conditional variable for another thread to set the eFlags and signal */ - pthread_cond_wait(&(plEvent->condition), &(plEvent->mutex)); - /* eFlags set by some thread. Now, isolate the flags. - * The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation - */ - isolatedFlags = plEvent->eFlags & uRequestedEvents; - /*Check if it is the AND operation. If yes then, all the flags must match */ - if (and_operation) { - isolatedFlags = (isolatedFlags == uRequestedEvents); - } - } - - /* Obtained the requested combination of bits on eFlags */ - *pRetrievedEvents = plEvent->eFlags; - bRet = OSAL_ErrNone; - } else { - /* Calculate uTimeOutMsec in terms of the absolute time. uTimeOutMsec is in milliseconds */ - gettimeofday(&now, NULL); - timeout_us = now.tv_usec + 1000 * uTimeOutMsec; - timeout.tv_sec = now.tv_sec + timeout_us / 1000000; - timeout.tv_nsec = (timeout_us % 1000000) * 1000; - - while (!isolatedFlags) { - /* Wait till uTimeOutMsec for a thread to signal on the conditional variable */ - status = pthread_cond_timedwait(&(plEvent->condition), &(plEvent->mutex), &timeout); - /*Timedout or error and returned without being signalled */ - if (SUCCESS != status) { - if (ETIMEDOUT == status) - bRet = OSAL_ErrTimeOut; - *pRetrievedEvents = 0; - break; - } - - /* eFlags set by some thread. Now, isolate the flags. - * The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation - */ - isolatedFlags = plEvent->eFlags & uRequestedEvents; - - /*Check if it is the AND operation. If yes then, all the flags must match */ - if (and_operation) { - isolatedFlags = (isolatedFlags == uRequestedEvents); - } - } - } - } - - /*If we have got the required combination of bits, we will have to reset the eFlags if CONSUME is mentioned - *in the eOperations - */ - if (isolatedFlags && ((eOperation == OSAL_EVENT_AND_CONSUME) || - (eOperation == OSAL_EVENT_OR_CONSUME))) { - plEvent->eFlags = 0; - bRet = OSAL_ErrNone; - } - - /*unlock the mutex */ - if (SUCCESS != pthread_mutex_unlock(&(plEvent->mutex))) { - OSAL_ErrorTrace("Event Retrieve: Mutex Unlock failed !"); - bRet = OSAL_ErrNone; - } - -EXIT: - return bRet; -} - diff --git a/omx/osal/src/osal_memory.c b/omx/osal/src/osal_memory.c deleted file mode 100755 index 01d945b..0000000 --- a/omx/osal/src/osal_memory.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <string.h> -#include <malloc.h> -#include <stdint.h> - -#include "osal_trace.h" -#include "osal_error.h" -#include "osal_memory.h" - -void* OSAL_Malloc(size_t size) -{ - void* pData = NULL; - pData = malloc((size_t) size); - return pData; -} - -void OSAL_Free(void *pData) -{ - if (NULL == pData) { - OSAL_WarningTrace("TIMM_OSAL_Free called on NULL pointer"); - return; - } - - free(pData); - pData = NULL; -} - - -OSAL_ERROR OSAL_Memset(void *pBuffer, uint8_t uValue, uint32_t uSize) -{ - if (NULL == pBuffer || uSize == 0) { - OSAL_WarningTrace("OSAL_Memset is called on NULL pointer"); - return OSAL_ErrParameter; - } - - memset((void *)pBuffer, (int)uValue, (size_t) uSize); - return OSAL_ErrNone; -} - - - -int32_t OSAL_Memcmp(void *pBuffer1, void *pBuffer2, uint32_t uSize) -{ - if (NULL == pBuffer1 || NULL == pBuffer2) { - OSAL_WarningTrace("OSAL_MemCmp called with null buffers"); - return OSAL_ErrParameter; - } - - int32_t result = memcmp(pBuffer1, pBuffer2, uSize); - return (result == 0) ? result : ((result > 0) ? 1 : -1); -} - - -OSAL_ERROR OSAL_Memcpy(void *pBufDst, void *pBufSrc, uint32_t uSize) -{ - if (NULL == pBufDst || NULL == pBufSrc) { - OSAL_WarningTrace("OSAL_Memcpy called with null buffers"); - return OSAL_ErrParameter; - } - memcpy(pBufDst, pBufSrc, uSize); - return OSAL_ErrNone; -} - - diff --git a/omx/osal/src/osal_mutex.c b/omx/osal/src/osal_mutex.c deleted file mode 100755 index e4aae80..0000000 --- a/omx/osal/src/osal_mutex.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <errno.h> -#include <pthread.h> -#include <sys/time.h> - -#include "osal_trace.h" -#include "osal_error.h" -#include "osal_memory.h" -#include "osal_semaphores.h" - -OSAL_ERROR OSAL_CreateMutex(void **pMutex) -{ - pthread_mutex_t *plMutex = (pthread_mutex_t *)OSAL_Malloc(sizeof(pthread_mutex_t)); - if (NULL == plMutex) { - return OSAL_ErrAlloc; - } - - if (SUCCESS != pthread_mutex_init(plMutex, NULL)) { - OSAL_Free(plMutex); - return OSAL_ErrMutexCreate; - } - - *pMutex = (void*) plMutex; - return OSAL_ErrNone; -} - -OSAL_ERROR OSAL_DeleteMutex(void *pMutex) -{ - pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; - if (NULL == plMutex) { - return OSAL_ErrParameter; - } - - /*can we do away with if or with switch case */ - if (SUCCESS != pthread_mutex_destroy(plMutex)) { - OSAL_ErrorTrace("Delete Mutex failed !"); - return OSAL_ErrMutexDestroy; - } - - OSAL_Free(plMutex); - return OSAL_ErrNone; -} - - -OSAL_ERROR OSAL_ObtainMutex(void *pMutex, uint32_t uTimeOut) -{ - struct timespec abs_timeout; - struct timeval ltime_now; - uint32_t ltimenow_us; - pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; - if (plMutex == NULL) { - return OSAL_ErrParameter; - } - - if (OSAL_SUSPEND == uTimeOut) { - if (SUCCESS != pthread_mutex_lock(plMutex)) { - OSAL_ErrorTrace("Lock Mutex failed !"); - return OSAL_ErrMutexLock; - } - } else if (OSAL_NO_SUSPEND == uTimeOut) { - if (SUCCESS != pthread_mutex_trylock(plMutex)) { - OSAL_ErrorTrace("Lock Mutex failed !"); - return OSAL_ErrMutexLock; - } - } else { - gettimeofday(<ime_now, NULL); - /*uTimeOut is assumed to be in milliseconds */ - ltimenow_us = ltime_now.tv_usec + 1000 * uTimeOut; - abs_timeout.tv_sec = ltime_now.tv_sec + uTimeOut / 1000; - abs_timeout.tv_nsec = (ltimenow_us % 1000000) * 1000; - if (SUCCESS != pthread_mutex_lock(plMutex)) { - OSAL_ErrorTrace("Lock Mutex failed !"); - return OSAL_ErrMutexLock; - } - } - return OSAL_ErrNone; -} - - -OSAL_ERROR OSAL_ReleaseMutex(void *pMutex) -{ - pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; - if (NULL == plMutex) { - return OSAL_ErrParameter; - } - - if (SUCCESS != pthread_mutex_unlock(plMutex)) { - OSAL_ErrorTrace("Unlock Mutex failed !"); - return OSAL_ErrMutexUnlock; - } - return OSAL_ErrNone; -} diff --git a/omx/osal/src/osal_pipes.c b/omx/osal/src/osal_pipes.c deleted file mode 100755 index 52128d4..0000000 --- a/omx/osal/src/osal_pipes.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <unistd.h> -#include <stdio.h> -#include <unistd.h> -#include <errno.h> - -#include "osal_error.h" -#include "osal_memory.h" -#include "osal_trace.h" - -/** -* structure definition for the OSAL pipe -*/ -typedef struct timm_osal_pipe -{ - int pfd[2]; - uint32_t pipeSize; - uint32_t messageSize; - uint8_t isFixedMessage; - int messageCount; - int totalBytesInPipe; - pthread_mutex_t mutex; -} OSAL_Pipe; - -typedef enum -{ - PIPE_RESET, - PIPE_INCREMENT, - PIPE_DECREMENT, -}PIPE_UPDATE; - -static inline int UpdatePipe(void *pPipe, uint32_t msgCnt, uint32_t size, PIPE_UPDATE updateMode) -{ - OSAL_Pipe *pHandle = (OSAL_Pipe*)pPipe; - - switch(updateMode) { - case PIPE_RESET: - pHandle->messageCount = msgCnt; - pHandle->totalBytesInPipe = size; - break; - - case PIPE_INCREMENT: - pHandle->messageCount += msgCnt; - pHandle->totalBytesInPipe += size; - break; - - case PIPE_DECREMENT: - pHandle->messageCount -= msgCnt; - pHandle->totalBytesInPipe -= size; - break; - - default: - OSAL_ErrorTrace("InValid Pipe update Mode"); - } - - return OSAL_ErrNone; -} - -OSAL_ERROR OSAL_CreatePipe(void **pPipe, uint32_t pipeSize, - uint32_t messageSize, uint8_t isFixedMessage) -{ - OSAL_Pipe *pHandle = (OSAL_Pipe*)OSAL_Malloc(sizeof(OSAL_Pipe)); - if (NULL == pHandle) { - return OSAL_ErrAlloc; - } - - OSAL_Memset(pHandle, 0x0, sizeof(OSAL_Pipe)); - pHandle->pfd[0] = -1; - pHandle->pfd[1] = -1; - if (SUCCESS != pipe(pHandle->pfd)) { - OSAL_ErrorTrace("Pipe failed: %s!!!", strerror(errno)); - OSAL_Free(pHandle); - return OSAL_ErrAlloc; - } - - if (SUCCESS != pthread_mutex_init(&(pHandle->mutex), NULL)) { - OSAL_ErrorTrace("Pipe Create:Mutex Init failed !"); - OSAL_Free(pHandle); - return OSAL_ErrMutexCreate; - } - pHandle->pipeSize = pipeSize; - pHandle->messageSize = messageSize; - pHandle->isFixedMessage = isFixedMessage; - pHandle->messageCount = 0; - pHandle->totalBytesInPipe = 0; - - *pPipe = (void*)pHandle; - return OSAL_ErrNone; -} - -OSAL_ERROR OSAL_DeletePipe(void *pPipe) -{ - OSAL_Pipe *pHandle = (OSAL_Pipe*) pPipe; - if (NULL == pHandle) { - return OSAL_ErrParameter; - } - - if (SUCCESS != close(pHandle->pfd[0])) { - OSAL_ErrorTrace("Delete_Pipe Read fd failed!!!"); - return OSAL_ErrPipeClose; - } - if (SUCCESS != close(pHandle->pfd[1])) { - OSAL_ErrorTrace("Delete_Pipe Write fd failed!!!"); - return OSAL_ErrPipeClose; - } - - if (SUCCESS != pthread_mutex_destroy(&(pHandle->mutex))) { - OSAL_ErrorTrace("Pipe Delete: Mutex Destory failed !"); - return OSAL_ErrMutexDestroy; - } - - OSAL_Free(pHandle); - return OSAL_ErrNone; -} - - -OSAL_ERROR OSAL_WriteToPipe(void *pPipe, void *pMessage, uint32_t size, int32_t timeout) -{ - uint32_t lSizeWritten = -1; - OSAL_ERROR ret = OSAL_ErrNone; - OSAL_Pipe *pHandle = (OSAL_Pipe*)pPipe; - (void)timeout; - - if (NULL == pHandle || size == 0) { - OSAL_ErrorTrace("0 size!!!"); - return OSAL_ErrParameter; - } - - - if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { - OSAL_ErrorTrace("update Pipe: Mutex Lock failed !"); - return OSAL_ErrMutexLock; - } - - /*Update message count and size */ - ret = UpdatePipe(pHandle, 1, size, PIPE_INCREMENT); - if (ret) { - goto EXIT; - } - - lSizeWritten = write(pHandle->pfd[1], pMessage, size); - if (lSizeWritten != size) { - OSAL_ErrorTrace("Write of pipe failed!!!"); - /*Update message count and size */ - UpdatePipe(pHandle, 1, size, PIPE_DECREMENT); - ret = OSAL_ErrPipeWrite; - } - -EXIT: - - if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { - OSAL_ErrorTrace("update Pipe: Mutex Unlock failed !"); - ret = OSAL_ErrMutexUnlock; - } - - return ret; -} - - -OSAL_ERROR OSAL_WriteToFrontOfPipe(void *pPipe, void *pMessage, uint32_t size, int32_t timeout) -{ - uint32_t lSizeWritten = -1; - uint32_t lSizeRead = -1; - OSAL_ERROR ret = OSAL_ErrNone; - OSAL_Pipe *pHandle = (OSAL_Pipe*) pPipe; - uint8_t *tempPtr = NULL; - (void)timeout; - - /*First write to this pipe */ - if (NULL == pHandle || size == 0) { - return OSAL_ErrParameter; - - } - - if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { - OSAL_ErrorTrace("update Pipe: Mutex Lock failed !"); - return OSAL_ErrMutexLock; - } - - /*Update message count and size */ - ret = UpdatePipe(pHandle, 1, size, PIPE_INCREMENT); - if (ret) { - goto EXIT; - } - - - lSizeWritten = write(pHandle->pfd[1], pMessage, size); - if (lSizeWritten != size) { - /*Update message count and size */ - UpdatePipe(pHandle, 1, size, PIPE_DECREMENT); - ret = OSAL_ErrPipeWrite; - goto EXIT; - } - - if (pHandle->messageCount > 1) { - /*First allocate memory */ - tempPtr = (uint8_t*)OSAL_Malloc(pHandle->totalBytesInPipe-size); - if (NULL == tempPtr) { - ret = OSAL_ErrAlloc; - goto EXIT; - } - - /*Read out of pipe */ - lSizeRead = read(pHandle->pfd[0], tempPtr, pHandle->totalBytesInPipe-size); - - /*Write back to pipe */ - lSizeWritten = write(pHandle->pfd[1], tempPtr, lSizeRead); - if (lSizeWritten != lSizeRead) { - /*Update message count and size */ - UpdatePipe(pHandle, 1, size, PIPE_RESET); - ret = OSAL_ErrPipeWrite; - } - OSAL_Free(tempPtr); - } - -EXIT: - if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { - OSAL_ErrorTrace("update Pipe: Mutex Unlock failed !"); - ret = OSAL_ErrMutexUnlock; - } - - return ret; -} - - -OSAL_ERROR OSAL_ReadFromPipe(void *pPipe, void *pMessage, uint32_t size, - uint32_t *actualSize, int32_t timeout) -{ - uint32_t lSizeRead = -1; - OSAL_ERROR ret = OSAL_ErrNone; - OSAL_Pipe *pHandle = (OSAL_Pipe*) pPipe; - - if (NULL == pHandle || size == 0) { - OSAL_ErrorTrace("nRead size has error!!!"); - return OSAL_ErrParameter; - } - - if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { - OSAL_ErrorTrace("update Pipe: Mutex Lock failed !"); - return OSAL_ErrMutexLock; - } - - if (pHandle->messageCount == 0 && timeout == OSAL_NO_SUSPEND) { - /*If timeout is 0 and pipe is empty, return error */ - OSAL_ErrorTrace("Pipe is empty!!!"); - ret = OSAL_ErrPipeEmpty; - goto EXIT; - } - - if (timeout != OSAL_NO_SUSPEND && timeout != (int32_t)OSAL_SUSPEND) { - OSAL_WarningTrace("Only infinite or no timeouts \ - supported. Going to read with infinite timeout now"); - } - - /*read blocks infinitely until message is available */ - *actualSize = lSizeRead = read(pHandle->pfd[0], pMessage, size); - if (0 == lSizeRead) { - OSAL_ErrorTrace("EOF reached or no data in pipe!!!"); - ret = OSAL_ErrPipeRead; - goto EXIT; - } - - ret = UpdatePipe(pHandle, 1, lSizeRead, PIPE_DECREMENT); - -EXIT: - - if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { - OSAL_ErrorTrace("update Pipe: Mutex Unlock failed !"); - ret = OSAL_ErrMutexUnlock; - } - - return ret; - -} - - -OSAL_ERROR OSAL_ClearPipe(void *pPipe) -{ - (void)pPipe; - OSAL_WarningTrace("This function is currently not implemented"); - return OSAL_ErrNone; -} - -OSAL_ERROR OSAL_IsPipeReady(void *pPipe) -{ - OSAL_Pipe *pHandle = (OSAL_Pipe *) pPipe; - int isReady; - - if (NULL == pHandle) { - return OSAL_ErrParameter; - } - - if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { - OSAL_ErrorTrace("IsPipeReady: Mutex Lock failed !"); - return OSAL_ErrMutexLock; - } - - isReady = (pHandle->messageCount <= 0) ? OSAL_ErrNotReady : OSAL_ErrNone; - - if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { - OSAL_ErrorTrace("IsPipeReady: Mutex Unlock failed !"); - return OSAL_ErrMutexUnlock; - } - return isReady; -} - -OSAL_ERROR OSAL_GetPipeReadyMessageCount(void *pPipe, uint32_t *count) -{ - OSAL_Pipe *pHandle = (OSAL_Pipe*) pPipe; - if (NULL == pHandle) { - *count = 0; - return OSAL_ErrParameter; - } - - if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { - OSAL_ErrorTrace("GetPipeReadyMessageCount: Mutex Lock failed !"); - return OSAL_ErrMutexLock; - } - - - *count = pHandle->messageCount; - - if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { - OSAL_ErrorTrace("GetPipeReadyMessageCount: Mutex Unlock failed !"); - return OSAL_ErrMutexUnlock; - } - - return OSAL_ErrNone; -} diff --git a/omx/osal/src/osal_semaphores.c b/omx/osal/src/osal_semaphores.c deleted file mode 100755 index a33246d..0000000 --- a/omx/osal/src/osal_semaphores.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <stdio.h> - -#include <semaphore.h> -#include <sys/time.h> - -#include "osal_trace.h" -#include "osal_error.h" -#include "osal_memory.h" - -OSAL_ERROR OSAL_CreateSemaphore(void **pSemaphore, uint32_t uInitCount) -{ - OSAL_ERROR bRet = OSAL_ErrUnKnown; - *pSemaphore = NULL; - sem_t *psem = (sem_t *)OSAL_Malloc(sizeof(sem_t)); - if (NULL == psem) { - bRet = OSAL_ErrAlloc; - goto EXIT; - } - - /*Unnamed semaphore */ - if (SUCCESS != sem_init(psem, 0, uInitCount)) { - OSAL_ErrorTrace("Semaphore Create failed !"); - bRet = OSAL_ErrSemCreate; - goto EXIT; - } - *pSemaphore = (void *) psem; - bRet = OSAL_ErrNone; - -EXIT: - if (OSAL_ErrNone != bRet && NULL != psem) { - OSAL_Free(psem); - } - return bRet; -} - -OSAL_ERROR OSAL_DeleteSemaphore(void *pSemaphore) -{ - sem_t *psem = (sem_t *)pSemaphore; - if (NULL == psem) { - return OSAL_ErrParameter; - } - /* Release the semaphore. */ - if (SUCCESS != sem_destroy(psem)) { - OSAL_ErrorTrace("Semaphore Delete failed !"); - return OSAL_ErrSemDelete; - } - - OSAL_Free(psem); - return OSAL_ErrNone; -} - -OSAL_ERROR OSAL_ObtainSemaphore(void *pSemaphore, uint32_t uTimeOut) -{ - struct timeval ltime_now; - struct timespec abs_timeout; - sem_t *psem = (sem_t *) pSemaphore; - if (psem == NULL) { - return OSAL_ErrParameter; - } - - if (OSAL_SUSPEND == uTimeOut) { - if (SUCCESS != sem_wait(psem)) { - OSAL_ErrorTrace("Semaphore Wait failed !"); - return OSAL_ErrTimeOut; - } - } else if (OSAL_NO_SUSPEND == uTimeOut) { - if (SUCCESS != sem_trywait(psem)) { - OSAL_ErrorTrace("Semaphore blocked !"); - return OSAL_ErrTimeOut; - } - } else { - /* Some delay in calling gettimeofday and sem_timedwait - cant - * be avoided. Possibility of thread switch after gettimeofday - * in which case time out will be less than expected */ - gettimeofday(<ime_now, NULL); - /*uTimeOut is assumed to be in milliseconds */ - abs_timeout.tv_sec = ltime_now.tv_sec + (uTimeOut / 1000); - abs_timeout.tv_nsec = 1000 * (ltime_now.tv_usec + ((uTimeOut % 1000) * 1000)); - if (SUCCESS != sem_timedwait(psem, &abs_timeout)) { - OSAL_ErrorTrace("Semaphore Timed Wait failed !"); - return OSAL_ErrTimeOut; - } - } - return OSAL_ErrNone; -} - -OSAL_ERROR OSAL_ReleaseSemaphore(void *pSemaphore) -{ - sem_t *psem = (sem_t *) pSemaphore; - if (NULL == psem) { - return OSAL_ErrParameter; - } - /* Release the semaphore. */ - if (SUCCESS != sem_post(psem)) { - OSAL_ErrorTrace("Release failed !"); - return OSAL_ErrSemPost; - } - return OSAL_ErrNone; -} - -OSAL_ERROR OSAL_ResetSemaphore(void *pSemaphore, uint32_t uInitCount) -{ - (void)pSemaphore, uInitCount; - return OSAL_ErrNone; -} - -OSAL_ERROR OSAL_GetSemaphoreCount(void *pSemaphore, uint32_t *count) -{ - int sval = -2; /*value that is not possible */ - sem_t *psem = (sem_t *) pSemaphore; - if (NULL == psem) { - return OSAL_ErrParameter; - } - - /* Release the semaphore. */ - if (SUCCESS != sem_getvalue(psem, &sval)) { - OSAL_ErrorTrace("Get Semaphore Count failed !"); - return OSAL_ErrSemGetValue; - } - - *count = sval; - return OSAL_ErrNone; -} diff --git a/omx/osal/src/osal_task.c b/omx/osal/src/osal_task.c deleted file mode 100755 index f5c7e70..0000000 --- a/omx/osal/src/osal_task.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - - -#include <stdio.h> -#include <pthread.h> /*for POSIX calls */ -#include <sched.h> /*for sched structure */ -#include <unistd.h> - -#include "osal_trace.h" -#include "osal_error.h" -#include "osal_memory.h" -#include "osal_task.h" - -/** -* osal_task structure definition -*/ -typedef struct osal_task -{ - pthread_t threadID; /*SHM check */ - pthread_attr_t ThreadAttr; /* To set the priority and stack size */ - /*parameters to the task */ - uint32_t uArgc; - void *pArgv; - uint8_t isCreated; /** flag to check if task got created */ -} OSAL_Task; - -/* -* Task creation -*/ -OSAL_ERROR OSAL_CreateTask(void **pTask, OSAL_TaskProc pFunc, uint32_t uArgc, - void *pArgv, uint32_t uStackSize, uint32_t uPriority, int8_t *pName) -{ - OSAL_ERROR bRet = OSAL_ErrThreadCreate; - OSAL_Task *pHandle = NULL; - struct sched_param sched; - size_t stackSize; - (void)pName; - *pTask = NULL; - - /*Task structure allocation */ - pHandle = (OSAL_Task*)OSAL_Malloc(sizeof(OSAL_Task)); - if (NULL == pHandle) { - bRet = OSAL_ErrAlloc; - goto EXIT; - } - - /* Initial cleaning of the task structure */ - OSAL_Memset((void*)pHandle, 0, sizeof(OSAL_Task)); - - /*Arguments for task */ - pHandle->uArgc = uArgc; - pHandle->pArgv = pArgv; - pHandle->isCreated = OSAL_FALSE; - - if (SUCCESS != pthread_attr_init(&pHandle->ThreadAttr)) { - OSAL_ErrorTrace("Task Init Attr Init failed!"); - goto EXIT; - } - - /* Updation of the priority and the stack size */ - if (SUCCESS != pthread_attr_getschedparam(&pHandle->ThreadAttr, &sched)) { - OSAL_ErrorTrace("Task Init Get Sched Params failed!"); - goto EXIT; - } - - sched.sched_priority = uPriority; /* relative to the default priority */ - if (SUCCESS != pthread_attr_setschedparam(&pHandle->ThreadAttr, &sched)) { - OSAL_ErrorTrace("Task Init Set Sched Paramsfailed!"); - goto EXIT; - } - - /*First get the default stack size */ - if (SUCCESS != pthread_attr_getstacksize(&pHandle->ThreadAttr, &stackSize)) { - OSAL_ErrorTrace("Task Init Set Stack Size failed!"); - goto EXIT; - } - - /*Check if requested stack size is larger than the current default stack size */ - if (uStackSize > stackSize) { - stackSize = uStackSize; - if (SUCCESS != pthread_attr_setstacksize(&pHandle->ThreadAttr, stackSize)) { - OSAL_ErrorTrace("Task Init Set Stack Size failed!"); - goto EXIT; - } - } - - if (SUCCESS != pthread_create(&pHandle->threadID, &pHandle->ThreadAttr, pFunc, pArgv)) { - OSAL_ErrorTrace("Create_Task failed !"); - goto EXIT; - } - - /* Task was successfully created */ - pHandle->isCreated = OSAL_TRUE; - *pTask = (void*) pHandle; - bRet = OSAL_ErrNone; - -EXIT: - if (OSAL_ErrNone != bRet) { - OSAL_Free(pHandle); - } - return bRet; -} - - -OSAL_ERROR OSAL_DeleteTask(void *pTask) -{ - OSAL_Task *pHandle = (OSAL_Task*)pTask; - void *retVal; - - if (NULL == pHandle || OSAL_TRUE != pHandle->isCreated) { - /* this task was never created */ - return OSAL_ErrParameter; - } - if (pthread_attr_destroy(&pHandle->ThreadAttr)) { - OSAL_ErrorTrace("Delete_Task failed !"); - return OSAL_ErrThreadDestroy; - } - if (pthread_join(pHandle->threadID, &retVal)) { - OSAL_ErrorTrace("Delete_Task failed !"); - return OSAL_ErrThreadDestroy; - } - - OSAL_Free(pHandle); - return OSAL_ErrNone; -} - - -OSAL_ERROR OSAL_SleepTask(uint32_t mSec) -{ - usleep(1000 * mSec); - return OSAL_ErrNone; -} diff --git a/omx/videodecode/Android.mk b/omx/videodecode/Android.mk deleted file mode 100644 index 105b5b1..0000000 --- a/omx/videodecode/Android.mk +++ /dev/null @@ -1,52 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -# -# libOMX.TI.DUCATI1.VIDEO.DECODER.so -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - frameworks/native/include/media/openmax \ - $(LOCAL_PATH)/../base/omx_core/inc \ - $(LOCAL_PATH)/../osal/inc \ - $(LOCAL_PATH)/../base/omx_base_comp/inc \ - $(LOCAL_PATH)/../base/omx_base_dio_plugin/inc \ - hardware/libhardware/include \ - hardware/ti/dra7xx/hwcomposer/ \ - hardware/ti/dce/ \ - $(LOCAL_PATH)/omx_videodec_common/inc/ \ - $(LOCAL_PATH)/omx_h264_dec/inc/ \ - $(LOCAL_PATH)/omx_mpeg4_dec/inc/ \ - $(LOCAL_PATH)/omx_mpeg2_dec/inc/ \ - hardware/ti/dce/packages/codec_engine/ \ - hardware/ti/dce/packages/framework_components/ \ - hardware/ti/dce/packages/ivahd_codecs/ \ - hardware/ti/dce/packages/xdais/ \ - hardware/ti/dce/packages/xdctools - -LOCAL_HEADER_LIBRARIES += libutils_headers - -LOCAL_SHARED_LIBRARIES := \ - libosal \ - libc \ - liblog \ - libOMX \ - libhardware \ - libdce - -LOCAL_CFLAGS += -Dxdc_target_types__=google/targets/arm/std.h -DBUILDOS_ANDROID -Dxdc__deprecated_types - -LOCAL_MODULE_TAGS:= optional - -LOCAL_SRC_FILES:= omx_videodec_common/src/omx_video_decoder.c \ - omx_videodec_common/src/omx_video_decoder_componenttable.c \ - omx_videodec_common/src/omx_video_decoder_internal.c \ - omx_h264_dec/src/omx_h264dec.c \ - omx_mpeg4_dec/src/omx_mpeg4dec.c \ - omx_mpeg2_dec/src/omx_mpeg2dec.c - -LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.DECODER -LOCAL_VENDOR_MODULE := true - -include $(BUILD_SHARED_LIBRARY) diff --git a/omx/videodecode/omx_h264_dec/inc/omx_h264vd.h b/omx/videodecode/omx_h264_dec/inc/omx_h264vd.h deleted file mode 100644 index b01a3ed..0000000 --- a/omx/videodecode/omx_h264_dec/inc/omx_h264vd.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_H264VD_H_ -#define _OMX_H264VD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <omx_video_decoder.h> -#include <ti/sdo/codecs/h264vdec/ih264vdec.h> - -/*! Padding for width as per Codec Requirement */ - #define PADX (32) -/*! Padding for height as per Codec requirement */ - #define PADY (24) - -/** Default Frame skip H264 Decoder */ -#define H264VD_DEFAULT_FRAME_SKIP IVIDEO_SKIP_DEFAULT - - -static OMX_ERRORTYPE OMXH264VD_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); - -static OMX_ERRORTYPE OMXH264VD_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); - -void OMXH264VD_Set_StaticParams(OMX_HANDLETYPE hComponent, void *staticparams); - -void OMXH264VD_Set_DynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams); - -void OMXH264VD_Set_Status(OMX_HANDLETYPE hComponent, void *status); - -OMX_ERRORTYPE OMXH264VD_HandleError(OMX_HANDLETYPE hComponent); - -PaddedBuffParams CalculateH264VD_outbuff_details(OMX_HANDLETYPE hComponent, - OMX_U32 width, OMX_U32 height); - -extern OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent); -extern void OMXH264VD_DeInit(OMX_HANDLETYPE hComponent); -extern OMX_U32 OMXH264VD_Calculate_TotalRefFrames(OMX_U32 nWidth, OMX_U32 nHeight, OMX_VIDEO_AVCLEVELTYPE eLevel); - -typedef struct OMXH264VidDecComp { - OMX_VIDEO_PARAM_AVCTYPE tH264VideoParam; -} OMXH264VidDecComp; - - -#ifdef __cplusplus -} -#endif - -#endif /* _OMX_H2644VD_NEW_H_ */ - diff --git a/omx/videodecode/omx_h264_dec/src/omx_h264dec.c b/omx/videodecode/omx_h264_dec/src/omx_h264dec.c deleted file mode 100644 index 18e7889..0000000 --- a/omx/videodecode/omx_h264_dec/src/omx_h264dec.c +++ /dev/null @@ -1,721 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_H264_VIDDEC" - -#include <omx_h264vd.h> -#include <omx_video_decoder_internal.h> - -#define OMX_MAX_DEC_OP_BUFFERS 20 - -OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXH264VidDecComp *pH264VidDecComp = NULL; - IVIDDEC3_Params *pDecParams; - IH264VDEC_Params *params; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - /*! Initialize the function parameters for OMX functions */ - pHandle->SetParameter = OMXH264VD_SetParameter; - pHandle->GetParameter = OMXH264VD_GetParameter; - - /*! Initialize the function pointers */ - pVidDecComp->fpSet_StaticParams = OMXH264VD_Set_StaticParams; - pVidDecComp->fpSet_DynamicParams = OMXH264VD_Set_DynamicParams; - pVidDecComp->fpSet_Status = OMXH264VD_Set_Status; - pVidDecComp->fpCalc_OubuffDetails - = CalculateH264VD_outbuff_details; - pVidDecComp->fpDeinit_Codec = OMXH264VD_DeInit; - pVidDecComp->cDecoderName = "ivahd_h264dec"; - pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingAVC; - pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused; - pVidDecComp->fpHandle_ExtendedError = OMXH264VD_HandleError; - - pVidDecComp->pCodecSpecific = - (OMXH264VidDecComp *) OSAL_Malloc(sizeof (OMXH264VidDecComp)); - OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources); - - pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; - - OMX_BASE_INIT_STRUCT_PTR(&(pH264VidDecComp->tH264VideoParam), OMX_VIDEO_PARAM_AVCTYPE); - pH264VidDecComp->tH264VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT; - pH264VidDecComp->tH264VideoParam.eProfile = OMX_VIDEO_AVCProfileHigh; - pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel41; - pH264VidDecComp->tH264VideoParam.nRefFrames = 0xFFFFFFFF; - - /*! Allocate Memory for Static Parameter */ - pVidDecComp->pDecStaticParams - = (IVIDDEC3_Params *) memplugin_alloc(sizeof(IH264VDEC_Params), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IH264VDEC_Params)); - - params = (IH264VDEC_Params *) (pVidDecComp->pDecStaticParams); - pDecParams = &(params->viddec3Params); - pDecParams->displayDelay = IVIDDEC3_DISPLAY_DELAY_AUTO; - params->presetLevelIdc = IH264VDEC_LEVEL41; - params->dpbSizeInFrames = IH264VDEC_DPB_NUMFRAMES_AUTO; - - /*! Allocate Memory for Dynamic Parameter */ - pVidDecComp->pDecDynParams - = (IVIDDEC3_DynamicParams *) memplugin_alloc(sizeof(IH264VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IH264VDEC_DynamicParams)); - - /*! Allocate Memory for Status Structure */ - pVidDecComp->pDecStatus - = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IH264VDEC_Status), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IH264VDEC_Status)); - ((IH264VDEC_Status *)pVidDecComp->pDecStatus)->spsMaxRefFrames = 1; - - /*! Allocate Memory for Input Arguments */ - pVidDecComp->pDecInArgs - = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IH264VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IH264VDEC_InArgs)); - - /*! Allocate Memory for Output Arguments */ - pVidDecComp->pDecOutArgs - = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IH264VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IH264VDEC_OutArgs)); - - pVidDecComp->pDecInArgs->size = sizeof(IH264VDEC_InArgs); - pVidDecComp->pDecOutArgs->size = sizeof(IH264VDEC_OutArgs); - - pDecParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE; - pDecParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE; - pDecParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE; - - pDecParams->operatingMode = IVIDEO_DECODE_ONLY; - pDecParams->inputDataMode = IVIDEO_ENTIREFRAME; - pDecParams->numInputDataUnits = 0; - -EXIT: - return (eError); -} - - -void OMXH264VD_Set_StaticParams(OMX_HANDLETYPE hComponent, void *staticparams) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - IVIDDEC3_Params *pDecParams; - IH264VDEC_Params *params = (IH264VDEC_Params *)staticparams; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - pDecParams = &(params->viddec3Params); - pDecParams->size = sizeof(IH264VDEC_Params); - pDecParams->maxWidth = 1920; - pDecParams->maxHeight = 1088; - pDecParams->maxFrameRate = 30000; - pDecParams->maxBitRate = 10000000; - pDecParams->dataEndianness = XDM_BYTE; - - /*init outArgs IVIDDEC3_OutArgs*/ - pDecParams->forceChromaFormat = XDM_YUV_420SP; - pDecParams->displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED; - pDecParams->outputDataMode = IVIDEO_ENTIREFRAME; - pDecParams->numOutputDataUnits = 0; - pDecParams->errorInfoMode = IVIDEO_ERRORINFO_OFF; - params->errConcealmentMode = - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment; - - params->temporalDirModePred = IH264VDEC_ENABLE_TEMPORALDIRECT; - params->debugTraceLevel= 0; - params->lastNFramesToLog= 0; - - return; -} - - -void OMXH264VD_Set_DynamicParams(OMX_HANDLETYPE hComponent, void *dynParams) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - IVIDDEC3_DynamicParams *pDecDynParams; - IH264VDEC_DynamicParams *params = (IH264VDEC_DynamicParams *) dynParams; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pDecDynParams = &(params->viddec3DynamicParams); - pDecDynParams->size = sizeof(IVIDDEC3_DynamicParams); - - /* init dynamic params IVIDDEC3_DynamicParams */ - pDecDynParams->decodeHeader = XDM_DECODE_AU; /* Supported */ - - pDecDynParams->displayWidth = 0; /* Not Supported: Set default */ - /*Not Supported: Set default*/ - pDecDynParams->frameSkipMode = H264VD_DEFAULT_FRAME_SKIP; - pDecDynParams->newFrameFlag = XDAS_TRUE; //Not Supported: Set default - - if( ((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) - { - pDecDynParams->putBufferFxn = NULL; - pDecDynParams->putBufferHandle = NULL; - pDecDynParams->putDataFxn = NULL; - pDecDynParams->putDataHandle = NULL; - pDecDynParams->getDataHandle = NULL; - pDecDynParams->getDataFxn = NULL; - } - - return; -} - -/**/ -void OMXH264VD_Set_Status(OMX_HANDLETYPE hComponent, void *decstatus) -{ - IH264VDEC_Status *status; - (void)hComponent; - - status = (IH264VDEC_Status *)decstatus; - status->viddec3Status.size = sizeof(IH264VDEC_Status); - return; -} - -PaddedBuffParams CalculateH264VD_outbuff_details(OMX_HANDLETYPE hComponent, OMX_U32 width, OMX_U32 height) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXH264VidDecComp *pH264VidDecComp = NULL; - OMX_U32 nRefBufferCount=16; - IH264VDEC_Status *pDecStatus = NULL; - IH264VDEC_Params *staticparams; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; - - pDecStatus = (IH264VDEC_Status *)(pVidDecComp->pDecStatus); - - PaddedBuffParams OutBuffDetails; - OutBuffDetails.nBufferSize - = ((((width + (2 * PADX) + 127) & 0xFFFFFF80) * (height + 4 * PADY))); - /* Multiply buffer size by 1.5 to account for both luma and chroma */ - OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1; - OutBuffDetails.nBufferCountMin = OMXH264VD_Calculate_TotalRefFrames(width, height, pH264VidDecComp->tH264VideoParam.eLevel); - staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams); - - /* Assume 0 ref frames initially only if IL client is using port reconfig for allocating padded buffers. - * In that case use the correct ref frames at the time of port reconfig to calculate nBufferCountMin/Actual. - */ - if( pDecStatus->spsMaxRefFrames != 0 || pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { - if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) { - staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER; - } else { - staticparams->viddec3Params.displayDelay = pDecStatus->spsMaxRefFrames; - } - - staticparams->dpbSizeInFrames = pDecStatus->spsMaxRefFrames; - pH264VidDecComp->tH264VideoParam.nRefFrames = pDecStatus->spsMaxRefFrames; - if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) { - /*Base profile*/ - OutBuffDetails.nBufferCountMin = pDecStatus->spsMaxRefFrames + 1; - } else { - /* High Profile */ - OutBuffDetails.nBufferCountMin = 2 * pDecStatus->spsMaxRefFrames + 1; - } - } else if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) { - if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) { - OutBuffDetails.nBufferCountMin = OMXH264VD_Calculate_TotalRefFrames - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - pH264VidDecComp->tH264VideoParam.eLevel); - } else { - nRefBufferCount = OMXH264VD_Calculate_TotalRefFrames - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - pH264VidDecComp->tH264VideoParam.eLevel) - 1; - if((2 * nRefBufferCount + 1) < OMX_MAX_DEC_OP_BUFFERS ) { - OutBuffDetails.nBufferCountMin = 2 * nRefBufferCount + 1; - } else { - OutBuffDetails.nBufferCountMin = OMX_MAX_DEC_OP_BUFFERS; //Cap max buffers to 20 - } - } - } else if( pH264VidDecComp->tH264VideoParam.nRefFrames <= 16 ) { - if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) { - OutBuffDetails.nBufferCountMin = pH264VidDecComp->tH264VideoParam.nRefFrames + 1; - } else { - OutBuffDetails.nBufferCountMin = 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1; - } - } - OutBuffDetails.nBufferCountActual = OutBuffDetails.nBufferCountMin + 2; - OutBuffDetails.n1DBufferAlignment = 16; - OutBuffDetails.nPaddedWidth = (width + (2 * PADX) + 127) & 0xFFFFFF80; - OutBuffDetails.nPaddedHeight = height + 4 * PADY; - OutBuffDetails.n2DBufferYAlignment = 1; - OutBuffDetails.n2DBufferXAlignment = 16; - - return (OutBuffDetails); -} - - -void OMXH264VD_DeInit(OMX_HANDLETYPE hComponent) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - /*! Delete all the memory which was allocated during init of decoder */ - if( pVidDecComp->pDecStaticParams ) { - memplugin_free(pVidDecComp->pDecStaticParams); - pVidDecComp->pDecStaticParams = NULL; - } - if( pVidDecComp->pDecDynParams ) { - memplugin_free(pVidDecComp->pDecDynParams); - pVidDecComp->pDecDynParams = NULL; - } - if( pVidDecComp->pDecStatus ) { - memplugin_free(pVidDecComp->pDecStatus); - pVidDecComp->pDecStatus = NULL; - } - if( pVidDecComp->pDecInArgs ) { - memplugin_free(pVidDecComp->pDecInArgs); - pVidDecComp->pDecInArgs = NULL; - } - if( pVidDecComp->pDecOutArgs ) { - memplugin_free(pVidDecComp->pDecOutArgs); - pVidDecComp->pDecOutArgs = NULL; - } - if( pVidDecComp->pCodecSpecific ) { - OSAL_Free(pVidDecComp->pCodecSpecific); - pVidDecComp->pCodecSpecific = NULL; - } - pHandle->SetParameter = OMXVidDec_SetParameter; - pHandle->GetParameter = OMXVidDec_GetParameter; - pVidDecComp->fpHandle_ExtendedError = NULL; -} - - -OMX_U32 OMXH264VD_Calculate_TotalRefFrames(OMX_U32 nWidth, OMX_U32 nHeight, OMX_VIDEO_AVCLEVELTYPE eLevel) -{ - OMX_U32 ref_frames = 0; - OMX_U32 MaxDpbMbs; - OMX_U32 PicWidthInMbs; - OMX_U32 FrameHeightInMbs; - - switch( eLevel ) { - case OMX_VIDEO_AVCLevel1 : - case OMX_VIDEO_AVCLevel1b : - { - MaxDpbMbs = 396; - break; - } - - case OMX_VIDEO_AVCLevel11 : - { - MaxDpbMbs = 900; - break; - } - - case OMX_VIDEO_AVCLevel12 : - case OMX_VIDEO_AVCLevel13 : - case OMX_VIDEO_AVCLevel2 : - { - MaxDpbMbs = 2376; - break; - } - - case OMX_VIDEO_AVCLevel21 : - { - MaxDpbMbs = 4752; - break; - } - - case OMX_VIDEO_AVCLevel22 : - case OMX_VIDEO_AVCLevel3 : - { - MaxDpbMbs = 8100; - break; - } - - case OMX_VIDEO_AVCLevel31 : - { - MaxDpbMbs = 18000; - break; - } - - case OMX_VIDEO_AVCLevel32 : - { - MaxDpbMbs = 20480; - break; - } - - case OMX_VIDEO_AVCLevel5 : - { - MaxDpbMbs = 110400; //Maximum value for upto level 5 - break; - } - - case OMX_VIDEO_AVCLevel51 : - { - MaxDpbMbs = 184320; //Maximum value for upto level 5.1 - break; - } - - default : - { - MaxDpbMbs = 32768; //Maximum value for upto level 4.1 - } - } - - PicWidthInMbs = nWidth / 16; - FrameHeightInMbs = nHeight / 16; - ref_frames = (OMX_U32)(MaxDpbMbs / (PicWidthInMbs * FrameHeightInMbs)); - - ref_frames = (ref_frames > 16) ? 16 : ref_frames; - - /* Three is added to total reference frames because of the N+3 buffer issue - * It was found that theoretically 2N+1 buffers are required but from a practical - * point of view N+3 was sufficient */ - return (ref_frames + 1); -} - - -OMX_ERRORTYPE OMXH264VD_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXH264VidDecComp *pH264VidDecComp = NULL; - OMX_VIDEO_PARAM_AVCTYPE *pH264VideoParam = NULL; - OMX_U32 nRefBufferCount = 0; - OMX_U8 i; - IH264VDEC_Params *staticparams; - - OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), - OMX_ErrorBadParameter); - - /*! Initialize the pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pH264VidDecComp = (OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; - staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams); - - switch( nIndex ) { - case OMX_IndexParamVideoAvc : - { - pH264VideoParam = (OMX_VIDEO_PARAM_AVCTYPE *) pParamStruct; - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || - (pVidDecComp->sBase.pPorts[pH264VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), - OMX_ErrorIncorrectStateOperation); - - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError); - OMX_CHECK(pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline - || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileMain - || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileExtended - || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileHigh, - OMX_ErrorUnsupportedSetting); - OMX_CHECK(pH264VideoParam->eLevel <= OMX_VIDEO_AVCLevel51, - OMX_ErrorUnsupportedSetting); - if( pH264VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - pH264VidDecComp->tH264VideoParam = *pH264VideoParam; - } else if( pH264VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoAvc supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - goto EXIT; - } else { - eError = OMX_ErrorBadPortIndex; - } - ALOGE("Profile set = %x, Level Set = %x, num ref frames set = %d", - pH264VideoParam->eProfile, pH264VideoParam->eLevel, pH264VideoParam->nRefFrames); - if( pH264VideoParam->eLevel == OMX_VIDEO_AVCLevel5 ) { - staticparams->presetLevelIdc = IH264VDEC_LEVEL5; - } else if( pH264VideoParam->eLevel == OMX_VIDEO_AVCLevel51 ) { - staticparams->presetLevelIdc = IH264VDEC_LEVEL51; - } - if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) { - if( pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline ) { - staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER; - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin = - OMXH264VD_Calculate_TotalRefFrames( - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - pH264VideoParam->eLevel); - } else { - nRefBufferCount = OMXH264VD_Calculate_TotalRefFrames - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - pH264VideoParam->eLevel) - 1; - - if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) { - staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER; - } else { - staticparams->viddec3Params.displayDelay = nRefBufferCount; - } - - if((2 * nRefBufferCount + 1) < OMX_MAX_DEC_OP_BUFFERS ) { - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin - = 2 * nRefBufferCount + 1; - } else { - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin - = OMX_MAX_DEC_OP_BUFFERS; //Cap max buffers to 20 - } - } - } else if( pH264VidDecComp->tH264VideoParam.nRefFrames <= 16 ) { - staticparams->dpbSizeInFrames = pH264VidDecComp->tH264VideoParam.nRefFrames; - if( pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline ) { - staticparams->viddec3Params.displayDelay - = IVIDDEC3_DECODE_ORDER; - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin - = pH264VidDecComp->tH264VideoParam.nRefFrames + 1; - } else { - if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) { - staticparams->viddec3Params.displayDelay - = IVIDDEC3_DECODE_ORDER; - } else { - staticparams->viddec3Params.displayDelay - = pH264VidDecComp->tH264VideoParam.nRefFrames; - } - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin = - 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1; - } - } else { - OSAL_ErrorTrace("Invalid value of nRefFrames = %d of the structure OMX_VIDEO_PARAM_AVCTYPE provided ", - pH264VidDecComp->tH264VideoParam.nRefFrames); - } - } - break; - - case OMX_IndexParamVideoProfileLevelQuerySupported : - { - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, - OMX_ErrorIncorrectStateOperation); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - /*As of now do nothing. This i ndex is required for StdVideoDecoderTest. Later on do code review and fill in proper code here.*/ - eError = OMX_ErrorNoMore; - } - break; - - case OMX_IndexParamVideoProfileLevelCurrent : - { - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, - OMX_ErrorIncorrectStateOperation); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - /*As of now do nothing. This index is required for StdVideoDecoderTest. Later on do code review and fill in proper code here.*/ - eError = OMX_ErrorNoMore; - } - break; - - default : - eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct); - } - -EXIT: - return (eError); -} - - -OMX_ERRORTYPE OMXH264VD_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXH264VidDecComp *pH264VidDecComp = NULL; - OMX_VIDEO_PARAM_AVCTYPE *pH264VideoParam = NULL; - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pH264ProfileLevelParam = NULL; - - - OMX_CHECK((hComponent != NULL) && - (pParamStruct != NULL), OMX_ErrorBadParameter); - - // Initialize the local variables - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - pH264VidDecComp = (OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; - - /* GetParameter can't be invoked incase the comp is in Invalid State */ - OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, - OMX_ErrorIncorrectStateOperation); - - switch( nIndex ) { - case OMX_IndexParamVideoAvc : - { - pH264VideoParam = (OMX_VIDEO_PARAM_AVCTYPE *) pParamStruct; - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError); - if( pH264VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - *pH264VideoParam = pH264VidDecComp->tH264VideoParam; - } else if( pH264VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoAvc supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - } - break; - - case OMX_IndexParamVideoProfileLevelQuerySupported : - { - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - pH264ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct; - if( pH264ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - if( pH264ProfileLevelParam->nProfileIndex == 0 ) { - pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileBaseline; - pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41; - } else if( pH264ProfileLevelParam->nProfileIndex == 1 ) { - pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileMain; - pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41; - } else if( pH264ProfileLevelParam->nProfileIndex == 2 ) { - pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileHigh; - pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41; - } else { - eError = OMX_ErrorNoMore; - } - } else if( pH264ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - } - break; - - case OMX_IndexParamVideoProfileLevelCurrent : - { - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - eError = OMX_ErrorNoMore; - } - break; - - case OMX_IndexParamVideoMacroblocksPerFrame : - { - OMX_U32 MBwidth = 0, MBheight = 0; - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_MACROBLOCKSTYPE, eError); - MBwidth = (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth) / 16; - MBwidth = MBwidth + ((pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth) % 16); - MBheight = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight / 16; - MBheight = MBheight + ((pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight) % 16); - ((OMX_PARAM_MACROBLOCKSTYPE *)(pParamStruct))->nMacroblocks = MBwidth * MBheight; - } - break; - - default : - eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct); - } - -EXIT: - return (eError); -} - -/* */ -OMX_ERRORTYPE OMXH264VD_HandleError(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_U32 nRefFramesOld, nRefFrames41, nRefFrames5; - OMXH264VidDecComp *pH264VidDecComp = NULL; - IH264VDEC_Params *staticparams = NULL; - IH264VDEC_Status *pDecStatus = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMX_U32 nBufferCountMin_old = 0; - - /* Initialize pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams); - pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; - - pDecStatus = (IH264VDEC_Status *)(pVidDecComp->pDecStatus); - if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) { - nRefFramesOld = OMXH264VD_Calculate_TotalRefFrames - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - pH264VidDecComp->tH264VideoParam.eLevel) - 1; - } else { - nRefFramesOld = pH264VidDecComp->tH264VideoParam.nRefFrames; - } - nRefFrames41 = OMXH264VD_Calculate_TotalRefFrames - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - OMX_VIDEO_AVCLevel41) - 1; - nRefFrames5 = OMXH264VD_Calculate_TotalRefFrames - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - OMX_VIDEO_AVCLevel5) - 1; - nBufferCountMin_old = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin; - if( pDecStatus->spsMaxRefFrames > nRefFramesOld ) { - ALOGE("spsMaxRefFrames = %d, nRefFrames set initially = %d", - (OMX_U32)pDecStatus->spsMaxRefFrames, pH264VidDecComp->tH264VideoParam.nRefFrames); - pH264VidDecComp->tH264VideoParam.nRefFrames - = pDecStatus->spsMaxRefFrames; - staticparams->dpbSizeInFrames - = pDecStatus->spsMaxRefFrames; - staticparams->viddec3Params.displayDelay - = pDecStatus->spsMaxRefFrames; - if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) { - staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER; - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin - = pH264VidDecComp->tH264VideoParam.nRefFrames + 1; - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountActual - = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin + 2; - } else { - if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) { - staticparams->viddec3Params.displayDelay - = IVIDDEC3_DECODE_ORDER; - } else { - staticparams->viddec3Params.displayDelay = pDecStatus->spsMaxRefFrames; - } - - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin - = 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1; - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountActual - = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin + 2; - } - if( pDecStatus->spsMaxRefFrames > nRefFrames5 ) { - pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel51; - staticparams->presetLevelIdc = IH264VDEC_LEVEL51; - OSAL_ErrorTrace("Resetting level of the stream to Level 5.1"); - pVidDecComp->nCodecRecreationRequired = 1; - pVidDecComp->nOutPortReconfigRequired = 1; - } else if( pDecStatus->spsMaxRefFrames > nRefFrames41 ) { - pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel5; - staticparams->presetLevelIdc = IH264VDEC_LEVEL5; - OSAL_ErrorTrace("Resetting level of the stream to Level 5"); - pVidDecComp->nCodecRecreationRequired = 1; - pVidDecComp->nOutPortReconfigRequired = 1; - } else if( pDecStatus->spsMaxRefFrames > nRefFramesOld ) { - pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel41; - OSAL_ErrorTrace("Resetting level of the stream to Level 4.1"); - } - if( pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin - > nBufferCountMin_old ) { - OSAL_ErrorTrace("nBufferCountMin_old = %d, nBufferCountMin_new = %d", - nBufferCountMin_old, pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin); - pVidDecComp->nOutPortReconfigRequired = 1; - pVidDecComp->nCodecRecreationRequired = 1; - } - } - - return (eError); -} - diff --git a/omx/videodecode/omx_mpeg2_dec/inc/omx_mpeg2dec.h b/omx/videodecode/omx_mpeg2_dec/inc/omx_mpeg2dec.h deleted file mode 100644 index 4f489f0..0000000 --- a/omx/videodecode/omx_mpeg2_dec/inc/omx_mpeg2dec.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_MPEG2DEC_H_ -#define _OMX_MPEG2DEC_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/****************************************************************** - * INCLUDE FILES - ******************************************************************/ -#include <omx_video_decoder.h> -#include <ti/sdo/codecs/mpeg2vdec/impeg2vdec.h> - - -void OMXMPEG2VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams); - -void OMXMPEG2VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams); - -void OMXMPEG2VD_SetStatus(OMX_HANDLETYPE hComponent, void *status); - -PaddedBuffParams CalculateMPEG2VD_outbuff_details(OMX_HANDLETYPE hComponent, - OMX_U32 width, OMX_U32 height); - -/*---------- function prototypes ------------------- */ -extern OMX_ERRORTYPE OMX_TI_VideoDecoder_ComponentInit(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent); -void OMXMPEG2VD_DeInit(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE OMXMPEG2VD_HandleError(OMX_HANDLETYPE hComponent); - -extern OMX_ERRORTYPE OMXMPEG2VD_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); -extern OMX_ERRORTYPE OMXMPEG2VD_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); - -extern OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); -extern OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); - - -typedef struct OMXMPEG2VidDecComp { - OMX_PARAM_DEBLOCKINGTYPE tDeblockingParam; - OMX_VIDEO_PARAM_MPEG2TYPE tMPEG2VideoParam; -} OMXMPEG2VidDecComp; - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _OMX_MPEG2DEC_H_ */ - diff --git a/omx/videodecode/omx_mpeg2_dec/src/omx_mpeg2dec.c b/omx/videodecode/omx_mpeg2_dec/src/omx_mpeg2dec.c deleted file mode 100644 index c9e8954..0000000 --- a/omx/videodecode/omx_mpeg2_dec/src/omx_mpeg2dec.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_MPEG2_VIDDEC" - -#include <omx_mpeg2dec.h> - - -OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - /*! Initialize the function parameters for OMX functions */ - pHandle->SetParameter = OMXMPEG2VD_SetParameter; - pHandle->GetParameter = OMXMPEG2VD_GetParameter; - - /*! Initialize the function pointers */ - pVidDecComp->fpSet_StaticParams = OMXMPEG2VD_SetStaticParams; - pVidDecComp->fpSet_DynamicParams = OMXMPEG2VD_SetDynamicParams; - pVidDecComp->fpSet_Status = OMXMPEG2VD_SetStatus; - pVidDecComp->fpCalc_OubuffDetails = CalculateMPEG2VD_outbuff_details; - pVidDecComp->fpDeinit_Codec = OMXMPEG2VD_DeInit; - pVidDecComp->cDecoderName = "ivahd_mpeg2vdec"; - - pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingMPEG2; - pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused; - - pVidDecComp->fpHandle_ExtendedError = OMXMPEG2VD_HandleError; - - pVidDecComp->pCodecSpecific = - (OMXMPEG2VidDecComp *) OSAL_Malloc(sizeof (OMXMPEG2VidDecComp)); - OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources); - - pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific; - - OMX_BASE_INIT_STRUCT_PTR(&(pMPEG2VidDecComp->tDeblockingParam), OMX_PARAM_DEBLOCKINGTYPE); - pMPEG2VidDecComp->tDeblockingParam.nPortIndex = OMX_VIDDEC_OUTPUT_PORT; - pMPEG2VidDecComp->tDeblockingParam.bDeblocking = OMX_FALSE; - - - OMX_BASE_INIT_STRUCT_PTR(&(pMPEG2VidDecComp->tMPEG2VideoParam), OMX_VIDEO_PARAM_MPEG2TYPE); - pMPEG2VidDecComp->tMPEG2VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT; - pMPEG2VidDecComp->tMPEG2VideoParam.eProfile = OMX_VIDEO_MPEG2ProfileMain; - pMPEG2VidDecComp->tMPEG2VideoParam.eLevel = OMX_VIDEO_MPEG2LevelML; - - /*! Allocate Memory for Static Parameter */ - pVidDecComp->pDecStaticParams = (IVIDDEC3_Params *)memplugin_alloc(sizeof(IMPEG2VDEC_Params), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IMPEG2VDEC_Params)); - - /*! Allocate Memory for Dynamic Parameter */ - pVidDecComp->pDecDynParams = (IVIDDEC3_DynamicParams *)memplugin_alloc(sizeof(IMPEG2VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IMPEG2VDEC_DynamicParams)); - - /*! Allocate Memory for Status Structure */ - pVidDecComp->pDecStatus = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IMPEG2VDEC_Status), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IMPEG2VDEC_Status)); - - /*! Allocate Memory for Input Arguments */ - pVidDecComp->pDecInArgs = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IMPEG2VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IMPEG2VDEC_InArgs)); - - /*! Allocate Memory for Output Arguments */ - pVidDecComp->pDecOutArgs = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IMPEG2VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IMPEG2VDEC_OutArgs)); - - pVidDecComp->pDecInArgs->size = sizeof(IMPEG2VDEC_InArgs); - pVidDecComp->pDecOutArgs->size = sizeof(IMPEG2VDEC_OutArgs); - - pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE; - pVidDecComp->pDecStaticParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE; - pVidDecComp->pDecStaticParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE; - - pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_DECODE_ONLY; //IVIDEO_TRANSCODE_FRAMELEVEL; // - - pVidDecComp->pDecStaticParams->inputDataMode = IVIDEO_ENTIREFRAME; - pVidDecComp->pDecStaticParams->numInputDataUnits = 0; - - -EXIT: - return (eError); - -} - -void OMXMPEG2VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL; - OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; - IMPEG2VDEC_Params *params; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp - = (OMXVidDecComp *)pHandle->pComponentPrivate; - p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]); - - pMPEG2VidDecComp = - (OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific; - - params = (IMPEG2VDEC_Params *) staticparams; - - params->viddecParams.size = sizeof(IMPEG2VDEC_Params); - - params->viddecParams.maxWidth = p2DOutBufAllocParam->nWidth; - - params->viddecParams.maxFrameRate = 30000; - - params->viddecParams.maxBitRate = 10000000; - - params->viddecParams.dataEndianness = XDM_BYTE; - params->viddecParams.forceChromaFormat = XDM_YUV_420SP; - params->viddecParams.displayDelay = IVIDDEC3_DISPLAY_DELAY_1; - params->viddecParams.inputDataMode = IVIDEO_ENTIREFRAME; - params->viddecParams.numInputDataUnits = 0; - params->viddecParams.numOutputDataUnits = 0; - params->viddecParams.outputDataMode = IVIDEO_ENTIREFRAME; - params->viddecParams.displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED; - - params->viddecParams.errorInfoMode = IVIDEO_ERRORINFO_OFF; - - params->outloopDeBlocking = pMPEG2VidDecComp->tDeblockingParam.bDeblocking; - params->ErrorConcealmentON = pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment; - /* If ErrorConcealmentON, then metadata[0] should be set to IVIDEO_METADATAPLANE_MBINFO */ - if (params->ErrorConcealmentON) { - pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_MBINFO; - pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_TRANSCODE_FRAMELEVEL; - } - - params->debugTraceLevel= 0; - params->lastNFramesToLog= 0; - - return; -} - - -void OMXMPEG2VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynParams) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; - IMPEG2VDEC_DynamicParams *dynamicParams; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp - = (OMXVidDecComp *)pHandle->pComponentPrivate; - p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]); - dynamicParams = (IMPEG2VDEC_DynamicParams *)dynParams; - - /*! Update the Individual fields in the Dyanmic Params of MPEG2 decoder */ - dynamicParams->viddecDynamicParams.size = sizeof(IMPEG2VDEC_DynamicParams); - dynamicParams->viddecDynamicParams.decodeHeader = XDM_DECODE_AU; - dynamicParams->viddecDynamicParams.displayWidth = p2DOutBufAllocParam->nWidth; - dynamicParams->viddecDynamicParams.frameSkipMode = IVIDEO_NO_SKIP; - dynamicParams->viddecDynamicParams.newFrameFlag = XDAS_TRUE; - dynamicParams->viddecDynamicParams.putDataFxn = NULL; - dynamicParams->viddecDynamicParams.putDataHandle = NULL; - dynamicParams->viddecDynamicParams.getDataFxn = NULL; - dynamicParams->viddecDynamicParams.getDataHandle = NULL; - dynamicParams->viddecDynamicParams.putBufferFxn = NULL; - dynamicParams->viddecDynamicParams.putBufferHandle = NULL; - dynamicParams->viddecDynamicParams.lateAcquireArg = IRES_HDVICP2_UNKNOWNLATEACQUIREARG; - return; -} - - -void OMXMPEG2VD_SetStatus(OMX_HANDLETYPE hComponent, void *decstatus) -{ - IMPEG2VDEC_Status *status; - (void)hComponent; - - status = (IMPEG2VDEC_Status *)decstatus; - - status->viddecStatus.size = sizeof(IMPEG2VDEC_Status); - return; -} - - -PaddedBuffParams CalculateMPEG2VD_outbuff_details(OMX_HANDLETYPE hComponent, - OMX_U32 width, OMX_U32 height) -{ - PaddedBuffParams OutBuffDetails; - (void)hComponent; - - /* OutBuffDetails.nBufferSize - = ((((width + PADX + 127) & ~127) * (height + PADY))); */ - /* The 2 additional rows and columns are required as per codec request to boost performance. */ - OutBuffDetails.nBufferSize - = ((((width + 127) & ~127) + 2) * (height + 2)); - /* Multiply buffer size by 1.5 to account for both luma and chroma */ - OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1; - - OutBuffDetails.nBufferCountMin = 4; - OutBuffDetails.nBufferCountActual = 8; - OutBuffDetails.n1DBufferAlignment = 16; - //OutBuffDetails.nPaddedWidth = (width + PADX + 127) & ~127; - //OutBuffDetails.nPaddedHeight = height + PADY; - OutBuffDetails.nPaddedWidth = (width + 127) & ~127; - OutBuffDetails.nPaddedHeight = height; - OutBuffDetails.n2DBufferYAlignment = 1; - OutBuffDetails.n2DBufferXAlignment = 16; - - return (OutBuffDetails); -} - - -void OMXMPEG2VD_DeInit(OMX_HANDLETYPE hComponent) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - /*! Delete all the memory which was allocated during init of decoder */ - if( pVidDecComp->pDecStaticParams ) { - memplugin_free(pVidDecComp->pDecStaticParams); - pVidDecComp->pDecStaticParams = NULL; - } - if( pVidDecComp->pDecDynParams ) { - memplugin_free(pVidDecComp->pDecDynParams); - pVidDecComp->pDecDynParams = NULL; - } - if( pVidDecComp->pDecStatus ) { - memplugin_free(pVidDecComp->pDecStatus); - pVidDecComp->pDecStatus = NULL; - } - if( pVidDecComp->pDecInArgs ) { - memplugin_free(pVidDecComp->pDecInArgs); - pVidDecComp->pDecInArgs = NULL; - } - if( pVidDecComp->pDecOutArgs ) { - memplugin_free(pVidDecComp->pDecOutArgs); - pVidDecComp->pDecOutArgs = NULL; - } - if( pVidDecComp->pCodecSpecific ) { - OSAL_Free(pVidDecComp->pCodecSpecific); - pVidDecComp->pCodecSpecific = NULL; - } - pHandle->SetParameter = OMXVidDec_SetParameter; - pHandle->GetParameter = OMXVidDec_GetParameter; - pVidDecComp->fpHandle_ExtendedError = NULL; -} - -OMX_ERRORTYPE OMXMPEG2VD_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL; - OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL; - OMX_VIDEO_PARAM_MPEG2TYPE *pMPEG2VideoParam = NULL; - - OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), - OMX_ErrorBadParameter); - - /*! Initialize the pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific; - - switch( nIndex ) { - case OMX_IndexParamVideoMpeg2 : - - pMPEG2VideoParam = (OMX_VIDEO_PARAM_MPEG2TYPE *) pParamStruct; - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || - (pVidDecComp->sBase.pPorts[pMPEG2VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), - OMX_ErrorIncorrectStateOperation); - - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG2TYPE, eError); - OMX_CHECK(pMPEG2VideoParam->eProfile == OMX_VIDEO_MPEG2ProfileSimple - || pMPEG2VideoParam->eProfile == OMX_VIDEO_MPEG2ProfileMain, - OMX_ErrorUnsupportedSetting); - if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - pMPEG2VidDecComp->tMPEG2VideoParam = *pMPEG2VideoParam; - } else if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoMpeg2 supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - case OMX_IndexParamCommonDeblocking : - - pDeblockingParam = (OMX_PARAM_DEBLOCKINGTYPE *) pParamStruct; - - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || - (pVidDecComp->sBase.pPorts[pDeblockingParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), - OMX_ErrorIncorrectStateOperation); - - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_DEBLOCKINGTYPE, eError); - if( pDeblockingParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - pMPEG2VidDecComp->tDeblockingParam.bDeblocking = pDeblockingParam->bDeblocking; - } else if( pDeblockingParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - OSAL_ErrorTrace("\n Deblocking supported only on o/p port... \n"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - default : - eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct); - } - -EXIT: - return (eError); -} - -OMX_ERRORTYPE OMXMPEG2VD_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL; - OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL; - OMX_VIDEO_PARAM_MPEG2TYPE *pMPEG2VideoParam = NULL; - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pMPEG2ProfileLevelParam = NULL; - - OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), - OMX_ErrorBadParameter); - - /*! Initialize the pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - /* GetParameter can't be invoked incase the comp is in Invalid State */ - OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, - OMX_ErrorIncorrectStateOperation); - - pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific; - - switch( nIndex ) { - case OMX_IndexParamVideoMpeg2 : - - pMPEG2VideoParam = (OMX_VIDEO_PARAM_MPEG2TYPE *) pParamStruct; - - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG2TYPE, eError); - if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - *pMPEG2VideoParam = pMPEG2VidDecComp->tMPEG2VideoParam; - } else if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoMpeg2 supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - case OMX_IndexParamCommonDeblocking : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_DEBLOCKINGTYPE, eError); - pDeblockingParam = (OMX_PARAM_DEBLOCKINGTYPE *) pParamStruct; - if( pDeblockingParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - pDeblockingParam->bDeblocking = pMPEG2VidDecComp->tDeblockingParam.bDeblocking; - } else if( pDeblockingParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - OSAL_ErrorTrace("\n Deblocking supported only on o/p port... \n"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - case OMX_IndexParamVideoProfileLevelQuerySupported : - { - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - pMPEG2ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct; - if( pMPEG2ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - if( pMPEG2ProfileLevelParam->nProfileIndex == 0 ) { - if( pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2 ) { - pMPEG2ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG2ProfileSimple; - pMPEG2ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG2LevelLL; - } - } else if( pMPEG2ProfileLevelParam->nProfileIndex == 1 ) { - if( pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2 ) { - pMPEG2ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG2ProfileMain; - pMPEG2ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG2LevelML; - } - } else { - eError = OMX_ErrorNoMore; - } - } else if( pMPEG2ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - } - break; - - default : - eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct); - } - -EXIT: - return (eError); -} - - -OMX_ERRORTYPE OMXMPEG2VD_HandleError(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - XDAS_Int32 status = 0; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - /* Initialize pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - /*! Call the Codec Status function to know cause of error */ - status = VIDDEC3_control(pVidDecComp->pDecHandle, - XDM_GETSTATUS, - pVidDecComp->pDecDynParams, - pVidDecComp->pDecStatus); - /* Check whether the Codec Status call was succesful */ - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_GETSTATUS failed"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - - ALOGE("Mpeg2: extendedErrorCode0 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode0); - ALOGE("Mpeg2: extendedErrorCode1 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode1); - ALOGE("Mpeg2: extendedErrorCode2 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode2); - ALOGE("Mpeg2: extendedErrorCode3 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode3); - -EXIT: - return (eError); -} - diff --git a/omx/videodecode/omx_mpeg4_dec/inc/omx_mpeg4vd.h b/omx/videodecode/omx_mpeg4_dec/inc/omx_mpeg4vd.h deleted file mode 100644 index 4aadbfe..0000000 --- a/omx/videodecode/omx_mpeg4_dec/inc/omx_mpeg4vd.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_MPEG4VD_H_ -#define _OMX_MPEG4VD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <omx_video_decoder.h> -#include <ti/sdo/codecs/mpeg4vdec/impeg4vdec.h> - -/*! Padding for width as per Codec Requirement */ -#define PADX (32) -/*! Padding for height as per Codec requirement */ -#define PADY (32) - - -void OMXMPEG4VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams); - -void OMXMPEG4VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams); - -void OMXMPEG4VD_SetStatus(OMX_HANDLETYPE hComponent, void *status); - -PaddedBuffParams CalculateMPEG4VD_outbuff_details(OMX_HANDLETYPE hComponent, - OMX_U32 width, OMX_U32 height); - -OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE OMXMPEG4_H263VD_Init(OMX_HANDLETYPE hComponent); -void OMXMPEG4VD_DeInit(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE OMXMPEG4VD_HandleError(OMX_HANDLETYPE hComponent); - -extern OMX_ERRORTYPE OMXMPEG4VD_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); -extern OMX_ERRORTYPE OMXMPEG4VD_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); - -extern OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); -extern OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); - - -typedef struct OMXMPEG4VidDecComp { - OMX_PARAM_DEBLOCKINGTYPE tDeblockingParam; - OMX_VIDEO_PARAM_MPEG4TYPE tMPEG4VideoParam; - OMX_BOOL bIsSorensonSpark; -} OMXMPEG4VidDecComp; - - -#ifdef __cplusplus -} -#endif - -#endif /* _OMX_MPEG4VD_H_ */ - diff --git a/omx/videodecode/omx_mpeg4_dec/src/omx_mpeg4dec.c b/omx/videodecode/omx_mpeg4_dec/src/omx_mpeg4dec.c deleted file mode 100644 index 6f24f88..0000000 --- a/omx/videodecode/omx_mpeg4_dec/src/omx_mpeg4dec.c +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_MPEG4_VIDDEC" -#include <omx_mpeg4vd.h> - -OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; - - eError = OMXMPEG4_H263VD_Init(hComponent); - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; - pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingMPEG4; - pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused; - pMPEG4VidDecComp->bIsSorensonSpark = OMX_FALSE; - - return (eError); -} - -OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; - - eError = OMXMPEG4_H263VD_Init(hComponent); - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; - - pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingH263; - pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused; - - pMPEG4VidDecComp->bIsSorensonSpark = OMX_FALSE; - - return (eError); -} - -OMX_ERRORTYPE OMXMPEG4_H263VD_Init(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - /*! Initialize the function pointers */ - pVidDecComp->fpSet_StaticParams = OMXMPEG4VD_SetStaticParams; - pVidDecComp->fpSet_DynamicParams = OMXMPEG4VD_SetDynamicParams; - pVidDecComp->fpSet_Status = OMXMPEG4VD_SetStatus; - pVidDecComp->fpCalc_OubuffDetails = CalculateMPEG4VD_outbuff_details; - pVidDecComp->fpDeinit_Codec = OMXMPEG4VD_DeInit; - pVidDecComp->cDecoderName = "ivahd_mpeg4dec"; - pHandle->SetParameter = OMXMPEG4VD_SetParameter; - pHandle->GetParameter = OMXMPEG4VD_GetParameter; - pVidDecComp->fpHandle_ExtendedError = OMXMPEG4VD_HandleError; - - /*! Initialize the framerate divisor to 10000 as WA because MPEG4 codec is providing framerate by multiplying with 10000 instead of 1000*/ - pVidDecComp->nFrameRateDivisor = 10000; - - pVidDecComp->pCodecSpecific = (OMXMPEG4VidDecComp *) OSAL_Malloc(sizeof (OMXMPEG4VidDecComp)); - OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources); - - pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; - - OMX_BASE_INIT_STRUCT_PTR(&(pMPEG4VidDecComp->tDeblockingParam), OMX_PARAM_DEBLOCKINGTYPE); - pMPEG4VidDecComp->tDeblockingParam.nPortIndex = OMX_VIDDEC_OUTPUT_PORT; - pMPEG4VidDecComp->tDeblockingParam.bDeblocking = OMX_TRUE; - - OMX_BASE_INIT_STRUCT_PTR(&(pMPEG4VidDecComp->tMPEG4VideoParam), OMX_VIDEO_PARAM_MPEG4TYPE); - pMPEG4VidDecComp->tMPEG4VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT; - pMPEG4VidDecComp->tMPEG4VideoParam.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedSimple; - pMPEG4VidDecComp->tMPEG4VideoParam.eLevel = OMX_VIDEO_MPEG4Level5; - - /*! Allocate Memory for Static Parameter */ - pVidDecComp->pDecStaticParams = (IVIDDEC3_Params *) memplugin_alloc(sizeof(IMPEG4VDEC_Params), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IMPEG4VDEC_Params)); - - /*! Allocate Memory for Dynamic Parameter */ - pVidDecComp->pDecDynParams = (IVIDDEC3_DynamicParams *)memplugin_alloc(sizeof(IMPEG4VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IMPEG4VDEC_DynamicParams)); - - /*! Allocate Memory for Status Structure */ - pVidDecComp->pDecStatus = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IMPEG4VDEC_Status), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IMPEG4VDEC_Status)); - - /*! Allocate Memory for Input Arguments */ - pVidDecComp->pDecInArgs = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IMPEG4VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IMPEG4VDEC_InArgs)); - - /*! Allocate Memory for Output Arguments */ - pVidDecComp->pDecOutArgs = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IMPEG4VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IMPEG4VDEC_OutArgs)); - - pVidDecComp->pDecInArgs->size = sizeof(IMPEG4VDEC_InArgs); - pVidDecComp->pDecOutArgs->size = sizeof(IMPEG4VDEC_OutArgs); - - pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE; - pVidDecComp->pDecStaticParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE; - pVidDecComp->pDecStaticParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE; - - pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_DECODE_ONLY; - - pVidDecComp->pDecStaticParams->inputDataMode = IVIDEO_ENTIREFRAME; - pVidDecComp->pDecStaticParams->numInputDataUnits = 0; - -EXIT: - return (eError); -} - -void OMXMPEG4VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; - IMPEG4VDEC_Params *params; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp - = (OMXVidDecComp *)pHandle->pComponentPrivate; - - pMPEG4VidDecComp = - (OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; - - params = (IMPEG4VDEC_Params *) staticparams; - - params->viddec3Params.size = sizeof(IMPEG4VDEC_Params); - params->viddec3Params.maxFrameRate = 300000; - params->viddec3Params.maxBitRate = 10000000; - params->viddec3Params.dataEndianness = XDM_BYTE; - params->viddec3Params.forceChromaFormat = XDM_YUV_420SP; - params->viddec3Params.displayDelay = IVIDDEC3_DISPLAY_DELAY_1; - params->viddec3Params.inputDataMode = IVIDEO_ENTIREFRAME; - params->viddec3Params.numInputDataUnits = 0; - params->viddec3Params.outputDataMode = IVIDEO_ENTIREFRAME; - params->viddec3Params.displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED; - - params->viddec3Params.errorInfoMode = IVIDEO_ERRORINFO_OFF; - params->outloopDeBlocking = IMPEG4VDEC_DEBLOCK_DISABLE; - params->enhancedDeBlockingQp = 31; - params->sorensonSparkStream = pMPEG4VidDecComp->bIsSorensonSpark; - params->errorConcealmentEnable = pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment; - params->debugTraceLevel = 0; - params->lastNFramesToLog = 0; - params->paddingMode = IMPEG4VDEC_MPEG4_MODE_PADDING; - - return; -} - - -void OMXMPEG4VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynParams) -{ - IMPEG4VDEC_DynamicParams *dynamicParams; - (void)hComponent; - - dynamicParams = (IMPEG4VDEC_DynamicParams *)dynParams; - - /*! Update the Individual fields in the Dyanmic Params of MPEG4 decoder */ - dynamicParams->viddec3DynamicParams.size = sizeof(IMPEG4VDEC_DynamicParams); - dynamicParams->viddec3DynamicParams.decodeHeader = XDM_DECODE_AU; - dynamicParams->viddec3DynamicParams.displayWidth = 0; - dynamicParams->viddec3DynamicParams.frameSkipMode = IVIDEO_NO_SKIP; - dynamicParams->viddec3DynamicParams.newFrameFlag = XDAS_TRUE; - dynamicParams->viddec3DynamicParams.putDataFxn = NULL; - dynamicParams->viddec3DynamicParams.putDataHandle = NULL; - dynamicParams->viddec3DynamicParams.getDataFxn = NULL; - dynamicParams->viddec3DynamicParams.getDataHandle = NULL; - dynamicParams->viddec3DynamicParams.putBufferFxn = NULL; - dynamicParams->viddec3DynamicParams.putBufferHandle = NULL; - return; -} - - -void OMXMPEG4VD_SetStatus(OMX_HANDLETYPE hComponent, void *decstatus) -{ - IMPEG4VDEC_Status *status; - (void)hComponent; - - status = (IMPEG4VDEC_Status *)decstatus; - - status->viddec3Status.size = sizeof(IMPEG4VDEC_Status); - return; -} - - -PaddedBuffParams CalculateMPEG4VD_outbuff_details(OMX_HANDLETYPE hComponent, - OMX_U32 width, OMX_U32 height) -{ - PaddedBuffParams OutBuffDetails; - (void)hComponent; - - OutBuffDetails.nBufferSize = ((((width + PADX + 127) & ~127) * (height + PADY))); - /* Multiply buffer size by 1.5 to account for both luma and chroma */ - OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1; - - OutBuffDetails.nBufferCountMin = 4; - OutBuffDetails.nBufferCountActual = 8; - OutBuffDetails.n1DBufferAlignment = 16; - OutBuffDetails.nPaddedWidth = (width + PADX + 127) & ~127; - OutBuffDetails.nPaddedHeight = height + PADY; - OutBuffDetails.n2DBufferYAlignment = 1; - OutBuffDetails.n2DBufferXAlignment = 16; - return (OutBuffDetails); -} - - -void OMXMPEG4VD_DeInit(OMX_HANDLETYPE hComponent) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - /*! Delete all the memory which was allocated during init of decoder */ - if( pVidDecComp->pDecStaticParams ) { - memplugin_free(pVidDecComp->pDecStaticParams); - pVidDecComp->pDecStaticParams = NULL; - } - if( pVidDecComp->pDecDynParams ) { - memplugin_free(pVidDecComp->pDecDynParams); - pVidDecComp->pDecDynParams = NULL; - } - if( pVidDecComp->pDecStatus ) { - memplugin_free(pVidDecComp->pDecStatus); - pVidDecComp->pDecStatus = NULL; - } - if( pVidDecComp->pDecInArgs ) { - memplugin_free(pVidDecComp->pDecInArgs); - pVidDecComp->pDecInArgs = NULL; - } - if( pVidDecComp->pDecOutArgs ) { - memplugin_free(pVidDecComp->pDecOutArgs); - pVidDecComp->pDecOutArgs = NULL; - } - if( pVidDecComp->pCodecSpecific ) { - OSAL_Free(pVidDecComp->pCodecSpecific); - pVidDecComp->pCodecSpecific = NULL; - } - pHandle->SetParameter = OMXVidDec_SetParameter; - pHandle->GetParameter = OMXVidDec_GetParameter; - pVidDecComp->fpHandle_ExtendedError = NULL; - pVidDecComp->nFrameRateDivisor = 1000; -} - -OMX_ERRORTYPE OMXMPEG4VD_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; - OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL; - OMX_VIDEO_PARAM_MPEG4TYPE *pMPEG4VideoParam = NULL; - - OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), - OMX_ErrorBadParameter); - - /*! Initialize the pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; - - switch( nIndex ) { - case OMX_IndexParamVideoMpeg4 : - pMPEG4VideoParam = (OMX_VIDEO_PARAM_MPEG4TYPE *) pParamStruct; - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || - (pVidDecComp->sBase.pPorts[pMPEG4VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), - OMX_ErrorIncorrectStateOperation); - - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG4TYPE, eError); - OMX_CHECK(pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileSimple - || pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileMain - || pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileAdvancedSimple, - OMX_ErrorUnsupportedSetting); - if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - pMPEG4VidDecComp->tMPEG4VideoParam = *pMPEG4VideoParam; - } else if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoMpeg4 supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - default : - eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct); - } - -EXIT: - return (eError); -} - -OMX_ERRORTYPE OMXMPEG4VD_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; - OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL; - OMX_VIDEO_PARAM_MPEG4TYPE *pMPEG4VideoParam = NULL; - OMX_VIDEO_PARAM_PROFILELEVELTYPE *pMPEG4ProfileLevelParam = NULL; - - OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), - OMX_ErrorBadParameter); - - /*! Initialize the pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - /* GetParameter can't be invoked incase the comp is in Invalid State */ - OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, - OMX_ErrorIncorrectStateOperation); - - pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; - - switch( nIndex ) { - case OMX_IndexParamVideoMpeg4 : - pMPEG4VideoParam = (OMX_VIDEO_PARAM_MPEG4TYPE *) pParamStruct; - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG4TYPE, eError); - if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - *pMPEG4VideoParam = pMPEG4VidDecComp->tMPEG4VideoParam; - } else if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoMpeg4 supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - case OMX_IndexParamVideoProfileLevelQuerySupported : - { - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - pMPEG4ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct; - if( pMPEG4ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { - if( pMPEG4ProfileLevelParam->nProfileIndex == 0 ) { - if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 ) { - pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG4ProfileSimple; - pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG4LevelMax; - } else if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingH263 ) { - pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_H263ProfileBaseline; - pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_H263Level70; - } - } else if( pMPEG4ProfileLevelParam->nProfileIndex == 1 ) { - if(pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 ) { - pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG4ProfileAdvancedSimple; - pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG4LevelMax; - } else if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingH263 ) { - pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_H263ProfileISWV2; - pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_H263Level70; - } - } else { - eError = OMX_ErrorNoMore; - } - } else if( pMPEG4ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port"); - eError = OMX_ErrorUnsupportedIndex; - } else { - eError = OMX_ErrorBadPortIndex; - } - } - break; - default : - eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct); - } - -EXIT: - return (eError); -} - - -OMX_ERRORTYPE OMXMPEG4VD_HandleError(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - /* Initialize pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - /* To send the output buffer to display in case of no valid VOL/VOP header */ - - if((!(pVidDecComp->pDecOutArgs->extendedError & 0x8000) - && ((pVidDecComp->pDecOutArgs->extendedError & 0x100000) - || (pVidDecComp->pDecOutArgs->extendedError & 0x80000))) - && (pVidDecComp->pDecInArgs->inputID == pVidDecComp->pDecOutArgs->freeBufID[0] - && pVidDecComp->pDecOutArgs->outputID[0] == 0)) { - pVidDecComp->pDecOutArgs->outputID[0] = pVidDecComp->pDecInArgs->inputID; - pVidDecComp->bSyncFrameReady = OMX_TRUE; - } - - return (eError); -} - diff --git a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder.h b/omx/videodecode/omx_videodec_common/inc/omx_video_decoder.h deleted file mode 100644 index 543cb75..0000000 --- a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder.h +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_VIDEO_DECODER_H_ -#define _OMX_VIDEO_DECODER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <OMX_Types.h> -#include <omx_base.h> -#include <xdc/std.h> -#include <ti/xdais/xdas.h> -#include <ti/sdo/ce/video3/viddec3.h> -#include <omx_base_utils.h> - -#include <hardware/gralloc.h> -#include <hardware/hardware.h> -#include <hal_public.h> - -#define OMX_VIDDEC_NUM_OF_PORTS OMX_BASE_NUM_OF_PORTS -#define OMX_VIDDEC_INPUT_PORT OMX_BASE_INPUT_PORT -#define OMX_VIDDEC_OUTPUT_PORT OMX_BASE_OUTPUT_PORT -#define OMX_VIDDEC_DEFAULT_START_PORT_NUM OMX_BASE_DEFAULT_START_PORT_NUM - - -/*Android Data structures*/ - -enum Type { - MEDIA_IMAGE_TYPE_UNKNOWN = 0, - MEDIA_IMAGE_TYPE_YUV, -}; - -enum PlaneIndex { - Y = 0, - U, - V, - MAX_NUM_PLANES -}; - -typedef struct PlaneInfo { - uint32_t mOffset; // offset of first pixel of the plane in bytes - // from buffer offset - uint32_t mColInc; // column increment in bytes - uint32_t mRowInc; // row increment in bytes - uint32_t mHorizSubsampling; // subsampling compared to the largest plane - uint32_t mVertSubsampling; // subsampling compared to the largest plane -}PlaneInfo; - -// Structure describing a media image (frame) -// Currently only supporting YUV -typedef struct MediaImage { - int mType; - uint32_t mNumPlanes; // number of planes - uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) - uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) - uint32_t mBitDepth; // useable bit depth - PlaneInfo mPlane[MAX_NUM_PLANES]; -}MediaImage; - -// A pointer to this struct is passed to OMX_GetParameter when the extension -// index for the 'OMX.google.android.index.describeColorFormat' -// extension is given. This method can be called from any component state -// other than invalid. The color-format, frame width/height, and stride/ -// slice-height parameters are ones that are associated with a raw video -// port (input or output), but the stride/slice height parameters may be -// incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will -// be used (while specifying this color format). -// -// The component shall fill out the MediaImage structure that -// corresponds to the described raw video format, and the potentially corrected -// stride and slice-height info. -// -// The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE, -// though most implementations can ignore this difference. When using native buffers, -// the component may change the configured color format to an optimized format. -// Additionally, when allocating these buffers for flexible usecase, the framework -// will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers -// is OMX_TRUE), the component shall fill out the MediaImage information for the -// scenario when these SW-readable/writable buffers are locked using gralloc_lock. -// Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must -// be supported for vendor-specific formats. -// -// For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers -// is OMX_TRUE and the component does not support this color format with native -// buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN. -typedef struct DescribeColorFormatParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_U32 nFrameWidth; - OMX_U32 nFrameHeight; - OMX_U32 nStride; - OMX_U32 nSliceHeight; - OMX_BOOL bUsingNativeBuffers; - - // output: fill out the MediaImage fields - MediaImage sMediaImage; -}DescribeColorFormatParams; - -// A pointer to this struct is passed to OMX_SetParameter() when the extension -// index "OMX.google.android.index.prepareForAdaptivePlayback" is given. -// -// This method is used to signal a video decoder, that the user has requested -// seamless resolution change support (if bEnable is set to OMX_TRUE). -// nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest -// anticipated frames in the video. If bEnable is OMX_FALSE, no resolution -// change is expected, and the nMaxFrameWidth/Height fields are unused. -// -// If the decoder supports dynamic output buffers, it may ignore this -// request. Otherwise, it shall request resources in such a way so that it -// avoids full port-reconfiguration (due to output port-definition change) -// during resolution changes. -// -// DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED. INSTEAD, IMPLEMENT -// METADATA SUPPORT FOR VIDEO DECODERS. -typedef struct PrepareForAdaptivePlaybackParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bEnable; - OMX_U32 nMaxFrameWidth; - OMX_U32 nMaxFrameHeight; -}PrepareForAdaptivePlaybackParams; - -/* -* Padded Buffer Parameters -*/ -typedef struct PaddedBuffParams { - OMX_U32 nBufferSize; /*! Buffer size */ - OMX_U32 nPaddedWidth; /*! Padded Width of the buffer */ - OMX_U32 nPaddedHeight; /*! Padded Height */ - OMX_U32 nBufferCountMin; /*! Min number of buffers required */ - OMX_U32 nBufferCountActual; /*! Actual number of buffers */ - OMX_U32 n1DBufferAlignment; /*! 1D Buffer Alignment value */ - OMX_U32 n2DBufferYAlignment; /*! Y axis alignment value in 2Dbuffer */ - OMX_U32 n2DBufferXAlignment; /*! X Axis alignment value in 2Dbuffer */ -} PaddedBuffParams; - -/* -* OMX Video decoder component -*/ -typedef struct OMXVideoDecoderComponent { - OMXBaseComp sBase; - /* codec related fields */ - OMX_STRING cDecoderName; - VIDDEC3_Handle pDecHandle; - Engine_Handle ce; - IVIDDEC3_Params *pDecStaticParams; /*! Pointer to Decoder Static Params */ - IVIDDEC3_DynamicParams *pDecDynParams; /*! Pointer to Decoder Dynamic Params */ - IVIDDEC3_Status *pDecStatus; /*! Pointer to Decoder Status struct */ - IVIDDEC3_InArgs *pDecInArgs; /*! Pointer to Decoder InArgs */ - IVIDDEC3_OutArgs *pDecOutArgs; /*! Pointer to Decoder OutArgs */ - XDM2_BufDesc *tInBufDesc; - XDM2_BufDesc *tOutBufDesc; - - /* OMX params */ - OMX_VIDEO_PARAM_PORTFORMATTYPE tVideoParams[OMX_VIDDEC_NUM_OF_PORTS]; - OMX_CONFIG_RECTTYPE tCropDimension; - OMX_CONFIG_SCALEFACTORTYPE tScaleParams; - OMX_PARAM_COMPONENTROLETYPE tComponentRole; - OMX_CONFIG_RECTTYPE t2DBufferAllocParams[OMX_VIDDEC_NUM_OF_PORTS]; - - /* local params */ - gralloc_module_t const *grallocModule; - OMXBase_CodecConfigBuf sCodecConfig; - OMX_U32 nOutPortReconfigRequired; - OMX_U32 nCodecRecreationRequired; - OMX_U32 bInputBufferCancelled; - - OMX_U32 bIsFlushRequired; - OMX_BOOL bUsePortReconfigForCrop; - OMX_BOOL bUsePortReconfigForPadding; - OMX_BOOL bSupportDecodeOrderTimeStamp; - OMX_BOOL bSupportSkipGreyOutputFrames; - OMX_BOOL bEnableDecodeZeroDisplayDelayMode; - - OMX_U32 nFrameCounter; - OMX_BOOL bSyncFrameReady; - OMX_U32 nOutbufInUseFlag; - OMX_PTR pCodecSpecific; - OMX_U32 nDecoderMode; - OMX_U32 nFatalErrorGiven; - OMX_PTR pTimeStampStoragePipe; - OMX_U32 nFrameRateDivisor; - OMX_BOOL bFirstFrameHandled; - - OMX_BOOL bIPCRecoveryNeeded; - - //Parameters for Adaptive video playback - OMX_BOOL bisAdaptivePlayback; - OMX_U32 nAdaptiveMaxFrameWidth; - OMX_U32 nAdaptiveMaxFrameHeight; - - void (*fpSet_StaticParams)(OMX_HANDLETYPE hComponent, void *params); - void (*fpSet_DynamicParams)(OMX_HANDLETYPE hComponent, void *dynamicparams); - void (*fpSet_Status)(OMX_HANDLETYPE hComponent, void *status); - void (*fpDeinit_Codec)(OMX_HANDLETYPE hComponent); - OMX_ERRORTYPE (*fpHandle_ExtendedError)(OMX_HANDLETYPE hComponent); - OMX_ERRORTYPE (*fpHandle_CodecGetStatus)(OMX_HANDLETYPE hComponent); - PaddedBuffParams (*fpCalc_OubuffDetails)(OMX_HANDLETYPE hComponent, OMX_U32 width, OMX_U32 height); - MemHeader *pmetaBuffer; - -}OMXVidDecComp; - -/* Component Entry Method */ -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE OMXVidDec_ComponentInit(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE OMXVidDec_ComponentDeinit(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); - -OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); - -OMX_ERRORTYPE OMXVidDec_GetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure); - -OMX_ERRORTYPE OMXVidDec_SetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure); - -OMX_ERRORTYPE OMXVidDec_CommandNotify(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, OMX_PTR pCmdData); - -OMX_ERRORTYPE OMXVidDec_DataNotify(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXVidDec_XlateBuffHandle(OMX_HANDLETYPE hComponent, OMX_PTR pBufferHdr, OMX_BOOL bRegister); - -OMX_ERRORTYPE OMXVidDec_GetExtensionIndex(OMX_HANDLETYPE hComponent, OMX_STRING cParameterName, - OMX_INDEXTYPE *pIndexType); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OMX_VIDEO_DECODER_H_ */ - diff --git a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_componenttable.h b/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_componenttable.h deleted file mode 100644 index b3638db..0000000 --- a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_componenttable.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_VIDEO_DECODER_COMPONENTTABLE_H_ -#define _OMX_VIDEO_DECODER_COMPONENTTABLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> -#include <OMX_Video.h> - -typedef struct OMXDecoderComponentList { - /*Component role to be specified here*/ - OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE]; - - /*! Video Coding Type Format */ - OMX_VIDEO_CODINGTYPE eCompressionFormat; - - /*! Function pointer to the component Init function of decoder */ - OMX_ERRORTYPE (*fpDecoderComponentInit)(OMX_HANDLETYPE hComponent); - -} OMXDecoderComponentList; - -/* external definition for the Decoder Component List*/ -extern OMXDecoderComponentList DecoderList[]; - -#ifdef __cplusplus -} -#endif - -#endif /* _OMX_VIDEO_DECODER_COMPONENTTABLE_H_ */ - diff --git a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_internal.h b/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_internal.h deleted file mode 100644 index 12efba5..0000000 --- a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_internal.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_VIDEO_DECODER_INTERNAL_H_ -#define _OMX_VIDEO_DECODER_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <osal_trace.h> -#include <OMX_Core.h> -#include <OMX_Component.h> -#include <omx_base.h> -#include <OMX_Types.h> -#include <omx_base_utils.h> -#include <omx_video_decoder.h> -#include <omx_video_decoder_componenttable.h> - -static OMX_STRING engineName = "ivahd_vidsvr"; - -#define OMX_VIDDEC_COMP_VERSION_MAJOR 1 -#define OMX_VIDDEC_COMP_VERSION_MINOR 1 -#define OMX_VIDDEC_COMP_VERSION_REVISION 0 -#define OMX_VIDDEC_COMP_VERSION_STEP 0 - -#define OMX_VIDEODECODER_DEFAULT_FRAMERATE 30 - -/*! Minimum Input Buffer Count */ -#define OMX_VIDDEC_MIN_IN_BUF_COUNT 1 -/*! Default Input Buffer Count */ -#define OMX_VIDDEC_DEFAULT_IN_BUF_COUNT 2 -/*! Minimum Input Buffer Count in Data Sync mode -* codec releases input buffer of Nth Data Sync call during (N+2)th Data Sync call -* So minimum number of input buffers required is 3 */ -#define OMX_VIDDEC_DATASYNC_MIN_IN_BUF_COUNT 3 -/*! Default Input Buffer Count in Data Sync mode*/ -#define OMX_VIDDEC_DATASYNC_DEFAULT_IN_BUF_COUNT 4 -/*! Default Frame Width */ -#define OMX_VIDDEC_DEFAULT_FRAME_WIDTH 176 -/*! Default Frame Height */ -#define OMX_VIDDEC_DEFAULT_FRAME_HEIGHT 144 -/*! Default 1D-Buffer Alignment */ -#define OMX_VIDDEC_DEFAULT_1D_INPUT_BUFFER_ALIGNMENT 1 -/*! Default Stride value for 2D buffer */ -#define OMX_VIDDEC_DEFAULT_STRIDE OMX_VIDDEC_DEFAULT_FRAME_WIDTH -/*! Max Image Width supported */ -#define OMX_VIDDEC_MAX_WIDTH (2048) -/*! Max Image Height supported */ -#define OMX_VIDDEC_MAX_HEIGHT (2048) -/*! Max Number of MBs supported */ -#define OMX_VIDDEC_MAX_MACROBLOCK (8160) - -#define OMX_VIDEODECODER_COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER" - -/* external definition for the Video Params Init function */ -extern OMX_ERRORTYPE OMXVidDec_InitFields(OMXVidDecComp *pVidDecComp); -extern void OMXVidDec_InitPortDefs(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp); -extern void OMXVidDec_InitPortParams(OMXVidDecComp *pVidDecComp); -extern void OMXVidDec_InitDecoderParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp); - -extern OMX_ERRORTYPE OMXVidDec_HandleFLUSH_EOS(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE *pOutBufHeader, - OMX_BUFFERHEADERTYPE *pInBufHeader); -extern OMX_ERRORTYPE OMXVidDec_SetInPortDef(OMX_HANDLETYPE hComponent, - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs); -extern OMX_ERRORTYPE OMXVidDec_SetOutPortDef(OMXVidDecComp *pVidDecComp, - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs); -extern OMX_ERRORTYPE OMXVidDec_HandleFirstFrame(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * *ppInBufHeader); -extern OMX_ERRORTYPE OMXVidDec_HandleCodecProcError(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * *ppInBufHeader, - OMX_BUFFERHEADERTYPE * *ppOutBufHeader); -extern OMX_ERRORTYPE OMXVidDec_HandleLockedBuffer(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE *pOutBufHeader); - -XDAS_Int32 OMXVidDec_DataSync_GetInputData(XDM_DataSyncHandle dataSyncHandle, XDM_DataSyncDesc *dataSyncDesc); - -XDAS_Int32 OMXVidDec_DataSync_PutBuffer(XDM_DataSyncHandle dataSyncHandle, XDM_DataSyncDesc *dataSyncDesc); - -extern void OMXVidDec_Set2DBuffParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp); -extern OMX_U32 Calc_InbufSize(OMX_U32 width, OMX_U32 height); - -#ifdef __cplusplus -} -#endif - -#endif /* _OMX_VIDEO_DECODER_H_ */ - diff --git a/omx/videodecode/omx_videodec_common/src/omx_video_decoder.c b/omx/videodecode/omx_videodec_common/src/omx_video_decoder.c deleted file mode 100644 index c688277..0000000 --- a/omx/videodecode/omx_videodec_common/src/omx_video_decoder.c +++ /dev/null @@ -1,1726 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_VIDDEC_COMMON" - -#include <omx_video_decoder_internal.h> -#include <OMX_TI_Custom.h> - -#include <osal_trace.h> -#include <memplugin.h> -#include <libdce.h> - - -#define HAL_NV12_PADDED_PIXEL_FORMAT HAL_PIXEL_FORMAT_NV12 - -#define MAX_REF_FRAMES 16 - -/* -* Component Init -*/ -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT; - OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - - /*! Call the Common Decoder Component Init */ - eError = OMXVidDec_ComponentInit(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - - /*! Call the Decoder Specific Init as default */ - eError = DecoderList[DEFAULT_COMPOENENT].fpDecoderComponentInit(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - OMXVidDec_InitPortDefs(hComponent, pVidDecComp); - OMXVidDec_InitPortParams(pVidDecComp); - OMXVidDec_Set2DBuffParams(hComponent, pVidDecComp); - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]); - pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; - - /* Call Decoder Specific function to set Static Params */ - pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams); - - strcpy((char *)pVidDecComp->tComponentRole.cRole, - (char *)DecoderList[DEFAULT_COMPOENENT].cRole); - /* Set the Parse Header flag to XDM_PARSE_HEADER */ - pVidDecComp->nDecoderMode = XDM_PARSE_HEADER; - -EXIT: - return (eError); -} - -/* -* Video Decoder Component Init -*/ -OMX_ERRORTYPE OMXVidDec_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - Engine_Error errorCode; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - - /* allocate the decoder component */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pHandle->pComponentPrivate = (OMXVidDecComp*)OSAL_Malloc(sizeof(OMXVidDecComp)); - OMX_CHECK(pHandle->pComponentPrivate != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pHandle->pComponentPrivate, 0x0, sizeof(OMXVidDecComp)); - - pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate; - - /*! Initialize the fields */ - eError = OMXVidDec_InitFields(pHandle->pComponentPrivate); - OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUndefined); - - strcpy(pVidDecComp->sBase.cComponentName, OMX_VIDEODECODER_COMPONENT_NAME); - - /* Initialize the base component */ - eError = OMXBase_ComponentInit(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - - /*Setting default properties. - * PreCondition: NumOfPorts is filled and all pointers allocated*/ - eError = OMXBase_SetDefaultProperties(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); - - /*! Initialize function pointers for Command and Data Notify */ - pVidDecComp->sBase.fpCommandNotify = OMXVidDec_CommandNotify; - pVidDecComp->sBase.fpDataNotify = OMXVidDec_DataNotify; - pVidDecComp->sBase.fpXlateBuffHandle = OMXVidDec_XlateBuffHandle; - - /*! Initialize the function parameters for OMX functions */ - pHandle->SetParameter = OMXVidDec_SetParameter; - pHandle->GetParameter = OMXVidDec_GetParameter; - pHandle->GetConfig = OMXVidDec_GetConfig; - pHandle->SetConfig = OMXVidDec_SetConfig; - pHandle->ComponentDeInit = OMXVidDec_ComponentDeinit; - pHandle->GetExtensionIndex = OMXVidDec_GetExtensionIndex; - - /*! Open instance of Codec engine */ - pVidDecComp->ce = Engine_open(engineName, NULL, &errorCode); - pVidDecComp->pDecHandle = NULL; - pVidDecComp->nFrameCounter = 0; - pVidDecComp->bSyncFrameReady = OMX_FALSE; - pVidDecComp->nOutbufInUseFlag = 0; - pVidDecComp->nCodecRecreationRequired = 0; - pVidDecComp->nOutPortReconfigRequired = 0; - pVidDecComp->nFatalErrorGiven = 0; - pVidDecComp->bInputBufferCancelled = 0; - pVidDecComp->bIPCRecoveryNeeded = OMX_FALSE; - /*! Initialize the Framerate divisor to 1000 as codec is supposed provide framerate after by multiplying with 1000 */ - pVidDecComp->nFrameRateDivisor = 1000; - pVidDecComp->tCropDimension.nTop = 0; - pVidDecComp->tCropDimension.nLeft = 0; - pVidDecComp->tScaleParams.xWidth = 0x10000; - pVidDecComp->tScaleParams.xHeight = 0x10000; - pVidDecComp->bUsePortReconfigForCrop = OMX_TRUE; - pVidDecComp->bUsePortReconfigForPadding = OMX_TRUE; - pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_FALSE; - pVidDecComp->bSupportSkipGreyOutputFrames = OMX_TRUE; - pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_FALSE; - - /*Optimize this pipe to be created only if decode timestamps is requested. */ - OSAL_CreatePipe(&(pVidDecComp->pTimeStampStoragePipe), MAX_REF_FRAMES * sizeof(OMX_TICKS), - sizeof(OMX_TICKS), 1); - - pVidDecComp->tInBufDesc = (XDM2_BufDesc*)memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->tInBufDesc != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->tInBufDesc, 0x0, sizeof(XDM2_BufDesc)); - - pVidDecComp->tOutBufDesc = (XDM2_BufDesc*)memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pVidDecComp->tOutBufDesc != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pVidDecComp->tOutBufDesc, 0x0, sizeof(XDM2_BufDesc)); - -EXIT: - if( eError != OMX_ErrorNone ) { - if( pHandle != NULL ) { - OMXVidDec_ComponentDeinit(hComponent); - } - } - return (eError); -} - - -/* -* Video decoder setParameter -*/ -OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoParams = NULL; - OMX_CONFIG_RECTTYPE *p2DBufferAllocParams = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE *pInPortFmtType = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE *pOutPortFmtType = NULL; - OMX_CONFIG_RECTTYPE *pOut2DBufAllocParam = NULL; - OMX_CONFIG_RECTTYPE *pIn2DBufAllocParam = NULL; - OMX_U32 i=0; - OMX_U32 bFound = 0; - OMX_U32 nFrameHeight = 0; - OMX_U32 nFrameWidth = 0; - struct PrepareForAdaptivePlaybackParams *pPrepareForAdaptivePlaybackParams; - OMX_U32 framesize = 0; - OMX_U32 metasize = 0; - - OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), OMX_ErrorBadParameter); - - /*! Initialize the pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate; - - switch( (int) nIndex ) { - case OMX_IndexParamPortDefinition : - { - /*! To set the Port Definition */ - OMX_BASE_CHK_VERSION(pParamStruct, - OMX_PARAM_PORTDEFINITIONTYPE, eError); - - pPortDefs = (OMX_PARAM_PORTDEFINITIONTYPE *) pParamStruct; - pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - - //Check if an invalid port index is not sent - OMX_CHECK(pPortDefs->nPortIndex >= pVidDecComp->sBase.nMinStartPortIndex - && pPortDefs->nPortIndex < (pVidDecComp->sBase.nNumPorts + pVidDecComp->sBase.nMinStartPortIndex), - OMX_ErrorBadPortIndex); - - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - // OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || - // (pVidDecComp->sBase.pPorts[pPortDefs->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), - // OMX_ErrorIncorrectStateOperation); - // If Input Port Parameters have to be changed - if( pPortDefs->nPortIndex == pInputPortDef->nPortIndex ) { - /*! Check for correct resolution of the stream */ - nFrameWidth = pPortDefs->format.video.nFrameWidth; - nFrameHeight = pPortDefs->format.video.nFrameHeight; - - OMX_CHECK((nFrameWidth <= OMX_VIDDEC_MAX_WIDTH), - OMX_ErrorUnsupportedSetting); - OMX_CHECK((nFrameHeight <= OMX_VIDDEC_MAX_HEIGHT), - OMX_ErrorUnsupportedSetting); - OMX_CHECK((((nFrameWidth * nFrameHeight) >> 16) <= OMX_VIDDEC_MAX_MACROBLOCK), - OMX_ErrorUnsupportedSetting); - - /*! Call function to set input port definition */ - eError = OMXVidDec_SetInPortDef(hComponent, pPortDefs); - if( eError != OMX_ErrorNone ) { - goto EXIT; - } - if( pVidDecComp->sBase.tCurState != OMX_StateLoaded ) { - pVidDecComp->nCodecRecreationRequired = 1; - } - } - // If Output Port Parameters have to be changed - else if( pPortDefs->nPortIndex == pOutputPortDef->nPortIndex ) { - // Check the buffer cnt is greater than min required - // buffer count - OMX_CHECK((pPortDefs->nBufferCountActual - >= pOutputPortDef->nBufferCountMin), - OMX_ErrorUnsupportedSetting); - // Check if Resolution being set at output port is same - // as the input port - OMX_CHECK((pOutputPortDef->format.video.nFrameHeight - == pPortDefs->format.video.nFrameHeight) - && (pOutputPortDef->format.video.nFrameWidth - == pPortDefs->format.video.nFrameWidth), - OMX_ErrorUnsupportedSetting); - - OMX_CHECK((OMX_U32)pPortDefs->format.video.nStride >= - pOutputPortDef->format.video.nFrameWidth, - OMX_ErrorUnsupportedSetting); - if( (OMX_U32)pPortDefs->format.video.nStride > - pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) { - //Supported values of stride are only multiples of 128 - OMX_CHECK((pPortDefs->format.video.nStride & 0x7F) == 0, - OMX_ErrorUnsupportedSetting); - } - //Check for the supported Color-fromat - //and compression format. - - if (pVidDecComp->sBase.pPorts[pOutputPortDef->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) { - //OMX_CHECK((pOutputPortDef->format.video.eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT), - // OMX_ErrorUnsupportedSetting); - } else { - OMX_CHECK((pOutputPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar), - OMX_ErrorUnsupportedSetting); - } - - OMX_CHECK((pOutputPortDef->format.video.eCompressionFormat == - OMX_VIDEO_CodingUnused), - OMX_ErrorUnsupportedSetting); - - /*! Call function to set output port definition */ - eError = OMXVidDec_SetOutPortDef(pVidDecComp, pPortDefs); - if( eError != OMX_ErrorNone ) { - goto EXIT; - } - } - } - - /* If MPEG2 and Error Concealment; then memplugin_alloc for pOutBufDescPtr->descs[2] one time allocation only.*/ - if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) { - if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment) { - /* It's MPEG2 and ErrorConcealment is ON; calculate metadata buffer size based on formula described in MPEG2 User Guide */ - framesize = (((pInputPortDef->format.video.nFrameWidth + 15) / 16) * 16) * (((pInputPortDef->format.video.nFrameHeight + 15) / 16) * 16); - metasize = ((framesize >> 8) * 112) + framesize; - if (pVidDecComp->pmetaBuffer && pVidDecComp->pmetaBuffer->size < metasize) { - memplugin_free((void*)H2P(pVidDecComp->pmetaBuffer)); - pVidDecComp->pmetaBuffer = NULL; - } - if (pVidDecComp->pmetaBuffer == NULL) { - pVidDecComp->pmetaBuffer = P2H(memplugin_alloc(metasize, 1, MEM_CARVEOUT, 0, 0)); - OMX_CHECK(pVidDecComp->pmetaBuffer != NULL, OMX_ErrorInsufficientResources); - } - } - } - break; - - case OMX_IndexParamVideoPortFormat : - { - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError); - pVideoParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *) pParamStruct; - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || - (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), - OMX_ErrorIncorrectStateOperation); - - pInPortFmtType = &(pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT]); - pOutPortFmtType = &(pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT]); - // If Input Port Format type has to be changed - if( pVideoParams->nPortIndex == pInPortFmtType->nPortIndex ) { - // Change Compression type and frame-rate - pInPortFmtType->eCompressionFormat - = pVideoParams->eCompressionFormat; - pInPortFmtType->xFramerate = pVideoParams->xFramerate; - } - // In case Output Port Format type has to be changed - else if( pVideoParams->nPortIndex == pOutPortFmtType->nPortIndex ) { - //Check for the supported Color-fromat - //and compression format. - if (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) { - // OMX_CHECK((pVideoParams->eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT), - // OMX_ErrorUnsupportedSetting); - } else { - OMX_CHECK((pVideoParams->eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar), - OMX_ErrorUnsupportedSetting); - } - OMX_CHECK((pVideoParams->eCompressionFormat == - OMX_VIDEO_CodingUnused), OMX_ErrorUnsupportedSetting); - - pOutputPortDef->format.video.eColorFormat - = pVideoParams->eColorFormat; - - // Change Compression type, color format and frame-rate - pOutPortFmtType->eCompressionFormat - = pVideoParams->eCompressionFormat; - pOutPortFmtType->eColorFormat = pVideoParams->eColorFormat; - pOutPortFmtType->xFramerate = pVideoParams->xFramerate; - } - } - break; - - case OMX_IndexParamStandardComponentRole : - { - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_COMPONENTROLETYPE, eError); - - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, - OMX_ErrorIncorrectStateOperation); - /*! In case there is change in Role */ - if( strcmp((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole, - (char *)pVidDecComp->tComponentRole.cRole)) { - /* De-initialize the current codec */ - pVidDecComp->fpDeinit_Codec(hComponent); - - /* Call specific component init depending upon the - cRole set. */ - i=0; - while( NULL != DecoderList[i].cRole[0] ) { - if( strcmp((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole, - (char *)DecoderList[i].cRole) == 0 ) { - /* Component found */ - bFound = 1; - break; - } - i++; - } - - if( bFound == 0 ) { - OSAL_ErrorTrace("Unsupported Role set"); - eError = OMX_ErrorUnsupportedSetting; - goto EXIT; - } - /* Call the Specific Decoder Init function and Initialize Params */ - eError = DecoderList[i].fpDecoderComponentInit(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - OMXVidDec_InitDecoderParams(hComponent, pHandle->pComponentPrivate); - - strcpy((char *)pVidDecComp->tComponentRole.cRole, - (char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole); - } - } - break; - - case OMX_TI_IndexParamTimeStampInDecodeOrder : - { - OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER, eError); - - /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ - OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, - OMX_ErrorIncorrectStateOperation); - if(((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled == OMX_TRUE ) { - pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_TRUE; - } else { - pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_FALSE; - } - } - break; - - case (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode : - { - OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE, eError); - - /* This SetParameter can be invoked in Loaded State only as it needs codec recreate.*/ - OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, - OMX_ErrorIncorrectStateOperation); - if(((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled == OMX_TRUE ) { - pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_TRUE; - } else { - pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_FALSE; - } - } - break; - - case (OMX_INDEXTYPE) OMX_TI_IndexPrepareForAdaptivePlayback: - { - OMX_BASE_CHK_VERSION(pParamStruct, PrepareForAdaptivePlaybackParams, eError); - /* This SetParameter can be invoked in Loaded State only as it needs codec recreate.*/ - OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, - OMX_ErrorIncorrectStateOperation); - pPrepareForAdaptivePlaybackParams = (PrepareForAdaptivePlaybackParams *) pParamStruct; - pVidDecComp->bisAdaptivePlayback = pPrepareForAdaptivePlaybackParams->bEnable; - pVidDecComp->nAdaptiveMaxFrameWidth = pPrepareForAdaptivePlaybackParams->nMaxFrameWidth; - pVidDecComp->nAdaptiveMaxFrameHeight = pPrepareForAdaptivePlaybackParams->nMaxFrameHeight; - } - break; - - - default : - eError = OMXBase_SetParameter(hComponent, nIndex, pParamStruct); - } - -EXIT: - return (eError); -} - -/* -* Video Decoder Get Parameter -*/ -OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoParams = NULL; - OMX_CONFIG_RECTTYPE *p2DBufferAllocParams = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE inPortParam; - OMX_VIDEO_PARAM_PORTFORMATTYPE outPortParam; - OMX_TI_PARAMNATIVEBUFFERUSAGE *pUsage = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; - OMX_U32 nStartPortNumber, nPorts, nPortIndex; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - struct DescribeColorFormatParams *Colorparams; - - OMX_CHECK((hComponent != NULL) && - (pParamStruct != NULL), OMX_ErrorBadParameter); - - // Initialize the local variables - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate; - - /* GetParameter can't be invoked incase the comp is in Invalid State */ - OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, - OMX_ErrorIncorrectStateOperation); - - switch( (int) nIndex ) { - case OMX_IndexParamPortDefinition: - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, - eError); - pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - - nPorts = pVidDecComp->sBase.nNumPorts; - nStartPortNumber = pVidDecComp->sBase.nMinStartPortIndex; - - nPortIndex = pPortDef->nPortIndex - nStartPortNumber; - /* check for valid port index */ - OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex); - *pPortDef = pVidDecComp->sBase.pPorts[nPortIndex]->sPortDef; - if (pPortDef->eDir == OMX_DirOutput && - pVidDecComp->sBase.pPorts[nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) { - pPortDef->format.video.eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT; - } - break; - - case OMX_IndexParamVideoPortFormat : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError); - // Initialize Port Params - pVideoParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *) pParamStruct; - inPortParam = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT]; - outPortParam = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT]; - if( pVideoParams->nPortIndex == inPortParam.nPortIndex ) { - if( pVideoParams->nIndex > inPortParam.nIndex ) { - return (OMX_ErrorNoMore); - } - pVideoParams->eCompressionFormat = inPortParam.eCompressionFormat; - pVideoParams->eColorFormat = inPortParam.eColorFormat; - pVideoParams->xFramerate = inPortParam.xFramerate; - if(pVideoParams->eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) - pVideoParams->eColorFormat = OMX_COLOR_FormatYUV420Flexible; // OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - } else if( pVideoParams->nPortIndex == outPortParam.nPortIndex ) { - if( pVideoParams->nIndex == 0 ) { - if (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) { - pVideoParams->eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT; - } else { - pVideoParams->eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - } - } else if( pVideoParams->nIndex > outPortParam.nIndex ) { - return (OMX_ErrorNoMore); - } - pVideoParams->eCompressionFormat = outPortParam.eCompressionFormat; - pVideoParams->xFramerate = outPortParam.xFramerate; - } - break; - - case OMX_IndexParamStandardComponentRole : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_COMPONENTROLETYPE, eError); - strcpy((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole, - (char *)pVidDecComp->tComponentRole.cRole); - break; - - case (OMX_INDEXTYPE) OMX_TI_IndexAndroidNativeBufferUsage: - pUsage = (OMX_TI_PARAMNATIVEBUFFERUSAGE*)pParamStruct; - pUsage->nUsage = GRALLOC_USAGE_HW_RENDER; - break; - - case (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat: - Colorparams = (struct DescribeColorFormatParams*)(pParamStruct); - - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - - struct MediaImage *image = &(Colorparams->sMediaImage); - memset(image, 0, sizeof(MediaImage)); - - image->mWidth = pOutputPortDef->format.video.nFrameWidth; - image->mHeight = pOutputPortDef->format.video.nFrameHeight; - - image->mType = MEDIA_IMAGE_TYPE_YUV; - image->mNumPlanes = 3; - image->mBitDepth = 8; - /* The crop left and top calculation is not needed here. - Stagefright will add pBuffer->nOffset to this Y offset. */ - image->mPlane[Y].mOffset = 0; - image->mPlane[Y].mColInc = 1; - image->mPlane[Y].mRowInc = pOutputPortDef->format.video.nStride; - image->mPlane[Y].mHorizSubsampling = 1; - image->mPlane[Y].mVertSubsampling = 1; - - /* Since the position of the Buffer is at the starting of Y buffer (UV offset from base - Y offset), - UV offset = (Stride*Height + (Top/2)*Stride + Left )- (Top*Stride + Left) - on simplification - UV offset = Stride*Height - (Top/2)*Stride */ - image->mPlane[U].mOffset = pOutputPortDef->format.video.nStride * pOutputPortDef->format.video.nFrameHeight; - image->mPlane[U].mColInc = 2; - image->mPlane[U].mRowInc = pOutputPortDef->format.video.nStride; - image->mPlane[U].mHorizSubsampling = 2; - image->mPlane[U].mVertSubsampling = 2; - - image->mPlane[V].mOffset = image->mPlane[U].mOffset + 1; - image->mPlane[V].mColInc = 2; - image->mPlane[V].mRowInc = pOutputPortDef->format.video.nStride; - image->mPlane[V].mHorizSubsampling = 2; - image->mPlane[V].mVertSubsampling = 2; - - break; - - case (OMX_INDEXTYPE) OMX_TI_IndexParamTimeStampInDecodeOrder : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER, eError); - if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { - ((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled = OMX_TRUE; - } else { - ((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled = OMX_FALSE; - } - break; - - case (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE, eError); - if( pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE ) { - ((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled = OMX_TRUE; - } else { - ((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled = OMX_FALSE; - } - break; - - default : - eError = OMXBase_GetParameter(hComponent, nIndex, pParamStruct); - } - -EXIT: - return (eError); -} - -/* -* Video decoder GetConfig -*/ -OMX_ERRORTYPE OMXVidDec_GetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure) { - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMX_CONFIG_RECTTYPE *pCropParams = NULL; - OMX_CONFIG_SCALEFACTORTYPE *pScaleParams = NULL; - - OMX_CHECK((hComponent != NULL) && - (pComponentConfigStructure != NULL), OMX_ErrorBadParameter); - - // Initialize the local variables - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - /* GetConfig can't be invoked incase the comp is in Invalid State */ - OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, - OMX_ErrorIncorrectStateOperation); - - switch( nIndex ) { - case OMX_IndexConfigCommonOutputCrop : - { - OMX_BASE_CHK_VERSION(pComponentConfigStructure, OMX_CONFIG_RECTTYPE, eError); - pCropParams = (OMX_CONFIG_RECTTYPE *) pComponentConfigStructure; - if( pCropParams->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - pCropParams->nWidth = pVidDecComp->tCropDimension.nWidth; - pCropParams->nHeight = pVidDecComp->tCropDimension.nHeight; - pCropParams->nTop = pVidDecComp->tCropDimension.nTop; - pCropParams->nLeft = pVidDecComp->tCropDimension.nLeft; - } else { - eError = OMX_ErrorBadParameter; - OSAL_ErrorTrace("OMX_IndexConfigCommonOutputCrop called on i/p port. Not Supported."); - } - } - break; - - case OMX_IndexConfigCommonScale : - { - OMX_BASE_CHK_VERSION(pComponentConfigStructure, OMX_CONFIG_SCALEFACTORTYPE, eError); - pScaleParams = (OMX_CONFIG_SCALEFACTORTYPE *) pComponentConfigStructure; - if( pScaleParams->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { - pScaleParams->xWidth = pVidDecComp->tScaleParams.xWidth; - pScaleParams->xHeight = pVidDecComp->tScaleParams.xHeight; - OSAL_ErrorTrace("OMX_IndexConfigCommonScale called on o/p port."); - } else { - eError = OMX_ErrorBadParameter; - OSAL_ErrorTrace("OMX_IndexConfigCommonOutputCrop called on i/p port. Not Supported."); - } - } - break; - - default : - eError = OMXBase_GetConfig(hComponent, nIndex, pComponentConfigStructure); - } - -EXIT: - return (eError); -} - -/* -* Video Decoder SetConfig -*/ -OMX_ERRORTYPE OMXVidDec_SetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure) { - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - OMX_CHECK((hComponent != NULL) && - (pComponentConfigStructure != NULL), OMX_ErrorBadParameter); - - // Initialize the local variables - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - /* SetConfig can't be invoked incase the comp is in Invalid State */ - OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, - OMX_ErrorIncorrectStateOperation); - - switch( nIndex ) { - default : - eError = OMXBase_SetConfig(hComponent, nIndex, pComponentConfigStructure); - } - -EXIT: - return (eError); -} - -/* -* Video Decoder xlateBuffer Handles -*/ -OMX_ERRORTYPE OMXVidDec_XlateBuffHandle(OMX_HANDLETYPE hComponent, - OMX_PTR pBufferHdr, OMX_BOOL bRegister) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMX_BUFFERHEADERTYPE *pOMXBufHeader; - OMXBase_Port *pPort; - OMX_U32 nPortIndex; - int32_t tRetVal; - int i; - - pComp = (OMX_COMPONENTTYPE *)(hComponent); - pVidDecComp = (OMXVidDecComp *)pComp->pComponentPrivate; - - pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) (pBufferHdr); - nPortIndex = (pOMXBufHeader->nInputPortIndex == OMX_NOPORT) ? - pOMXBufHeader->nOutputPortIndex : - pOMXBufHeader->nInputPortIndex; - - pPort = pVidDecComp->sBase.pPorts[nPortIndex]; - - /* Non a buffer allocator, then check if any xlation is needed */ - if (pPort->sProps.eBufMemoryType == MEM_GRALLOC) { - //populate the DMA BUFF_FDs from the gralloc pointers - for ( i = 0; i < MAX_PLANES_PER_BUFFER; i++ ) { - ((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd = (OMX_U32)(((IMG_native_handle_t*)(pOMXBufHeader->pBuffer))->fd[i]); - if (((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd > 0) { - if (bRegister) { - dce_buf_lock(1, (size_t *)&(((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd)); - } else { - dce_buf_unlock(1, (size_t *)&(((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd)); - } - } - } - } - -EXIT: - return (eError); -} - -/* -* video decoder Command Notify -*/ -OMX_ERRORTYPE OMXVidDec_CommandNotify(OMX_HANDLETYPE hComponent, - OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - XDAS_Int32 status; - OMX_U32 ReturnCmdCompletionCallBack = 1, i; - OMX_PTR pDecStaticParams; - OMX_PTR pDecDynamicParams; - OMX_PTR pDecStatus; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef; - OMX_U32 nFrameWidth, nFrameHeight; - OMX_U32 nFrameWidthOrig; - (void) pCmdData; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = pHandle->pComponentPrivate; - - switch( Cmd ) { - case OMX_CommandStateSet : - if( pVidDecComp->sBase.tCurState == OMX_StateLoaded && - pVidDecComp->sBase.tNewState == OMX_StateIdle ) { - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - // Check the buffer cnt is greater than min required - // buffer count - if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) { - OSAL_ErrorTrace("Number of actual buffers on o/p port less than the minmum required by componenet as set on o/p port defs"); - eError = OMX_ErrorUnsupportedSetting; - goto EXIT; - } - - // Transitioning from Loaded to Idle state - if(pVidDecComp->pDecHandle == NULL ) { - pDecStaticParams = pVidDecComp->pDecStaticParams; - // Call the Video Decoder Create Call - pVidDecComp->pDecHandle - = VIDDEC3_create(pVidDecComp->ce, - pVidDecComp->cDecoderName, - (VIDDEC3_Params *) pDecStaticParams); - - if( pVidDecComp->pDecHandle == NULL ) { - OSAL_ErrorTrace("VIDDEC3_create failed ....! \n"); - eError = OMX_ErrorInsufficientResources; - pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE; - goto EXIT; - } - pVidDecComp->nCodecRecreationRequired = 0; - pVidDecComp->nOutPortReconfigRequired = 0; - - // Populate Dynamic Params and the Status structures - pVidDecComp->fpSet_DynamicParams(hComponent, pVidDecComp->pDecDynParams); - pVidDecComp->fpSet_Status(hComponent, pVidDecComp->pDecStatus); - //This is to handle Arbitrary stride requirement given by IL client. - if((OMX_U32)pOutputPortDef->format.video.nStride > - pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth) { - pVidDecComp->pDecDynParams->displayWidth = - pOutputPortDef->format.video.nStride; - } - pDecDynamicParams = pVidDecComp->pDecDynParams; - pDecStatus = pVidDecComp->pDecStatus; - - OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed! \n"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - - // Call the Decoder Control function - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETBUFINFO, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_GETBUFINFO failed! \n"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - } else if( pVidDecComp->sBase.tCurState == OMX_StateIdle && - pVidDecComp->sBase.tNewState == OMX_StateLoaded ) { - // Transitioning from Idle to Loaded - if( pVidDecComp->pDecHandle != NULL ) { - // Delete the Decoder Component Private Handle - pVidDecComp->nFrameCounter = 0; - if( pVidDecComp->bSupportSkipGreyOutputFrames ) { - pVidDecComp->bSyncFrameReady = OMX_FALSE; - } - - pVidDecComp->nOutbufInUseFlag = 0; - VIDDEC3_delete(pVidDecComp->pDecHandle); - pVidDecComp->pDecHandle = NULL; - } - - } else if(((pVidDecComp->sBase.tCurState == OMX_StateExecuting) && - (pVidDecComp->sBase.tNewState == OMX_StateIdle)) || - ((pVidDecComp->sBase.tCurState == OMX_StatePause) && - (pVidDecComp->sBase.tNewState == OMX_StateIdle))) { - OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL); - } - - break; - - case OMX_CommandPortDisable : - // In case of Port Disable Command - // Loaded state implies codec is deleted. so no need to delete again - if( pVidDecComp->sBase.tCurState != OMX_StateLoaded - && pVidDecComp->pDecHandle != NULL ) { - // Call Decoder Flush function - OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL); - } - break; - - case OMX_CommandPortEnable : - if( nParam == OMX_VIDDEC_OUTPUT_PORT ) { - // Check the buffer cnt is greater than min required - // buffer count - pOutputPortDef = - &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) { - OSAL_ErrorTrace("Number of actual buffers on o/p port less than the minmum required by componenet as set on o/p port defs"); - eError = OMX_ErrorUnsupportedSetting; - goto EXIT; - } - if( (OMX_U32)pOutputPortDef->format.video.nStride < - pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) { - OSAL_ErrorTrace("Unsupported Stride set on o/p port defs"); - eError = OMX_ErrorUnsupportedSetting; - goto EXIT; - } - } - if( pVidDecComp->sBase.tCurState != OMX_StateLoaded ) { - if( pVidDecComp->nCodecRecreationRequired == 1 - && pVidDecComp->pDecHandle != NULL ) { - pVidDecComp->nCodecRecreationRequired = 0; - pVidDecComp->nFrameCounter = 0; - pVidDecComp->tScaleParams.xWidth = 0x10000; - pVidDecComp->tScaleParams.xHeight = 0x10000; - if( pVidDecComp->bSupportSkipGreyOutputFrames ) { - pVidDecComp->bSyncFrameReady = OMX_FALSE; - } - pVidDecComp->nOutbufInUseFlag = 0; - VIDDEC3_delete(pVidDecComp->pDecHandle); - pVidDecComp->pDecHandle = NULL; - - pOutputPortDef = - &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - // Set the Static Params - pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams); - if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE - && pVidDecComp->pDecStatus->outputWidth != 0 - && pVidDecComp->pDecStatus->outputHeight != 0 ) { - nFrameWidth = pVidDecComp->pDecStatus->outputWidth; - nFrameHeight = pVidDecComp->pDecStatus->outputHeight; - } else { - nFrameWidth = pOutputPortDef->format.video.nFrameWidth; - nFrameHeight = pOutputPortDef->format.video.nFrameHeight; - } - if( nFrameWidth & 0x0F ) { - nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); - } - if( nFrameHeight & 0x1F ) { - nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); - } - nFrameWidthOrig = pOutputPortDef->format.video.nFrameWidth; - if( nFrameWidthOrig & 0x0F ) { - nFrameWidthOrig = nFrameWidthOrig + 16 - (nFrameWidthOrig & 0x0F); - } - pVidDecComp->pDecStaticParams->maxHeight = nFrameHeight; - pVidDecComp->pDecStaticParams->maxWidth = nFrameWidth; - - /* Check whether the displayWidth already accounts for any - * difference between the current and new frame width and - * set maxWidth accordingly */ - if ( nFrameWidth != nFrameWidthOrig && - nFrameWidthOrig == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) { - pVidDecComp->pDecStaticParams->maxWidth = nFrameWidthOrig; - } - - // And Call the Codec Create - pVidDecComp->pDecHandle = VIDDEC3_create(pVidDecComp->ce, - pVidDecComp->cDecoderName, - (VIDDEC3_Params *) - pVidDecComp->pDecStaticParams); - if( pVidDecComp->pDecHandle == NULL ) { - OSAL_ErrorTrace("VIDDEC3_create failed ....! \n"); - eError = OMX_ErrorInsufficientResources; - pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE; - goto EXIT; - } - - // Populate Dynamic Params and the Status structures - pVidDecComp->fpSet_DynamicParams(hComponent, pVidDecComp->pDecDynParams); - pVidDecComp->fpSet_Status(hComponent, pVidDecComp->pDecStatus); - //This is to handle Arbitrary stride requirement given by IL client. - if((OMX_U32)pOutputPortDef->format.video.nStride != - pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth) { - pVidDecComp->pDecDynParams->displayWidth = - pOutputPortDef->format.video.nStride; - } - pDecDynamicParams = pVidDecComp->pDecDynParams; - pDecStatus = pVidDecComp->pDecStatus; - - // Call the Decoder Control function - OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed! \n"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - pVidDecComp->nOutPortReconfigRequired = 0; - } - - break; - - case OMX_CommandFlush : - { - // In case of Flush Command - // In case all ports have to be flushed or the output port - // has to be flushed - if( nParam == OMX_ALL || nParam == OMX_VIDDEC_OUTPUT_PORT ) { - // Only then flush the port - OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL); - } - } - break; - - case OMX_CommandMarkBuffer : - ReturnCmdCompletionCallBack = 0; - break; - - default: - OSAL_ErrorTrace("Invalid command"); - } - - if( ReturnCmdCompletionCallBack == 1 ) { - eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, - OMX_EventCmdComplete, Cmd, nParam, NULL); - } - -EXIT: - return (eError); - -} - -/* -* Video Decoder DataNotify -*/ -OMX_ERRORTYPE OMXVidDec_DataNotify(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eRMError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_BUFFERHEADERTYPE sInBufHeader; - OMXVidDecComp *pVidDecComp = NULL; - OMX_BUFFERHEADERTYPE *pInBufHeader = NULL; - OMX_BUFFERHEADERTYPE *pOutBufHeader = NULL; - OMX_BUFFERHEADERTYPE *pDupBufHeader = NULL; - OMX_BUFFERHEADERTYPE *pFreeBufHeader = NULL; - OMX_U32 nInMsgCount = 0; - OMX_U32 nOutMsgCount = 0; - OMX_U32 Buffer_locked = 1; - OMX_U32 ii = 0, i, jj = 0; - OMX_U32 nStride = 0; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; - OMX_BOOL nIsDioReady = OMX_FALSE; - XDAS_Int32 status; - XDM2_BufDesc *pInBufDescPtr = NULL; - XDM2_BufDesc *pOutBufDescPtr = NULL; - OMX_CONFIG_RECTTYPE out2DAllocParam; - IVIDDEC3_OutArgs *pDecOutArgs = NULL; - IVIDDEC3_Status *pDecStatus = NULL; - XDM_Rect activeFrameRegion[2]; - OMX_U32 nNewInBufferRequired = 0; - OMX_BOOL bSendPortReconfigForScale = OMX_FALSE; - OMX_U32 nScale, nScaleRem, nScaleQ16Low, nScaleWidth, nScaleHeight; - OMX_U64 nScaleQ16 = 0; - uint32_t nActualSize; - OMX_BOOL went_thru_loop = OMX_FALSE; - OMX_BOOL duped_IPbuffer = OMX_TRUE; - IMG_native_handle_t* grallocHandle; - OMX_U32 nLockedCount = 0; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - - //! Initialize pointers - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - OMX_CHECK(pVidDecComp != NULL, OMX_ErrorBadParameter); - - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); - out2DAllocParam = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]; - - /*! Ensure that the stride on output portdef structure is more than - the padded width. This is needed in the case where application - sets the Stride less than padded width */ - if( (OMX_U32)pOutputPortDef->format.video.nStride >= - pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) { - nStride = pOutputPortDef->format.video.nStride; - } else { - nStride = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; - } - if((pVidDecComp->sBase.tCurState != OMX_StateExecuting) || - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.bEnabled == OMX_FALSE) || - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.bEnabled == OMX_FALSE)) { - goto EXIT; - } - nIsDioReady = OMXBase_IsDioReady(hComponent, OMX_VIDDEC_OUTPUT_PORT); - if( nIsDioReady == OMX_FALSE ) { - goto EXIT; - } - //! Get the number of input and output buffers - pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, - OMX_VIDDEC_INPUT_PORT, - (OMX_PTR)&nInMsgCount); - pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, - OMX_VIDDEC_OUTPUT_PORT, - (OMX_PTR)&nOutMsgCount); - - // Loop until input or output buffers are exhausted - while((nInMsgCount > 0) && (nOutMsgCount > 0)) { - // Only if Cur-State is Execute proceed. - if((pVidDecComp->sBase.tCurState != OMX_StateExecuting) || - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.bEnabled == OMX_FALSE) || - (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.bEnabled == OMX_FALSE)) { - break; - } - if( OMXBase_IsCmdPending(hComponent) && pVidDecComp->nOutbufInUseFlag == 0 ) { - OSAL_ErrorTrace("Exiting dataNotify because command is pending"); - goto EXIT; - } - if( pVidDecComp->nOutPortReconfigRequired == 1 ) { - OSAL_ErrorTrace("Port disable/reconfiguration needed"); - goto EXIT; - } - if( pVidDecComp->nFatalErrorGiven == 1 ) { - OSAL_ErrorTrace("Fatal error given to IL client"); - goto EXIT; - } - // Buffer is locked by the codec by default. - // It can be freed only if mentioned in freeBufId[] field. - Buffer_locked = 1; - ii=0; - went_thru_loop = OMX_TRUE; - if( nNewInBufferRequired == 0 && pVidDecComp->sCodecConfig.sBuffer == NULL ) { - duped_IPbuffer = OMX_FALSE; - //! Get Input and Output Buffer header from Queue - eError = pVidDecComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_VIDDEC_INPUT_PORT, - (OMX_PTR*)(&pInBufHeader)); - if( eError == OMX_TI_WarningAttributePending ) { - pVidDecComp->sCodecConfig.sBuffer = P2H(memplugin_alloc(2, 1, MEM_CARVEOUT, 0, 0)); - OMX_CHECK(pVidDecComp->sCodecConfig.sBuffer != NULL, OMX_ErrorInsufficientResources); - eError = pVidDecComp->sBase.pPvtData->fpDioControl(hComponent, OMX_VIDDEC_INPUT_PORT, - OMX_DIO_CtrlCmd_GetCtrlAttribute, (OMX_PTR)&(pVidDecComp->sCodecConfig)); - if( eError == OMX_TI_WarningInsufficientAttributeSize ) { - /*Allocate the data pointer again with correct size*/ - uint32_t new_size = pVidDecComp->sCodecConfig.sBuffer->size; - memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer)); - pVidDecComp->sCodecConfig.sBuffer = P2H(memplugin_alloc(new_size, 1, MEM_CARVEOUT, 0, 0)); - OMX_CHECK(pVidDecComp->sCodecConfig.sBuffer != NULL, OMX_ErrorInsufficientResources); - eError = pVidDecComp->sBase.pPvtData->fpDioControl(hComponent, OMX_VIDDEC_INPUT_PORT, - OMX_DIO_CtrlCmd_GetCtrlAttribute, (OMX_PTR)&(pVidDecComp->sCodecConfig)); - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("Codec config test failed because DIO Control returned buffer"); - goto EXIT; - } - } - pVidDecComp->pDecDynParams->decodeHeader = pVidDecComp->nDecoderMode; - pInBufHeader = NULL; - // Call the Decoder Control function - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } else if( pVidDecComp->nOutbufInUseFlag == 0 ) { - if( pVidDecComp->pDecDynParams->decodeHeader != XDM_DECODE_AU ) { - pVidDecComp->pDecDynParams->decodeHeader = XDM_DECODE_AU; - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - if( pInBufHeader ) { - if(!(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) && (pInBufHeader->nFilledLen - pInBufHeader->nOffset == 0)) { - // Send Input buffer back to base - pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, - OMX_VIDDEC_INPUT_PORT, - pInBufHeader); - - //! Get the number of input and output buffers - pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, - OMX_VIDDEC_INPUT_PORT, - (OMX_PTR)&nInMsgCount); - if( nInMsgCount ) { - continue; - } else { - break; - } - } - } - nLockedCount = 0; - while (nLockedCount < nOutMsgCount) { - eError = pVidDecComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_VIDDEC_OUTPUT_PORT, - (OMX_PTR*)(&pOutBufHeader)); - if (pOutBufHeader) { - // check locked flag - if (((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bIsLocked) { - nLockedCount++; - // Send the buffer to the back of the queue - pVidDecComp->sBase.pPvtData->fpDioQueue(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); - pOutBufHeader = NULL; - // Get the number of output buffers - pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, - OMX_VIDDEC_OUTPUT_PORT, - (OMX_PTR)&nOutMsgCount); - continue; - } - } - // if we get here we have our buffer, or it is an error - break; - } - if (pOutBufHeader == NULL) { - // Cancel input buffer and continue - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_INPUT_PORT, - pInBufHeader); - - goto EXIT; - } - } - } - pOutBufDescPtr = pVidDecComp->tOutBufDesc; - pInBufDescPtr = pVidDecComp->tInBufDesc; - if( pVidDecComp->sCodecConfig.sBuffer != NULL && - (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) { - pVidDecComp->pDecDynParams->decodeHeader = pVidDecComp->nDecoderMode; - // Call the Decoder Control function - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, - pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - pInBufDescPtr->numBufs = 1; - if( pInBufHeader != NULL && pVidDecComp->nOutbufInUseFlag == 1 ) { - pVidDecComp->pDecInArgs->numBytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset; - //Sending the same input ID for second field - pVidDecComp->pDecInArgs->inputID = (OMX_S32) pOutBufHeader; - if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) { - (((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = pInBufHeader->nOffset; - pInBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]); - pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE; - pInBufDescPtr->descs[0].bufSize.bytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset; - pInBufDescPtr->descs[0].bufSize.tileMem.height = 1; - } - } else if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader == pVidDecComp->nDecoderMode ) { - pVidDecComp->pDecInArgs->numBytes = pVidDecComp->sCodecConfig.sBuffer->size; - pVidDecComp->pDecInArgs->inputID = 1; - pVidDecComp->sCodecConfig.sBuffer->offset = sizeof(MemHeader); - pInBufDescPtr->descs[0].buf = (XDAS_Int8*)(pVidDecComp->sCodecConfig.sBuffer); - pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE; - pInBufDescPtr->descs[0].bufSize.bytes = pVidDecComp->sCodecConfig.sBuffer->size; - pInBufDescPtr->descs[0].bufSize.tileMem.height = 1; - pOutBufDescPtr->numBufs = 0; - } else if( pInBufHeader != NULL && pVidDecComp->pDecDynParams->decodeHeader == XDM_DECODE_AU ) { - // In case EOS and Number of Input bytes=0. Flush Decoder and exit - if( pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS ) { - if( pInBufHeader->nFilledLen == 0 ) { - pOutBufHeader->nFilledLen = 0; - eError = OMXVidDec_HandleFLUSH_EOS(hComponent, pOutBufHeader, pInBufHeader); - goto EXIT; - } else { - pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; - } - } - if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { - if( pOutputPortDef->format.video.nFrameWidth < out2DAllocParam.nWidth - || pOutputPortDef->format.video.nFrameHeight < out2DAllocParam.nHeight ) { - - if (pVidDecComp->nFrameCounter) { - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_INPUT_PORT, pInBufHeader); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); - - OMXVidDec_HandleFirstFrame(hComponent, NULL); - } else { - pOutputPortDef->format.video.nFrameWidth = out2DAllocParam.nWidth; - pOutputPortDef->format.video.nFrameHeight = out2DAllocParam.nHeight; - pOutputPortDef->format.video.nStride = pOutputPortDef->format.video.nFrameWidth; - pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * - ((pOutputPortDef->format.video.nFrameHeight * 3) >> 1); - pInputPortDef->format.video.nFrameWidth = out2DAllocParam.nWidth; - pInputPortDef->format.video.nFrameHeight = out2DAllocParam.nHeight; - - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_INPUT_PORT, pInBufHeader); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); - - /*! Notify to Client change in output port settings */ - eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, - OMX_EventPortSettingsChanged, OMX_VIDDEC_OUTPUT_PORT, 0, NULL); - pVidDecComp->nOutPortReconfigRequired = 1; - } - goto EXIT; - } - } - /*! Populate xDM structure */ - pVidDecComp->pDecInArgs->numBytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset; - pVidDecComp->pDecInArgs->inputID = (OMX_S32) pOutBufHeader; - if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) { - /* Fill Input Buffer Descriptor */ - (((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = pInBufHeader->nOffset; - pInBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]); - pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE; - pInBufDescPtr->descs[0].bufSize.bytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset; - pInBufDescPtr->descs[0].bufSize.tileMem.height = 1; - } - /* Initialize Number of Buffers for input and output */ - pInBufDescPtr->numBufs = 1; - pOutBufDescPtr->numBufs = 2; - - /* Fill Output Buffer Descriptor */ - /* if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sProps.eBufMemoryType == MEM_GRALLOC) { - pOutBufDescPtr->descs[0].bufSize.tileMem.width = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; - pOutBufDescPtr->descs[0].bufSize.tileMem.height = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight; - (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = 0; - pOutBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]); - pOutBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILED8; - (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]).offset = 0; - pOutBufDescPtr->descs[1].bufSize.tileMem.width =pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; - pOutBufDescPtr->descs[1].bufSize.tileMem.height = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight / 2; - pOutBufDescPtr->descs[1].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]); - pOutBufDescPtr->descs[1].memType = XDM_MEMTYPE_TILED16; - } else*/ { - pOutBufDescPtr->descs[0].bufSize.bytes = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth * - pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight; - pOutBufDescPtr->descs[0].bufSize.tileMem.height = 1; - pOutBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]); - pOutBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE; - - memcpy(&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]), &(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]), sizeof(MemHeader)); - - (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]).offset = pOutBufDescPtr->descs[0].bufSize.bytes; - - pOutBufDescPtr->descs[1].bufSize.bytes = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth * - pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight/2; - pOutBufDescPtr->descs[1].bufSize.tileMem.height = 1; - pOutBufDescPtr->descs[1].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]); - pOutBufDescPtr->descs[1].memType = XDM_MEMTYPE_TILEDPAGE; - nStride = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; - } - - if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) { - if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment) { - /* provide metaBuffer to codec because it's MPEG2 with Error Concealment */ - pOutBufDescPtr->numBufs = 3; - pVidDecComp->pmetaBuffer->offset = sizeof(MemHeader); - pOutBufDescPtr->descs[2].buf = (XDAS_Int8*)(pVidDecComp->pmetaBuffer); - pOutBufDescPtr->descs[2].memType = XDM_MEMTYPE_RAW; - pOutBufDescPtr->descs[2].bufSize.bytes = pVidDecComp->pmetaBuffer->size; - pOutBufDescPtr->descs[2].bufSize.tileMem.height = 1; - } - } - - pOutBufHeader->nTimeStamp = pInBufHeader->nTimeStamp; - if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE && pVidDecComp->bInputBufferCancelled == 0 ) { - OSAL_WriteToPipe(pVidDecComp->pTimeStampStoragePipe, &(pInBufHeader->nTimeStamp), - sizeof(OMX_TICKS), OSAL_NO_SUSPEND); - } - } - /*Copy OMX_BUFFERFLAG_DECODEONLY from input buffer header to output buffer header*/ - if (pOutBufHeader && pInBufHeader) { - pOutBufHeader->nFlags |= (pInBufHeader->nFlags & OMX_BUFFERFLAG_DECODEONLY); - ((OMXBase_BufHdrPvtData *)(pInBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC; - ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC; - } - - if (pOutBufHeader) { - grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); - pVidDecComp->grallocModule->lock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle, GRALLOC_USAGE_HW_RENDER, - 0,0,pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth, - pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight,NULL); - ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bIsLocked = OMX_TRUE; - } - - status = VIDDEC3_process(pVidDecComp->pDecHandle, pInBufDescPtr, pOutBufDescPtr, - (VIDDEC3_InArgs *)pVidDecComp->pDecInArgs, (VIDDEC3_OutArgs *)pVidDecComp->pDecOutArgs); - - pDecOutArgs = pVidDecComp->pDecOutArgs; - - /*! In case this is an IPC failure */ - if(status == DCE_EIPC_CALL_FAIL) { - ALOGE("\n Remote Core Communication Failure... \n"); - eError = OMX_ErrorHardware; - pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE; - goto EXIT; - } - /*! In case Process returns error */ - if(status == XDM_EFAIL ){ - ALOGE("\n Process function returned an Error... \n"); - ALOGE("Codec Extended - 0x%x", (OMX_U32)pVidDecComp->pDecOutArgs->extendedError); - ALOGE("Input Buffer Size provided to codec is : %d", (int)pInBufDescPtr->descs[0].bufSize.bytes); - ALOGE("Frame count is : %d", pVidDecComp->nFrameCounter + 1); - ALOGE("Bytes consumed - %d", (int)pVidDecComp->pDecOutArgs->bytesConsumed); - - if( !(pVidDecComp->bInputBufferCancelled == 1 && pVidDecComp->pDecOutArgs->extendedError & 0x8000)) { - /*! Call function to handle Codec Error */ - eError = OMXVidDec_HandleCodecProcError(hComponent, &(pInBufHeader), &(pOutBufHeader)); - } - if( eError != OMX_ErrorNone ) { - goto EXIT; - } - if( pVidDecComp->nOutPortReconfigRequired == 1 ) { - goto EXIT; - } - } - if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader == pVidDecComp->nDecoderMode ) { - eError = OMXVidDec_HandleFirstFrame(hComponent, NULL); - //we have to loop once again if we duplicated any input buffer - if(duped_IPbuffer && nInMsgCount) { - if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer && pVidDecComp->nOutPortReconfigRequired == 0 && went_thru_loop) { - memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer)); - pVidDecComp->sCodecConfig.sBuffer = NULL; - } - continue; - } - goto EXIT; - } - // Increment the FrameCounter value - pVidDecComp->nFrameCounter++; - if( pDecOutArgs->outBufsInUseFlag && pVidDecComp->nOutbufInUseFlag == 1 ) { - pVidDecComp->nFrameCounter--; - } - if( pDecOutArgs->outBufsInUseFlag ) { - pVidDecComp->nOutbufInUseFlag = 1; - /* Check for any output buffer which is freed by codec*/ - ii = 0; - while( pDecOutArgs->freeBufID[ii] ) { - if( pDecOutArgs->outputID[0] == 0 && pDecOutArgs->freeBufID[ii] == pVidDecComp->pDecInArgs->inputID ) { - pVidDecComp->nOutbufInUseFlag = 0; - pVidDecComp->nFrameCounter--; - } - pFreeBufHeader = (OMX_BUFFERHEADERTYPE *) pDecOutArgs->freeBufID[ii]; - ((OMXBase_BufHdrPvtData *)(pFreeBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; - grallocHandle = (IMG_native_handle_t*)(pFreeBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle); - - /* Send the Freed buffer back to base component */ - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pFreeBufHeader); - ii++; - } - - if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) { - ii = 0; - if( pInBufHeader != NULL ) { - if((pInBufHeader->nFilledLen - pInBufHeader->nOffset) != (OMX_U32)pDecOutArgs->bytesConsumed ) { - nNewInBufferRequired = 1; - pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed; - continue; - } - nNewInBufferRequired = 0; - pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed; - if( !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS)) { - // Send Input buffer back to base - pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, - OMX_VIDDEC_INPUT_PORT, pInBufHeader); - } else if( pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS ) { - OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, pInBufHeader); - if( eError != OMX_ErrorNone ) { - goto EXIT; - } - } - } - pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, - OMX_VIDDEC_INPUT_PORT, (OMX_PTR)&nInMsgCount); - if( nInMsgCount > 0 ) { - continue; - } else { - break; - } - } - } - - // Check for the width/height after first frame - if((pVidDecComp->nFrameCounter == 1) || (pVidDecComp->nOutbufInUseFlag == 1 && pVidDecComp->nFrameCounter == 2)) { - eError = OMXVidDec_HandleFirstFrame(hComponent, &(pInBufHeader)); - if( eError != OMX_ErrorNone ) { - goto EXIT; - } - if( pVidDecComp->nOutPortReconfigRequired == 1 - && pVidDecComp->pDecStaticParams->displayDelay - != IVIDDEC3_DECODE_ORDER ) { - /*! In case Port reconfiguration is required - * output buffer */ - goto EXIT; - } - } // End of if condition from nFrameCounter = 1 - - if( pVidDecComp->nOutbufInUseFlag == 1 ) { - pVidDecComp->nOutbufInUseFlag = 0; - nNewInBufferRequired = 0; - } - ii = 0; - while( pDecOutArgs->outputID[ii] ) { - pOutBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[ii]; - if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { - OSAL_ReadFromPipe(pVidDecComp->pTimeStampStoragePipe, &(pOutBufHeader->nTimeStamp), - sizeof(OMX_TICKS), &(nActualSize), OSAL_NO_SUSPEND); - } - - activeFrameRegion[0] = pDecOutArgs->displayBufs.bufDesc[0].activeFrameRegion; - activeFrameRegion[1].bottomRight.y = (activeFrameRegion[0].bottomRight.y) / 2; - activeFrameRegion[1].bottomRight.x = activeFrameRegion[0].bottomRight.x; - - //Crop rectangle handles the offsets for Y and UV buffers - pOutBufHeader->nOffset = 0; - pOutBufHeader->nFilledLen = (pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * nStride * 3) / 2; - - if((pVidDecComp->tCropDimension.nTop != activeFrameRegion[0].topLeft.y - || pVidDecComp->tCropDimension.nLeft != activeFrameRegion[0].topLeft.x) - || (pVidDecComp->tCropDimension.nWidth != (OMX_U32)(activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x) - || pVidDecComp->tCropDimension.nHeight != (OMX_U32)(activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y))) { - pVidDecComp->tCropDimension.nTop = activeFrameRegion[0].topLeft.y; - pVidDecComp->tCropDimension.nLeft = activeFrameRegion[0].topLeft.x; - pVidDecComp->tCropDimension.nWidth = activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x; - pVidDecComp->tCropDimension.nHeight = activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y; - if( pVidDecComp->bUsePortReconfigForCrop == OMX_TRUE ) { - eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventPortSettingsChanged, - OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonOutputCrop, NULL); - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("Port reconfig callback returned error, trying to continue"); - } - } - } - - if( pVidDecComp->bSupportSkipGreyOutputFrames ) { - if( pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_I_FRAME || - pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IDR_FRAME || - pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IP_FRAME || - pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IB_FRAME ) { - pVidDecComp->bSyncFrameReady = OMX_TRUE; - } - } - grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle); - - if( pVidDecComp->bSyncFrameReady == OMX_TRUE ) { - if( !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) || !(pVidDecComp->bIsFlushRequired)) { - // Send the Output buffer to Base component - pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); - } - } else { - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); - } - pDecOutArgs->outputID[ii] = 0; - ii++; - } - - jj = 0; - while(pDecOutArgs->freeBufID[jj]) { - // update locked flag of buffer to "unlocked" - pFreeBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->freeBufID[jj]; - ((OMXBase_BufHdrPvtData *)(pFreeBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; - if (!ii && pDecOutArgs->freeBufID[jj] == pVidDecComp->pDecInArgs->inputID) { - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); - break; - } - jj++; - } - - if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) { - if( pInBufHeader && pDecOutArgs && - (pVidDecComp->pDecDynParams->decodeHeader == XDM_DECODE_AU && pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE)) { - if((pVidDecComp->bInputBufferCancelled == 1) && (((pDecOutArgs->bytesConsumed == 0) || (((OMX_S32)pInBufHeader->nFilledLen) - <= ((OMX_S32)pInBufHeader->nOffset + pDecOutArgs->bytesConsumed + 3))) || - (pVidDecComp->pDecOutArgs->extendedError & 0x8000))) { - pVidDecComp->bInputBufferCancelled = 0; - } else if((((OMX_S32)pInBufHeader->nFilledLen) > ((OMX_S32)pInBufHeader->nOffset + pDecOutArgs->bytesConsumed + 3)) && - ((pDecOutArgs->bytesConsumed != 0) && !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS))) { - pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed; - pVidDecComp->bInputBufferCancelled = 1; - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_VIDDEC_INPUT_PORT, pInBufHeader); - } - } - /* Currently the assumption is that the entire input buffer is consumed - * going forward we might have to handle cases where partial buffer is - * consumed */ - if( pVidDecComp->bInputBufferCancelled == 0 ) { - if( pInBufHeader != NULL && - !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) && - pVidDecComp->nOutPortReconfigRequired != 1 ) { - pInBufHeader->nFilledLen - = pInBufHeader->nFilledLen - pDecOutArgs->bytesConsumed - pInBufHeader->nOffset; - pInBufHeader->nOffset = 0; - // Send Input buffer back to base - pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, - OMX_VIDDEC_INPUT_PORT, pInBufHeader); - } - else if( pInBufHeader != NULL && (pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) && - pVidDecComp->nOutPortReconfigRequired != 1 ) { - pInBufHeader->nFilledLen - = pInBufHeader->nFilledLen - pDecOutArgs->bytesConsumed - pInBufHeader->nOffset; - pInBufHeader->nOffset = 0; - if( Buffer_locked == 1 ) { - OMXVidDec_HandleFLUSH_EOS(hComponent, pDupBufHeader, pInBufHeader); - } else { - OMXVidDec_HandleFLUSH_EOS(hComponent, pOutBufHeader, pInBufHeader); - } - if( eError != OMX_ErrorNone ) { - goto EXIT; - } - } - } - } - nIsDioReady = OMXBase_IsDioReady(hComponent, OMX_VIDDEC_OUTPUT_PORT); - if( nIsDioReady == OMX_FALSE ) { - goto EXIT; - } - // Get the number of buffers in Input and Output port - pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, - OMX_VIDDEC_INPUT_PORT, (OMX_PTR)&nInMsgCount); - pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, - OMX_VIDDEC_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount); - - } // End of while loop for input and output buffers - -EXIT: - if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer && pVidDecComp->nOutPortReconfigRequired == 0 && went_thru_loop) { - memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer)); - pVidDecComp->sCodecConfig.sBuffer = NULL; - } - - return (eError); -} - -/* -* Video Decoder DeInit -*/ -OMX_ERRORTYPE OMXVidDec_ComponentDeinit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp; - OMXVidDecComp *pVidDecComp = NULL; - OMX_U32 i; - OMXBase_PortProps *pOutPortProperties = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pComp = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pComp->pComponentPrivate; - - // For MPEG2 with Error Concealment ON, need to free the metadata buffer. - if ((pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) && (pVidDecComp->pmetaBuffer)) { - memplugin_free((void*)H2P(pVidDecComp->pmetaBuffer)); - pVidDecComp->pmetaBuffer = NULL; - } - - // Free sBuffer if it hasn't already been freed - if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer ) { - memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer)); - pVidDecComp->sCodecConfig.sBuffer = NULL; - } - - OSAL_DeletePipe(pVidDecComp->pTimeStampStoragePipe); - - OMXBase_UtilCleanupIfError(hComponent); - - // Call to Specific Decoder De-init routine - pVidDecComp->fpDeinit_Codec(hComponent); - // Close Codec-Engine - if( pVidDecComp->ce ) { - Engine_close(pVidDecComp->ce); - } - - if( pVidDecComp->sBase.cComponentName ) { - OSAL_Free(pVidDecComp->sBase.cComponentName); - pVidDecComp->sBase.cComponentName = NULL; - } - if( pVidDecComp->sBase.pVideoPortParams ) { - OSAL_Free(pVidDecComp->sBase.pVideoPortParams); - pVidDecComp->sBase.pVideoPortParams = NULL; - } - - if (pVidDecComp->tInBufDesc) { - memplugin_free(pVidDecComp->tInBufDesc); - pVidDecComp->tInBufDesc = NULL; - } - - if (pVidDecComp->tOutBufDesc) { - memplugin_free(pVidDecComp->tOutBufDesc); - pVidDecComp->tOutBufDesc = NULL; - } - - // Call to base Component De-init routine - eError = OMXBase_ComponentDeinit(hComponent); - - if (pVidDecComp->bIPCRecoveryNeeded) { - dce_ipc_recover(); - } - - OSAL_Free(pVidDecComp); - pVidDecComp = NULL; - -EXIT: - return (eError); -} - -/* -* GetExtension Index -*/ -OMX_ERRORTYPE OMXVidDec_GetExtensionIndex(OMX_HANDLETYPE hComponent, - OMX_STRING cParameterName, OMX_INDEXTYPE *pIndexType) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - // Check for NULL Parameters - if((cParameterName == NULL) || (pIndexType == NULL)) { - eError = OMX_ErrorBadParameter; - goto EXIT; - } - // Check for Valid State - if( pVidDecComp->sBase.tCurState == OMX_StateInvalid ) { - eError = OMX_ErrorInvalidState; - goto EXIT; - } - // Ensure that String length is not greater than Max allowed length - if( strlen(cParameterName) > 127 ) { - //strlen does not include \0 size, hence 127 - eError = OMX_ErrorBadParameter; - goto EXIT; - } - - if(strcmp(cParameterName, "OMX.google.android.index.enableAndroidNativeBuffers") == 0) { - // If Index type is 2D Buffer Allocated Dimension - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexUseNativeBuffers; - goto EXIT; - } else if (strcmp(cParameterName, "OMX.google.android.index.useAndroidNativeBuffer2") == 0) { - //This is call just a dummy for android to support backward compatibility - *pIndexType = (OMX_INDEXTYPE) NULL; - goto EXIT; - } else if (strcmp(cParameterName, "OMX.google.android.index.getAndroidNativeBufferUsage") == 0) { - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexAndroidNativeBufferUsage; - } else if( strcmp(cParameterName, "OMX.google.android.index.describeColorFormat") == 0 ) { - // If Index type is Time Stamp In Decode Order - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat; - } else if( strcmp(cParameterName, "OMX_TI_IndexParamTimeStampInDecodeOrder") == 0 ) { - // If Index type is Time Stamp In Decode Order - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexParamTimeStampInDecodeOrder; - } else if( strcmp(cParameterName, "OMX_TI_IndexEnableDecoderZeroDisplayDelayMode") == 0 ) { - // If Index type is Enable Decoder Zero Display Delay Mode - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode; - } else if( strcmp(cParameterName, "OMX.google.android.index.prepareForAdaptivePlayback") == 0 ) { - // If Index type is Enable Decoder Zero Display Delay Mode - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexPrepareForAdaptivePlayback; - } else { - //does not match any custom index - eError = OMX_ErrorUnsupportedIndex; - } - -EXIT: - return (eError); -} - - diff --git a/omx/videodecode/omx_videodec_common/src/omx_video_decoder_componenttable.c b/omx/videodecode/omx_videodec_common/src/omx_video_decoder_componenttable.c deleted file mode 100644 index 94bf1fd..0000000 --- a/omx/videodecode/omx_videodec_common/src/omx_video_decoder_componenttable.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <omx_video_decoder_componenttable.h> - - -extern OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent); -extern OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent); -extern OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent); -extern OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent); - -OMXDecoderComponentList DecoderList[] = -{ - { "video_decoder.avc", OMX_VIDEO_CodingAVC, OMXH264VD_Init }, /*! H264 Decoder */ - {"video_decoder.mpeg4", OMX_VIDEO_CodingMPEG4, OMXMPEG4VD_Init}, - { "video_decoder.h263", OMX_VIDEO_CodingH263, OMXH263VD_Init }, /*! H263 Decoder */ - { "video_decoder.mpeg2", OMX_VIDEO_CodingMPEG2, OMXMPEG2VD_Init }, /*! MPEG2 Decoder */ - { "NULL", 0, NULL } -}; - diff --git a/omx/videodecode/omx_videodec_common/src/omx_video_decoder_internal.c b/omx/videodecode/omx_videodec_common/src/omx_video_decoder_internal.c deleted file mode 100644 index 3536a99..0000000 --- a/omx/videodecode/omx_videodec_common/src/omx_video_decoder_internal.c +++ /dev/null @@ -1,946 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_VIDDEC_INTERNAL" - -#include <omx_video_decoder_internal.h> -#include <libdce.h> - -#define OMX_VIDDEC_DEFAULT_INBUF_WIDTH 1024 -#define OMX_VIDDEC_DEFAULT_INBUF_HEIGHT 1024 - -OMX_ERRORTYPE OMXVidDec_InitFields(OMXVidDecComp *pVidDecComp) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - hw_module_t const* module; - OMX_U32 i = 0; - - pVidDecComp->sBase.cComponentName = (OMX_STRING )OSAL_Malloc(sizeof(OMX_U8) * OMX_MAX_STRINGNAME_SIZE); - OMX_CHECK(pVidDecComp->sBase.cComponentName != NULL, OMX_ErrorInsufficientResources); - - /* Initialize Video Port parameters */ - pVidDecComp->sBase.pVideoPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); - - OMX_BASE_INIT_STRUCT_PTR(pVidDecComp->sBase.pVideoPortParams, OMX_PORT_PARAM_TYPE); - pVidDecComp->sBase.pVideoPortParams->nPorts = OMX_VIDDEC_NUM_OF_PORTS; - pVidDecComp->sBase.pVideoPortParams->nStartPortNumber = OMX_VIDDEC_DEFAULT_START_PORT_NUM; - pVidDecComp->sBase.nNumPorts = OMX_VIDDEC_NUM_OF_PORTS; - pVidDecComp->sBase.nMinStartPortIndex = OMX_VIDDEC_DEFAULT_START_PORT_NUM; - - pVidDecComp->sBase.nComponentVersion.s.nVersionMajor = OMX_VIDDEC_COMP_VERSION_MAJOR; - pVidDecComp->sBase.nComponentVersion.s.nVersionMinor = OMX_VIDDEC_COMP_VERSION_MINOR; - pVidDecComp->sBase.nComponentVersion.s.nRevision = OMX_VIDDEC_COMP_VERSION_REVISION; - pVidDecComp->sBase.nComponentVersion.s.nStep = OMX_VIDDEC_COMP_VERSION_STEP; - - eError = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); - if (eError == 0) { - pVidDecComp->grallocModule = (gralloc_module_t const *)module; - } else { - eError = OMX_ErrorInsufficientResources; - } - -EXIT: - return (eError); -} - -/* -*/ -void OMXVidDec_InitPortDefs(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp) -{ - OMXBaseComp *pBaseComp = &(pVidDecComp->sBase); - - OMX_PARAM_PORTDEFINITIONTYPE *inPortDefs = &(pBaseComp->pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); - OMX_PARAM_PORTDEFINITIONTYPE *outPortDefs= &(pBaseComp->pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - - /* set the default/Actual values of an Input port */ - inPortDefs->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - inPortDefs->nVersion = pBaseComp->nComponentVersion; - inPortDefs->bEnabled = OMX_TRUE; - inPortDefs->bPopulated = OMX_FALSE; - inPortDefs->eDir = OMX_DirInput; - inPortDefs->nPortIndex = OMX_VIDDEC_INPUT_PORT; - inPortDefs->nBufferCountMin = OMX_VIDDEC_MIN_IN_BUF_COUNT; - inPortDefs->nBufferCountActual = OMX_VIDDEC_DEFAULT_IN_BUF_COUNT; - inPortDefs->nBufferSize = Calc_InbufSize(OMX_VIDDEC_DEFAULT_INBUF_WIDTH, - OMX_VIDDEC_DEFAULT_INBUF_HEIGHT); - - inPortDefs->eDomain = OMX_PortDomainVideo; - inPortDefs->bBuffersContiguous = OMX_TRUE; - inPortDefs->nBufferAlignment = OMX_VIDDEC_DEFAULT_1D_INPUT_BUFFER_ALIGNMENT; - inPortDefs->format.video.cMIMEType= NULL; - inPortDefs->format.video.pNativeRender = NULL; - inPortDefs->format.video.nFrameWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH; - inPortDefs->format.video.nFrameHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT; - inPortDefs->format.video.nStride = 0; - inPortDefs->format.video.nSliceHeight = 0; - inPortDefs->format.video.nBitrate = 0; - inPortDefs->format.video.xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE << 16; - inPortDefs->format.video.bFlagErrorConcealment = OMX_TRUE; - inPortDefs->format.video.eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat; - inPortDefs->format.video.eColorFormat = OMX_COLOR_FormatUnused; - - /* set the default/Actual values of an output port */ - outPortDefs->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); - outPortDefs->nVersion = pVidDecComp->sBase.nComponentVersion; - outPortDefs->bEnabled = OMX_TRUE; - outPortDefs->bPopulated = OMX_FALSE; - outPortDefs->eDir = OMX_DirOutput; - outPortDefs->nPortIndex = OMX_VIDDEC_OUTPUT_PORT; - outPortDefs->nBufferCountMin = pVidDecComp->fpCalc_OubuffDetails(hComponent, - OMX_VIDDEC_DEFAULT_FRAME_WIDTH, - OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferCountMin; - outPortDefs->nBufferCountActual = pVidDecComp->fpCalc_OubuffDetails(hComponent, - OMX_VIDDEC_DEFAULT_FRAME_WIDTH, - OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferCountActual; - - outPortDefs->nBufferSize = pVidDecComp->fpCalc_OubuffDetails(hComponent, - OMX_VIDDEC_DEFAULT_FRAME_WIDTH, - OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferSize; - outPortDefs->eDomain = OMX_PortDomainVideo; - outPortDefs->bBuffersContiguous = OMX_TRUE; - outPortDefs->nBufferAlignment = pVidDecComp->fpCalc_OubuffDetails(hComponent, - OMX_VIDDEC_DEFAULT_FRAME_WIDTH, - OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).n1DBufferAlignment; - outPortDefs->format.video.cMIMEType = NULL; - outPortDefs->format.video.pNativeRender = NULL; - outPortDefs->format.video.nFrameWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH; - outPortDefs->format.video.nFrameHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT; - outPortDefs->format.video.nStride = OMX_VIDDEC_DEFAULT_STRIDE; - outPortDefs->format.video.nSliceHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT; - outPortDefs->format.video.nBitrate = 0; - outPortDefs->format.video.xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE << 16; - outPortDefs->format.video.bFlagErrorConcealment = OMX_TRUE; - outPortDefs->format.video.eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat; - outPortDefs->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; -} - - -void OMXVidDec_InitPortParams(OMXVidDecComp *pVidDecComp) -{ - OMX_VIDEO_PARAM_PORTFORMATTYPE *tInPortVideoParam - = &(pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT]); - OMX_VIDEO_PARAM_PORTFORMATTYPE *tOutPortVideoParam - = &(pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT]); - - // Initialize Input Video Port Param - tInPortVideoParam->nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE); - tInPortVideoParam->nVersion = pVidDecComp->sBase.nComponentVersion; - tInPortVideoParam->nPortIndex = OMX_VIDDEC_INPUT_PORT; - tInPortVideoParam->nIndex = 0; - tInPortVideoParam->eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat; - tInPortVideoParam->eColorFormat = OMX_COLOR_FormatUnused; - tInPortVideoParam->xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE; - - // Initialize Output Video Port Param - tOutPortVideoParam->nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE); - tOutPortVideoParam->nVersion = pVidDecComp->sBase.nComponentVersion; - tOutPortVideoParam->nPortIndex = OMX_VIDDEC_OUTPUT_PORT; - tOutPortVideoParam->nIndex = 1; - tOutPortVideoParam->eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat; - tOutPortVideoParam->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; - tOutPortVideoParam->xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE; -} - -void OMXVidDec_InitDecoderParams(OMX_HANDLETYPE hComponent, - OMXVidDecComp *pVidDecComp) -{ - OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = &(pVidDecComp->sBase.pPorts[outPort]->sPortDef); - OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]); - - OMXVidDec_InitPortDefs(hComponent, pVidDecComp); - OMXVidDec_InitPortParams(pVidDecComp); - OMXVidDec_Set2DBuffParams(hComponent, pVidDecComp); - pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; - - pVidDecComp->pDecStaticParams->maxHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT; - pVidDecComp->pDecStaticParams->maxWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH; - - /* Call Decoder Specific function to set Static Params */ - pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams); - return; -} - - -void OMXVidDec_Set2DBuffParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp) -{ - OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT; - OMX_U32 inPort = (OMX_U32)OMX_VIDDEC_INPUT_PORT; - OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]); - OMX_CONFIG_RECTTYPE *p2DInBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[inPort]); - - PaddedBuffParams outBuffParams; - OMX_U32 nFrameWidth, nFrameHeight; - - p2DOutBufAllocParam->nSize = sizeof(OMX_CONFIG_RECTTYPE); - p2DOutBufAllocParam->nVersion = pVidDecComp->sBase.nComponentVersion; - p2DOutBufAllocParam->nPortIndex = outPort; - - nFrameWidth = pVidDecComp->sBase.pPorts[inPort]->sPortDef.format.video.nFrameWidth; - nFrameHeight = pVidDecComp->sBase.pPorts[inPort]->sPortDef.format.video.nFrameHeight; - if( nFrameWidth & 0x0F ) { - nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); - } - if( nFrameHeight & 0x1F ) { - nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); - } - outBuffParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, nFrameWidth, nFrameHeight); - - p2DOutBufAllocParam->nWidth = outBuffParams.nPaddedWidth; - p2DOutBufAllocParam->nHeight = outBuffParams.nPaddedHeight; - p2DOutBufAllocParam->nLeft = outBuffParams.n2DBufferXAlignment; - p2DOutBufAllocParam->nTop = outBuffParams.n2DBufferYAlignment; - - p2DInBufAllocParam->nSize = sizeof(OMX_CONFIG_RECTTYPE); - p2DInBufAllocParam->nVersion = pVidDecComp->sBase.nComponentVersion; - p2DInBufAllocParam->nPortIndex = OMX_VIDDEC_INPUT_PORT; - p2DInBufAllocParam->nWidth = pVidDecComp->sBase.pPorts[inPort]->sPortDef.nBufferSize; - p2DInBufAllocParam->nHeight = 1; //On input port only 1D buffers supported. - p2DInBufAllocParam->nLeft = pVidDecComp->sBase.pPorts[inPort]->sPortDef.nBufferAlignment; - p2DInBufAllocParam->nTop = 1; -} - - -OMX_ERRORTYPE OMXVidDec_HandleFLUSH_EOS(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE *pLastOutBufHeader, - OMX_BUFFERHEADERTYPE *pInBufHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone, eRMError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_BUFFERHEADERTYPE *pDupBufHeader = NULL; - OMXVidDecComp *pVidDecComp = NULL; - OMX_U32 i = 0; - OMX_U32 nStride; - IVIDDEC3_OutArgs *pDecOutArgs = NULL; - OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT; - OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; - XDAS_Int32 status; - uint32_t nActualSize; - IMG_native_handle_t* grallocHandle; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - XDM_Rect activeFrameRegion[2]; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pDecOutArgs = pVidDecComp->pDecOutArgs; - p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]); - - pOutputPortDef = &(pVidDecComp->sBase.pPorts[outPort]->sPortDef); - /*! Ensure that the stride on output portdef structure is more than - the padded width. This is needed in the case where application - sets the Stride less than padded width */ - if( (OMX_U32)pOutputPortDef->format.video.nStride >= - p2DOutBufAllocParam->nWidth ) { - nStride = pOutputPortDef->format.video.nStride; - } else { - nStride = p2DOutBufAllocParam->nWidth; - } - - if( pVidDecComp->nFrameCounter > 0 ) { - /* Call codec flush and call process call until error */ - OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_FLUSH, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_FLUSH failed ....! \n"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - do { - pVidDecComp->tOutBufDesc->numBufs = 0; - pVidDecComp->tInBufDesc->numBufs = 0; - status = VIDDEC3_process(pVidDecComp->pDecHandle, (XDM2_BufDesc *)pVidDecComp->tInBufDesc, - (XDM2_BufDesc *)pVidDecComp->tOutBufDesc, - (VIDDEC3_InArgs *)pVidDecComp->pDecInArgs, - (VIDDEC3_OutArgs *)pVidDecComp->pDecOutArgs); - - /*! In case this is an IPC failure */ - if(status == DCE_EIPC_CALL_FAIL) { - ALOGE("\n Remote Core Communication Failure... \n"); - eError = OMX_ErrorHardware; - pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE; - goto EXIT; - } - - if( status != XDM_EFAIL ) { - /* Send the buffers out */ - i = 0; - while( pDecOutArgs->outputID[i] ) { - pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[i]; - if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { - OSAL_ReadFromPipe(pVidDecComp->pTimeStampStoragePipe, &(pDupBufHeader->nTimeStamp), - sizeof(OMX_TICKS), &(nActualSize), OSAL_NO_SUSPEND); - } - - activeFrameRegion[0] = pDecOutArgs->displayBufs.bufDesc[0].activeFrameRegion; - activeFrameRegion[1].bottomRight.y = (activeFrameRegion[0].bottomRight.y) / 2; - activeFrameRegion[1].bottomRight.x = activeFrameRegion[0].bottomRight.x; - - // Crop rectangle handles the Y and UV buffer offsets - pDupBufHeader->nOffset = 0; - pDupBufHeader->nFilledLen = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3 ) / 2; - - if((pVidDecComp->tCropDimension.nTop != activeFrameRegion[0].topLeft.y - || pVidDecComp->tCropDimension.nLeft != activeFrameRegion[0].topLeft.x) - || (pVidDecComp->tCropDimension.nWidth != (OMX_U32)(activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x) - || pVidDecComp->tCropDimension.nHeight != (OMX_U32)(activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y))) { - pVidDecComp->tCropDimension.nTop = activeFrameRegion[0].topLeft.y; - pVidDecComp->tCropDimension.nLeft = activeFrameRegion[0].topLeft.x; - pVidDecComp->tCropDimension.nWidth = activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x; - pVidDecComp->tCropDimension.nHeight = activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y; - if( pVidDecComp->bUsePortReconfigForCrop == OMX_TRUE ) { - eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventPortSettingsChanged, - OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonOutputCrop, NULL); - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("Port reconfig callback returned error, trying to continue"); - } - } - } - - if( pVidDecComp->bSupportSkipGreyOutputFrames ) { - if( pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_I_FRAME || - pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IDR_FRAME || - pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IP_FRAME || - pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IB_FRAME ) { - pVidDecComp->bSyncFrameReady = OMX_TRUE; - } - } - grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle); - - if( pVidDecComp->bSyncFrameReady == OMX_TRUE ) { - // Send the Output buffer to Base component - pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader); - } - pDecOutArgs->outputID[i] = 0; - i++; - } - i = 0; - while( pDecOutArgs->freeBufID[i] != 0 ) { - pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->freeBufID[i]; - ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; - if( pDupBufHeader ) { - grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader); - } - i++; - } - } - } while( status != XDM_EFAIL ); - } - if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { - OSAL_ClearPipe(pVidDecComp->pTimeStampStoragePipe); - } - if( pLastOutBufHeader != NULL ) { - pLastOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; - grallocHandle = (IMG_native_handle_t*)(pLastOutBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle); - pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_OUTPUT_PORT, pLastOutBufHeader); - } - if( pInBufHeader != NULL ) { - pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_INPUT_PORT, pInBufHeader); - /* Send the EOS event to client */ - pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventBufferFlag, - OMX_VIDDEC_OUTPUT_PORT, OMX_BUFFERFLAG_EOS, NULL); - } - pVidDecComp->nFrameCounter = 0; - if( pVidDecComp->bSupportSkipGreyOutputFrames ) { - pVidDecComp->bSyncFrameReady = OMX_FALSE; - } - pVidDecComp->nOutbufInUseFlag = 0; - pVidDecComp->nFatalErrorGiven = 0; - -EXIT: - if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { - //Clear the pipe, to discard the stale messages - OSAL_ERROR err = OSAL_ClearPipe(pVidDecComp->pTimeStampStoragePipe); - if( err != OSAL_ErrNone ) { - /* if pipe clear fails, nothing can be done, just put error trace */ - OSAL_ErrorTrace("\npipe clear failed"); - } - } - return (eError); -} - -/* ==========================================================================*/ -/** - * @fn Calc_InbufSize() - * This method Calcullates Buffer size given width and - * height of buffer - * - * @param [in] width : Width of the buffer - * @param [in] height : Height of the buffer - * - */ -/* ==========================================================================*/ -OMX_U32 Calc_InbufSize(OMX_U32 width, OMX_U32 height) -{ - return ((width * height * 3) / 2); -} - -OMX_ERRORTYPE OMXVidDec_SetInPortDef(OMX_HANDLETYPE hComponent, - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_VIDEO_CODINGTYPE currentCompressionType, desiredCompressionType; - OMX_U32 nFrameWidth, nFrameHeight; - OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - PaddedBuffParams tOutBufParams; - OMX_U32 i=0; - OMX_U32 bFound = 0; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - /*! Initialize pointers and variables */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - nFrameWidth = pPortDefs->format.video.nFrameWidth; - nFrameHeight = pPortDefs->format.video.nFrameHeight; - if( nFrameWidth & 0x0F ) { - nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); - } - if( nFrameHeight & 0x1F ) { - nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); - } - currentCompressionType = pInputPortDef->format.video.eCompressionFormat; - desiredCompressionType = pPortDefs->format.video.eCompressionFormat; - /*! In case there is change in Compression type */ - if( currentCompressionType != desiredCompressionType ) { - /* De-initialize the current codec */ - pVidDecComp->fpDeinit_Codec(hComponent); - /* Call specific component init depending upon the - eCompressionFormat set. */ - i=0; - while( NULL != DecoderList[i].eCompressionFormat ) { - if( DecoderList[i].eCompressionFormat - == desiredCompressionType ) { - /* Component found */ - bFound = 1; - break; - } - i++; - } - if( bFound == 0 ) { - OSAL_ErrorTrace("Unsupported Compression format given in port definition"); - eError = OMX_ErrorUnsupportedSetting; - goto EXIT; - } - /* Call the Specific Decoder Init function and Initialize Params */ - eError = DecoderList[i].fpDecoderComponentInit(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - OMXVidDec_InitDecoderParams(hComponent, pHandle->pComponentPrivate); - strcpy((char *)pVidDecComp->tComponentRole.cRole, - (char *)DecoderList[i].cRole); - } /* End of if condition for change in codec type */ - - /*! set the Actual values of an Input port */ - pInputPortDef->nBufferCountActual = pPortDefs->nBufferCountActual; - pInputPortDef->format = pPortDefs->format; - pInputPortDef->nBufferSize = Calc_InbufSize(nFrameWidth, nFrameHeight); - pVidDecComp->tCropDimension.nTop = 0; - pVidDecComp->tCropDimension.nLeft = 0; - pVidDecComp->tCropDimension.nWidth = pInputPortDef->format.video.nFrameWidth; - pVidDecComp->tCropDimension.nHeight = pInputPortDef->format.video.nFrameHeight; - - /*! Set o/p port details according to width/height set at i/p Port. */ - pOutputPortDef->format.video.nFrameWidth = pInputPortDef->format.video.nFrameWidth; - pOutputPortDef->format.video.nFrameHeight = pInputPortDef->format.video.nFrameHeight; - pOutputPortDef->format.video.nStride = pInputPortDef->format.video.nFrameWidth; - OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate); - pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * - ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1); - - tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, nFrameWidth, nFrameHeight); - pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin; - pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual; - - /*! Set the Static Params (Decoder Specific) */ - pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams); - pVidDecComp->pDecStaticParams->maxHeight = nFrameHeight; - pVidDecComp->pDecStaticParams->maxWidth = nFrameWidth; - if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) { - pVidDecComp->pDecStaticParams->maxWidth = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; - } - if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) { - pOutputPortDef->nBufferCountActual = pOutputPortDef->nBufferCountMin; - } - -EXIT: - return (eError); - -} - -OMX_ERRORTYPE OMXVidDec_SetOutPortDef(OMXVidDecComp *pVidDecComp, - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - OMX_PTR *pBufParams = NULL; - OMX_U32 nOutPort = OMX_VIDDEC_OUTPUT_PORT; - OMX_U32 nNumBuffers = 0; - - pOutputPortDef = &(pVidDecComp->sBase.pPorts[nOutPort]->sPortDef); - - /*! Set Values to output port based on input parameter */ - pOutputPortDef->nBufferCountActual = pPortDefs->nBufferCountActual; - pOutputPortDef->format = pPortDefs->format; - pOutputPortDef->format.video.nSliceHeight - = pOutputPortDef->format.video.nFrameHeight; - pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * - ((pVidDecComp->t2DBufferAllocParams[nOutPort].nHeight * 3) >> 1); - -EXIT: - return (eError); -} - - -OMX_ERRORTYPE OMXVidDec_HandleFirstFrame(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * *ppInBufHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_U32 nFrameWidth, nFrameHeight, nFrameWidthNew, nFrameHeightNew, nFrameRate, nFrameRateNew; - OMXVidDecComp *pVidDecComp = NULL; - XDAS_Int32 status = 0; - IVIDDEC3_Status *pDecStatus = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; - PaddedBuffParams tOutBufParams; - OMX_BUFFERHEADERTYPE *pInBufHeader; - OMX_BOOL bPortReconfigRequiredForPadding = OMX_FALSE; - OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; - - OMX_BOOL bSendPortReconfigForScale = OMX_FALSE; - OMX_U32 nScale, nScaleRem, nScaleQ16Low, nScaleWidth, nScaleHeight; - OMX_U64 nScaleQ16 = 0; - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); - pVidDecComp->nOutPortReconfigRequired = 0; - p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]); - - /*! Call the Codec Control call to get Status from Codec */ - OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETSTATUS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("Error in Codec Control Call for GETSTATUS"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - if( pVidDecComp->fpHandle_CodecGetStatus != NULL ) { - eError = pVidDecComp->fpHandle_CodecGetStatus(hComponent); - } - pDecStatus = (IVIDDEC3_Status *)(pVidDecComp->pDecStatus); - nFrameWidth = pOutputPortDef->format.video.nFrameWidth; - nFrameHeight = pOutputPortDef->format.video.nFrameHeight; - nFrameWidthNew = (OMX_U32)pDecStatus->outputWidth; - nFrameHeightNew = (OMX_U32)pDecStatus->outputHeight; - nFrameRate = pOutputPortDef->format.video.xFramerate >> 16; - - OMX_CHECK(pVidDecComp->nFrameRateDivisor != 0, OMX_ErrorBadParameter); - nFrameRateNew = (OMX_U32)(pDecStatus->frameRate / pVidDecComp->nFrameRateDivisor); - /*Set 200 as max cap, as if clip with incorrect setting is present in sdcard - it breaks havoc on thumbnail generation */ - if((nFrameRateNew == 0) || (nFrameRateNew > 200)) { - OSAL_ErrorTrace("Codec Returned spurious FrameRate Value - %d Setting Back to - %d", - nFrameRateNew, nFrameRate); - nFrameRateNew = nFrameRate; - } - - if( nFrameWidth & 0x0F ) { - nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); - } - if( nFrameHeight & 0x1F ) { - nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); - } - if( nFrameWidthNew & 0x0F ) { - nFrameWidthNew = nFrameWidthNew + 16 - (nFrameWidthNew & 0x0F); - } - if( nFrameHeightNew & 0x1F ) { - nFrameHeightNew = nFrameHeightNew + 32 - (nFrameHeightNew & 0x1F); - } - if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { - if( pOutputPortDef->format.video.nFrameWidth != p2DOutBufAllocParam->nWidth - || pOutputPortDef->format.video.nFrameHeight != p2DOutBufAllocParam->nHeight ) { - bPortReconfigRequiredForPadding = OMX_TRUE; - } - nFrameWidth = pVidDecComp->pDecStaticParams->maxWidth; - nFrameHeight = pVidDecComp->pDecStaticParams->maxHeight; - } - - /*! Check whether the displayWidth already accounts for any - * difference between the current and new frame width */ - if ( nFrameWidth != nFrameWidthNew && - nFrameWidth == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) { - nFrameWidthNew = nFrameWidth; - } - - tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, - (OMX_U32)pDecStatus->outputWidth, (OMX_U32)pDecStatus->outputHeight); - - /*! Check whether the height and width reported by codec matches - * that of output port */ - if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth - || bPortReconfigRequiredForPadding == OMX_TRUE || - pOutputPortDef->nBufferCountMin < tOutBufParams.nBufferCountMin || - nFrameRate < nFrameRateNew ) { /* Compare the min againt the older min buffer count - since parameters like display delay also gets set according to ref frame. */ - /*! Since the dimensions does not match trigger port reconfig */ - pVidDecComp->nOutPortReconfigRequired = 1; - pVidDecComp->nCodecRecreationRequired = 1; - /* Return back the Input buffer headers Note that the output header - * will be cancelled later so no need to cancel it here */ - if( ppInBufHeader != NULL ) { - pInBufHeader = *(ppInBufHeader); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_VIDDEC_INPUT_PORT, - pInBufHeader); - pInBufHeader = NULL; - } - /*! Change port definition to match with what codec reports */ - pInputPortDef->format.video.nFrameHeight = (OMX_U32)pDecStatus->outputHeight; - pInputPortDef->format.video.nFrameWidth = (OMX_U32)pDecStatus->outputWidth; - pOutputPortDef->format.video.nFrameHeight = (OMX_U32)pDecStatus->outputHeight; - pOutputPortDef->format.video.nFrameWidth = (OMX_U32)pDecStatus->outputWidth; - pOutputPortDef->format.video.nStride = (OMX_U32)pDecStatus->outputWidth; - pOutputPortDef->format.video.nSliceHeight = (OMX_U32)pDecStatus->outputHeight; - if( nFrameRate < nFrameRateNew ) { - pOutputPortDef->format.video.xFramerate = nFrameRateNew << 16; - pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].xFramerate = nFrameRateNew; - } - pVidDecComp->tCropDimension.nWidth = (OMX_U32)pDecStatus->outputWidth; - pVidDecComp->tCropDimension.nHeight = (OMX_U32)pDecStatus->outputHeight; - tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, - (OMX_U32)pDecStatus->outputWidth, - (OMX_U32)pDecStatus->outputHeight); - pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin; - pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual; - OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate); - - pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; - pOutputPortDef->format.video.nSliceHeight = p2DOutBufAllocParam->nHeight; - - pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * - ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1); - if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { - pInputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight; - pInputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth; - pOutputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight; - pOutputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth; - } - } - - if( pVidDecComp->nOutPortReconfigRequired == 1 ) { - /*! Notify to Client change in output port settings */ - eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, - OMX_EventPortSettingsChanged, - OMX_VIDDEC_OUTPUT_PORT, 0, NULL); - } else if( pDecStatus->sampleAspectRatioHeight != 0 && pDecStatus->sampleAspectRatioWidth != 0 ) { - nScaleWidth = (OMX_U32)pDecStatus->sampleAspectRatioWidth; - nScaleHeight = (OMX_U32)pDecStatus->sampleAspectRatioHeight; - nScale = nScaleWidth / nScaleHeight; - if( nScale >= 1 ) { - nScaleRem = nScaleWidth % nScaleHeight; - nScaleQ16Low = 0xFFFF * nScaleRem / nScaleHeight; - nScaleQ16 = nScale << 16; - nScaleQ16 |= nScaleQ16Low; - if( (OMX_U64)pVidDecComp->tScaleParams.xWidth != nScaleQ16 - || pVidDecComp->tScaleParams.xHeight != 0x10000 ) { - pVidDecComp->tScaleParams.xWidth = nScaleQ16; - pVidDecComp->tScaleParams.xHeight = 0x10000; - bSendPortReconfigForScale = OMX_TRUE; - } - } else { - nScale = nScaleHeight / nScaleWidth; - nScaleRem = nScaleHeight % nScaleWidth; - nScaleQ16Low = 0xFFFF * nScaleRem / nScaleWidth; - nScaleQ16 = nScale << 16; - nScaleQ16 |= nScaleQ16Low; - if( pVidDecComp->tScaleParams.xWidth != 0x10000 - || (OMX_U64)pVidDecComp->tScaleParams.xHeight != nScaleQ16 ) { - pVidDecComp->tScaleParams.xWidth = 0x10000; - pVidDecComp->tScaleParams.xHeight = nScaleQ16; - bSendPortReconfigForScale = OMX_TRUE; - } - } - if( bSendPortReconfigForScale == OMX_TRUE ) { - /*! Notify to Client change in output port settings */ - eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, - OMX_EventPortSettingsChanged, OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonScale, NULL); - bSendPortReconfigForScale = OMX_FALSE; - } - } - -EXIT: - return (eError); - -} - -OMX_ERRORTYPE OMXVidDec_HandleCodecProcError(OMX_HANDLETYPE hComponent, - OMX_BUFFERHEADERTYPE * *ppInBufHeader, - OMX_BUFFERHEADERTYPE * *ppOutBufHeader) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_U32 nFrameWidth, nFrameHeight, nFrameWidthNew, nFrameHeightNew; - OMXVidDecComp *pVidDecComp = NULL; - XDAS_Int32 status = 0; - IVIDDEC3_Status *pDecStatus = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; - PaddedBuffParams tOutBufParams; - OMX_BUFFERHEADERTYPE *pInBufHeader = *(ppInBufHeader); - OMX_BUFFERHEADERTYPE *pDupBufHeader; - OMX_BUFFERHEADERTYPE *pNewOutBufHeader = NULL; - OMX_BUFFERHEADERTYPE *pOutBufHeader = *(ppOutBufHeader); - OMX_U32 ii=0; - OMX_U32 nStride =0; - OMX_BOOL bPortReconfigRequiredForPadding = OMX_FALSE; - OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; - IMG_native_handle_t* grallocHandle; - - /* Initialize pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); - pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); - p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]); - - /*! Call the Codec Status function to know cause of error */ - OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); - status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETSTATUS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); - - /* Check whether the Codec Status call was succesful */ - if( status != VIDDEC3_EOK ) { - OSAL_ErrorTrace("VIDDEC3_control XDM_GETSTATUS failed"); - if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader - != pVidDecComp->nDecoderMode ) { - // Return the Input and Output buffer header - grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, - pOutBufHeader); - - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_INPUT_PORT, - pInBufHeader); - /*! Make Input buffer header pointer NULL */ - pInBufHeader = NULL; - } - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - - pDecStatus = (IVIDDEC3_Status *)(pVidDecComp->pDecStatus); - nFrameWidth = pOutputPortDef->format.video.nFrameWidth; - nFrameHeight = pOutputPortDef->format.video.nFrameHeight; - nFrameWidthNew = pDecStatus->outputWidth; - nFrameHeightNew = pDecStatus->outputHeight; - - if( nFrameWidth & 0x0F ) { - nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); - } - if( nFrameHeight & 0x1F ) { - nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); - } - if( nFrameWidthNew & 0x0F ) { - nFrameWidthNew = nFrameWidthNew + 16 - (nFrameWidthNew & 0x0F); - } - if( nFrameHeightNew & 0x1F ) { - nFrameHeightNew = nFrameHeightNew + 32 - (nFrameHeightNew & 0x1F); - } - - if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { - if( pOutputPortDef->format.video.nFrameWidth != p2DOutBufAllocParam->nWidth - || pOutputPortDef->format.video.nFrameHeight != p2DOutBufAllocParam->nHeight ) { - bPortReconfigRequiredForPadding = OMX_TRUE; - } - nFrameWidth = pVidDecComp->pDecStaticParams->maxWidth; - nFrameHeight = pVidDecComp->pDecStaticParams->maxHeight; - } - - /*! Check whether the displayWidth already accounts for any - * difference between the current and new frame width */ - if ( nFrameWidth != nFrameWidthNew && - nFrameWidth == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) { - nFrameWidthNew = nFrameWidth; - } - - /*! Check whether the height and width reported by codec matches - * that of output port */ - if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth - || bPortReconfigRequiredForPadding == OMX_TRUE ) { - pVidDecComp->nOutPortReconfigRequired = 1; - pVidDecComp->nCodecRecreationRequired = 1; - } - - if( pVidDecComp->fpHandle_ExtendedError != NULL ) { - eError = pVidDecComp->fpHandle_ExtendedError(hComponent); - } - - if( pVidDecComp->nOutPortReconfigRequired == 1 ) { - pNewOutBufHeader = (OMX_BUFFERHEADERTYPE *) pVidDecComp->pDecOutArgs->outputID[0]; - if( pNewOutBufHeader != NULL ) { - pVidDecComp->tCropDimension.nWidth = pDecStatus->outputWidth; - pVidDecComp->tCropDimension.nHeight = pDecStatus->outputHeight; - nStride = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nStride; - // Crop rect handles the offsets for Y and UV buffers - pNewOutBufHeader->nOffset = 0; - // FilledLen - pNewOutBufHeader->nFilledLen - = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) / 2; - grallocHandle = (IMG_native_handle_t*)(pNewOutBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle); - pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_OUTPUT_PORT, - pNewOutBufHeader); - } - - if( pVidDecComp->nOutbufInUseFlag == 0 - && (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) { - grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); // This buffer header is freed afterwards. - } else { - pOutBufHeader = NULL; - } - if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) { - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_INPUT_PORT, pInBufHeader); - - while( pVidDecComp->pDecOutArgs->freeBufID[ii] != 0 ) { - pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pVidDecComp->pDecOutArgs->freeBufID[ii++]; - ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; - if( pDupBufHeader != pOutBufHeader && pDupBufHeader != pNewOutBufHeader ) { - grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader); - } - } - } - - /*! Notify to Client change in output port settings */ - eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, - OMX_EventPortSettingsChanged, - OMX_VIDDEC_OUTPUT_PORT, 0, NULL); - } - if( pVidDecComp->nOutPortReconfigRequired == 0 ) { - if( pVidDecComp->pDecOutArgs->extendedError & 0x8000 ) { - eError = OMX_ErrorFormatNotDetected; - if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) { - if( pVidDecComp->nOutbufInUseFlag == 0 ) { - grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); // This buffer header is freed afterwards. - } - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_INPUT_PORT, pInBufHeader); - while( pVidDecComp->pDecOutArgs->freeBufID[ii] != 0 ) { - pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pVidDecComp->pDecOutArgs->freeBufID[ii++]; - ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; - if( pOutBufHeader != pDupBufHeader ) { - grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer); - pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, - (buffer_handle_t)grallocHandle); - pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, - OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader); - } - } - } - pVidDecComp->nFatalErrorGiven = 1; - } - } - - if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth - || bPortReconfigRequiredForPadding == OMX_TRUE ) { - /*Return back the locked buffers before changing the port definition */ - OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL); - /*! Change Port Definition */ - pInputPortDef->format.video.nFrameHeight = pDecStatus->outputHeight; - pInputPortDef->format.video.nFrameWidth = pDecStatus->outputWidth; - - pOutputPortDef->format.video.nFrameHeight = pDecStatus->outputHeight; - pOutputPortDef->format.video.nFrameWidth = pDecStatus->outputWidth; - pOutputPortDef->format.video.nSliceHeight = pDecStatus->outputHeight; - pVidDecComp->tCropDimension.nWidth = pDecStatus->outputWidth; - pVidDecComp->tCropDimension.nHeight = pDecStatus->outputHeight; - tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, - pDecStatus->outputWidth, - pDecStatus->outputHeight); - pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin; - pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual; - OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate); - - pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; - - pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * - ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1); - if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { - pInputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight; - pInputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth; - pOutputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight; - pOutputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth; - pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; - pOutputPortDef->format.video.nSliceHeight = p2DOutBufAllocParam->nHeight; - } - } - -EXIT: - return (eError); -} - -void OMXVidDec_CalcFilledLen(OMX_HANDLETYPE hComponent, - IVIDDEC3_OutArgs *pDecOutArgs, - OMX_U32 nStride) -{ - OMX_BUFFERHEADERTYPE *pOutBufHeader; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXVidDecComp *pVidDecComp = NULL; - - /* Initialize the pointers */ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; - - pOutBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[0]; - /*Crop rectangle handles the offsets for Y and UV buffers */ - pOutBufHeader->nOffset = 0; - - /*! Calcullate the Total Filled length */ - pOutBufHeader->nFilledLen = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) / 2; - - return; -} - - diff --git a/omx/videoencode/Android.mk b/omx/videoencode/Android.mk deleted file mode 100644 index b3b66fc..0000000 --- a/omx/videoencode/Android.mk +++ /dev/null @@ -1,46 +0,0 @@ -LOCAL_PATH:= $(call my-dir) - -# -# libOMX.TI.DUCATI1.VIDEO.H264E -# - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES += \ - frameworks/native/include/media/openmax \ - frameworks/native/include/media/hardware \ - $(LOCAL_PATH)/../base/omx_core/inc \ - $(LOCAL_PATH)/../osal/inc \ - $(LOCAL_PATH)/../base/omx_base_comp/inc \ - $(LOCAL_PATH)/../base/omx_base_dio_plugin/inc \ - hardware/ti/dra7xx/hwcomposer/ \ - hardware/ti/dce/ \ - system/core/include/cutils \ - $(LOCAL_PATH)/omx_h264_enc/inc \ - hardware/ti/dce/packages/codec_engine/ \ - hardware/ti/dce/packages/framework_components/ \ - hardware/ti/dce/packages/ivahd_codecs/ \ - hardware/ti/dce/packages/xdais/ \ - hardware/ti/dce/packages/xdctools - -LOCAL_HEADER_LIBRARIES += libutils_headers - -LOCAL_SHARED_LIBRARIES := \ - libosal \ - libc \ - liblog \ - libOMX \ - libhardware \ - libdce - -LOCAL_CFLAGS += -Dxdc_target_types__=google/targets/arm/std.h -DSUPPORT_ANDROID_FRAMEBUFFER_HAL -DSUPPORT_ANDROID_MEMTRACK_HAL -DBUILDOS_ANDROID -Dxdc__deprecated_types - -LOCAL_MODULE_TAGS:= optional -LOCAL_VENDOR_MODULE := true - -LOCAL_SRC_FILES:= omx_h264_enc/src/omx_H264videoencoder.c \ - omx_h264_enc/src/omx_H264videoencoderutils.c - -LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.H264E - -include $(BUILD_SHARED_LIBRARY) diff --git a/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoder.h b/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoder.h deleted file mode 100644 index c458c46..0000000 --- a/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoder.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#ifndef _OMX_H264VE_COMPONENT_H -#define _OMX_H264VE_COMPONENT_H - -#ifdef _cplusplus -extern "C" { -#endif /* _cplusplus */ - -#include "native_handle.h" -#include <hal_public.h> - -#include "omx_H264videoencoderutils.h" - -#define OMX_VIDENC_NUM_PORTS (2) - -#define OMX_ENGINE_NAME "ivahd_vidsvr" - -typedef struct OMX_H264_LVL_BITRATE { - OMX_VIDEO_AVCLEVELTYPE eLevel; - OMX_U32 nMaxBitRateSupport; -}OMX_H264_LVL_BITRATE; - -typedef struct OMX_MetaDataBuffer { - int type; - void *handle; - //int offset; -}OMX_MetaDataBuffer; - -typedef struct OMX_StoreMetaDataInBuffersParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - OMX_U32 nPortIndex; - OMX_BOOL bStoreMetaData; -}OMX_StoreMetaDataInBuffersParams; - - -/*Android Data structures*/ - -enum Type { - MEDIA_IMAGE_TYPE_UNKNOWN = 0, - MEDIA_IMAGE_TYPE_YUV, -}; - -enum PlaneIndex { - Y = 0, - U, - V, - MAX_NUM_PLANES -}; - -typedef struct PlaneInfo { - uint32_t mOffset; // offset of first pixel of the plane in bytes - // from buffer offset - uint32_t mColInc; // column increment in bytes - uint32_t mRowInc; // row increment in bytes - uint32_t mHorizSubsampling; // subsampling compared to the largest plane - uint32_t mVertSubsampling; // subsampling compared to the largest plane -}PlaneInfo; - -// Structure describing a media image (frame) -// Currently only supporting YUV -typedef struct MediaImage { - int mType; - uint32_t mNumPlanes; // number of planes - uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) - uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) - uint32_t mBitDepth; // useable bit depth - PlaneInfo mPlane[MAX_NUM_PLANES]; -}MediaImage; - -// A pointer to this struct is passed to OMX_GetParameter when the extension -// index for the 'OMX.google.android.index.describeColorFormat' -// extension is given. This method can be called from any component state -// other than invalid. The color-format, frame width/height, and stride/ -// slice-height parameters are ones that are associated with a raw video -// port (input or output), but the stride/slice height parameters may be -// incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will -// be used (while specifying this color format). -// -// The component shall fill out the MediaImage structure that -// corresponds to the described raw video format, and the potentially corrected -// stride and slice-height info. -// -// The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE, -// though most implementations can ignore this difference. When using native buffers, -// the component may change the configured color format to an optimized format. -// Additionally, when allocating these buffers for flexible usecase, the framework -// will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers -// is OMX_TRUE), the component shall fill out the MediaImage information for the -// scenario when these SW-readable/writable buffers are locked using gralloc_lock. -// Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must -// be supported for vendor-specific formats. -// -// For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers -// is OMX_TRUE and the component does not support this color format with native -// buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN. -typedef struct DescribeColorFormatParams { - OMX_U32 nSize; - OMX_VERSIONTYPE nVersion; - // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE - OMX_COLOR_FORMATTYPE eColorFormat; - OMX_U32 nFrameWidth; - OMX_U32 nFrameHeight; - OMX_U32 nStride; - OMX_U32 nSliceHeight; - OMX_BOOL bUsingNativeBuffers; - - // output: fill out the MediaImage fields - MediaImage sMediaImage; -}DescribeColorFormatParams; - - -/* OMX H264 Encoder Component */ -typedef struct OMXH264VideoEncoderComponent { - /* base component handle */ - OMXBaseComp sBase; - - /* codec and engine handles */ - Engine_Handle pCEhandle; - Engine_Error tCEerror; - VIDENC2_Handle pVidEncHandle; - OMX_BOOL bCodecCreate; - OMX_BOOL bCodecCreateSettingsChange; - - /* Encoder static/dynamic/buf args */ - IH264ENC_Params *pVidEncStaticParams; - IH264ENC_DynamicParams *pVidEncDynamicParams; - IH264ENC_Status *pVidEncStatus; - IH264ENC_InArgs *pVidEncInArgs; - IH264ENC_OutArgs *pVidEncOutArgs; - IVIDEO2_BufDesc *pVedEncInBufs; - XDM2_BufDesc *pVedEncOutBufs; - - /* omx component statemachine variables */ - OMX_BOOL bInputPortDisable; - OMX_BOOL bCodecFlush; - PARAMS_UPDATE_STATUS bCallxDMSetParams; - OMX_BOOL bAfterEOSReception; - OMX_BOOL bNotifyEOSEventToClient; - OMX_BOOL bPropagateEOSToOutputBuffer; - OMX_BOOL bSetParamInputIsDone; - - /* codec config handling variables*/ - OMXBase_CodecConfigBuf sCodecConfigData; - OMX_BOOL bSendCodecConfig; - OMX_U32 nCodecConfigSize; - OMX_BOOL bAfterGenHeader; - - /* internal buffer tracking arrays */ - OMX_BUFFERHEADERTYPE **pCodecInBufferArray; - OMXBase_BufHdrPvtData *pCodecInBufferBackupArray; - - /* temporary memory to meet and codec and dce requirements */ - MemHeader *pTempBuffer[2]; - - OMX_BOOL bInputMetaDataBufferMode; - OMX_PTR hCC; - IMG_native_handle_t **pBackupBuffers; - alloc_device_t *mAllocDev; - -} OMXH264VidEncComp; - -OMX_ERRORTYPE OMXH264VE_ComponentInit(OMX_HANDLETYPE hComponent); - -#ifdef _cplusplus -} -#endif /* __cplusplus */ - -#endif /* _OMX_H264VE_COMPONENT_H */ - diff --git a/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoderutils.h b/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoderutils.h deleted file mode 100644 index 9a1541f..0000000 --- a/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoderutils.h +++ /dev/null @@ -1,1130 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#include <string.h> - -#include <OMX_Core.h> -#include <OMX_Component.h> -#include <OMX_TI_Custom.h> - -#include <omx_base.h> -#include <omx_base_utils.h> - -#include <xdc/std.h> -#include <ti/sdo/ce/video2/videnc2.h> -#include <ti/sdo/codecs/h264enc/ih264enc.h> - -/* For Baseline Profile :: FLAG to indicate Constrained Baseline profile in the Bitstream generated by codec -conforming to the H264Standard */ -#define OMX_H264_SET_CONSTRAINT_SET1_FLAG 0x14 -#define OMX_H264_SET_CONSTRAINT_SET1b_FLAG 0x15 -#define OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS 0x0 - -/* OMX Component Version */ -#define OMX_H264VE_COMP_VERSION_MAJOR 1 - -#define OMX_H264VE_COMP_VERSION_MINOR 1 - -#define OMX_H264VE_COMP_VERSION_REVISION 0 - -#define OMX_H264VE_COMP_VERSION_STEP 0 - -/* OMX Component port numbers */ -#define OMX_H264VE_NUM_PORTS (2) - -#define OMX_H264VE_DEFAULT_START_PORT_NUM (0) - -#define OMX_H264VE_INPUT_PORT (0) - -#define OMX_H264VE_OUTPUT_PORT (1) - -/* OMX Component thread related */ -#define OMX_H264VE_DEFAULT_TASKPRIORITY (10) - -#define OMX_H264VE_STACKSIZE (1024 * 100) - -/* OMX Component and Encoder Name */ -#define OMX_H264VE_COMP_NAME "OMX.TI.DUCATI1.VIDEO.H264E" - -#define OMX_H264V_ENCODER_NAME "ivahd_h264enc" - -/* Default Interframe intervals */ -#define OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL (3) - -#define OMX_H264VE_BASELINE_INTERFRAME_INTERVAL (1) - -/* OMX Component Buffer defaults */ -#define OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT (2) - -#define OMX_H264VE_DEFAULT_OUTPUT_BUFFER_COUNT (OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT + 2) - -#define OMX_H264VE_MIN_INPUT_BUFFER_COUNT (OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL) - -#define OMX_H264VE_DEFAULT_INPUT_BUFFER_COUNT (OMX_H264VE_MIN_INPUT_BUFFER_COUNT) - -/* Default Framerate */ -#define OMX_H264VE_DEFAULT_FRAME_RATE (15) - -/* Default Intra Frame Interval */ -#define OMX_H264VE_DEFAULT_INTRAFRAME_INTERVAL (OMX_H264VE_DEFAULT_FRAME_RATE) - -/* Default MaxIntra Frame Interval */ -#define OMX_H264VE_DEFAULT_MAXINTRAFRAME_INTERVAL (0x7FFFFFFF) - -/* Minimum Bitrate */ -#define OMX_H264VE_MIN_BITRATE (16385) //( > 16*1024) - -/* Default Bitrate */ -#define OMX_H264VE_DEFAULT_BITRATE (64000) - -/*Default Frame Width */ -#define OMX_H264VE_DEFAULT_FRAME_WIDTH (176) - -/* Default Frame Height */ -#define OMX_H264VE_DEFAULT_FRAME_HEIGHT (144) - -/* Max Frame width */ -#define OMX_H264VE_MAX_FRAME_WIDTH (1920) - -/* Max Frame Height */ -#define OMX_H264VE_MAX_FRAME_HEIGHT (1088) - -/* Max Inter Frame Interval */ -#define OMX_H264VE_MAX_INTER_FRAME_INTERVAL (OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL) - -/* deafult input buffer size */ -#define OMX_H264VE_DEFAULT_INPUT_BUFFER_SIZE (OMX_H264VE_DEFAULT_FRAME_WIDTH * OMX_H264VE_DEFAULT_FRAME_HEIGHT * 3 / 2) - -/* deafult output buffer size */ -#define OMX_H264VE_DEFAULT_OUTPUT_BUFFER_SIZE (OMX_H264VE_DEFAULT_FRAME_WIDTH * OMX_H264VE_DEFAULT_FRAME_HEIGHT * 3 / 2) -/* Assuming encoded frame size will not exceed this size*/ - -/* deafult Aspect Ratio Height */ -#define OMX_H264VE_DEFAULT_ASPECT_RATIO_HEIGHT (1) - -/* deafult Aspect Ratio Width */ -#define OMX_H264VE_DEFAULT_ASPECT_RATIO_WIDTH (1) - -/* default Qp Settings for I frame */ -#define OMX_H264VE_DEFAULT_QP_IFRAME (28) -#define OMX_H264VE_DEFAULT_QPMAX_IFRAME (36) -#define OMX_H264VE_DEFAULT_QPMIN_IFRAME (10) - -/* default Qp Settings for P frame */ -#define OMX_H264VE_DEFAULT_QP_PFRAME (28) -#define OMX_H264VE_DEFAULT_QPMAX_PFRAME (40) -#define OMX_H264VE_DEFAULT_QPMIN_PFRAME (10) - -/* default Qp Settings for B frame */ -#define OMX_H264VE_DEFAULT_QPOFFSET_BFRAME (4) -#define OMX_H264VE_DEFAULT_QPMAX_BFRAME (44) -#define OMX_H264VE_DEFAULT_QPMIN_BFRAME (10) - -/* default Qp Settings for Chroma */ -#define OMX_H264VE_DEFAULT_QPOFFSET_CHROMA (0) - -/* default Search Range for P */ -#define OMX_H264VE_DEFAULT_HORSEARCH_PFRAME (144) -#define OMX_H264VE_DEFAULT_VERSEARCH_PFRAME (32) - -/* default Search Range for B */ -#define OMX_H264VE_DEFAULT_HORSEARCH_BFRAME (144) -#define OMX_H264VE_DEFAULT_VERSEARCH_BFRAME (16) - -/* default Min and Max Pic Size Ratio. Enables Codec to to chose ratio */ -#define OMX_H264VE_DEFAULT_MINPICSIZERATIO (0) -#define OMX_H264VE_DEFAULT_MAXPICSIZERATIOI (20) // codec default is 640 in Q5 format -#define OMX_H264VE_DEFAULT_MAXPICSIZERATIOP (0) -#define OMX_H264VE_DEFAULT_MAXPICSIZERATIOB (0) - -/* the header size SPS+PPS */ -#define SPS_PPS_HEADER_DATA_SIZE 0x100 - -/* The PARAMS_UPDATE_STATUS enum represents the status of the setconfig call. -* With respect to a process call there are 3 possibilities: -* 1. No params have been changed(no setconfig call has occured) -* 2. Setconfig call has occured but the modified params have not been updated to the codec -* It has been updated only at Ducati -* 3. Setconfig call has occured and the modified params have been updated to the codec -*/ -typedef enum PARAMS_UPDATE_STATUS { - NO_PARAM_CHANGE = 0, - PARAMS_UPDATED_AT_OMX = 1, - PARAMS_UPDATED_AT_CODEC = 2, - PARAMS_UPDATE_STATUS_MAX = 0x7FFFFFFF -} PARAMS_UPDATE_STATUS; - -/* inline functions */ -#define GET_OMX_RC_ALG(_pCompPvtStruct_, _pParamStruct_, _e_) \ - if((_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC) && (_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip == OMX_FALSE)) { \ - ((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate = OMX_Video_ControlRateVariable;\ - _e_=OMX_ErrorNone;\ - } else if((_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY) && (_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip == OMX_FALSE)) { \ - ((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate = OMX_Video_ControlRateConstant;\ - _e_=OMX_ErrorNone;\ - } - -#define SET_H264CODEC_RC_ALG(_pParamStruct_, _pCompPvtStruct_, _e_) \ - if(((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate == OMX_Video_ControlRateVariable ) { \ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_PRC;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\ - _e_=OMX_ErrorNone;\ - } else if(((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate == OMX_Video_ControlRateConstant ) { \ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_PRC_LOW_DELAY;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\ - _e_=OMX_ErrorNone;\ - } else {\ - _e_=OMX_ErrorUnsupportedSetting;\ - } - -#define GET_OMX_AVC_PARAMS(_pCompPvtStruct_, _pParamStruct_) \ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nSliceHeaderSpacing = 0; /* present code doesn't use this value: set to 0 */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nPFrames = (_pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval);\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames = ((_pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval) - 1);\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bUseHadamard = OMX_TRUE; /* Set to OMX_TRUE According to the Spec BUT it is not being Used by the component */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nRefFrames = 1; /* According to the Spec BUT present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nRefIdx10ActiveMinus1 = 1; /* According to Codec Support (2 ref frames for B frame Encoding)but present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nRefIdx11ActiveMinus1 = 1; /* According to Codec Support (2 ref frames for B frame Encoding)but present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableUEP = OMX_FALSE; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableFMO = (((_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset) == IH264_FMOCODING_NONE) ? OMX_FALSE : OMX_TRUE);\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableASO = OMX_FALSE; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableRS = OMX_FALSE; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nAllowedPictureTypes = 3; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bFrameMBsOnly = OMX_TRUE; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bMBAFF = ((_pCompPvtStruct_->pVidEncStaticParams->interlaceCodingType == IH264_INTERLACE_MBAFF) ? OMX_TRUE : OMX_FALSE); /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEntropyCodingCABAC = ((_pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode == IH264_ENTROPYCODING_CABAC) ? OMX_TRUE : OMX_FALSE);\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bWeightedPPrediction = OMX_FALSE; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nWeightedBipredicitonMode = OMX_FALSE; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred = (((_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable) == 0) ? OMX_FALSE : OMX_TRUE);\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bDirect8x8Inference = OMX_FALSE; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bDirectSpatialTemporal = OMX_FALSE; /* present code doesn't use this value */\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nCabacInitIdc = 0; /* present code doesn't use this value */ - - -#define SET_H264CODEC_PARAMS_FROM_AVC(_pParamStruct_, _pCompPvtStruct_) \ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nPFrames;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = (((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames + 1);\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = (((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames + 1);\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableFMO;\ - _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = ((((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEntropyCodingCABAC) ? IH264_ENTROPYCODING_CABAC : IH264_ENTROPYCODING_CAVLC);\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred;\ - if( _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable ) {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\ - } - -#define GET_OMX_AVC_PROFILE(_pCompPvtStruct_, _pParamStruct_, _e_)\ - switch( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile ) {\ - case IH264_BASELINE_PROFILE :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileBaseline;\ - break;\ - case IH264_MAIN_PROFILE :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileMain;\ - break;\ - case IH264_HIGH_PROFILE :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh;\ - break;\ - case IH264_EXTENDED_PROFILE :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileExtended;\ - break;\ - case IH264_HIGH10_PROFILE :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh10;\ - break;\ - case IH264_HIGH422_PROFILE :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh422;\ - break;\ - default :\ - _e_= OMX_ErrorNoMore;\ - break;\ - } - -#define SET_H264CODEC_PROFILE(_pParamStruct_, _pCompPvtStruct_, _e_) \ - switch(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile ) {\ - case OMX_VIDEO_AVCProfileBaseline :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile = IH264_BASELINE_PROFILE;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ - _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_SET_CONSTRAINT_SET1_FLAG;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\ - _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CAVLC;\ - _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\ - break;\ - case OMX_VIDEO_AVCProfileMain :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile =IH264_MAIN_PROFILE;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ - _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ - _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\ - _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\ - break;\ - case OMX_VIDEO_AVCProfileHigh :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile=IH264_HIGH_PROFILE;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\ - _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ - _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\ - _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_ADAPTIVE;\ - break;\ - case OMX_VIDEO_AVCProfileExtended :\ - case OMX_VIDEO_AVCProfileHigh10 :\ - case OMX_VIDEO_AVCProfileHigh422 :\ - default :\ - _e_= OMX_ErrorUnsupportedSetting;\ - break;\ - } - - -#define GET_OMX_AVC_LEVEL(_pCompPvtStruct_, _pParamStruct_, _e_)\ - switch( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level ) {\ - case IH264_LEVEL_10 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel1;\ - break;\ - case IH264_LEVEL_1b :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel1b;\ - break;\ - case IH264_LEVEL_11 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel11;\ - break;\ - case IH264_LEVEL_12 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel12;\ - break;\ - case IH264_LEVEL_13 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel13;\ - break;\ - case IH264_LEVEL_20 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel2;\ - break;\ - case IH264_LEVEL_21 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel21;\ - break;\ - case IH264_LEVEL_22 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel22;\ - break;\ - case IH264_LEVEL_30 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel3;\ - break;\ - case IH264_LEVEL_31 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel31;\ - break;\ - case IH264_LEVEL_32 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel32;\ - break;\ - case IH264_LEVEL_40 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel4;\ - break;\ - case IH264_LEVEL_41 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel41;\ - break;\ - case IH264_LEVEL_42 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel42;\ - break;\ - case IH264_LEVEL_50 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel5;\ - break;\ - case IH264_LEVEL_51 :\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel51;\ - break;\ - default :\ - _e_= OMX_ErrorNoMore;\ - break;\ - } - -#define SET_H264CODEC_LEVEL(_pParamStruct_, _pCompPvtStruct_, _e_)\ - switch(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel ) {\ - case OMX_VIDEO_AVCLevel1 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_10;\ - break;\ - case OMX_VIDEO_AVCLevel1b :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_1b;\ - if (((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile == OMX_VIDEO_AVCProfileBaseline) {\ - _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_SET_CONSTRAINT_SET1b_FLAG;\ - }\ - break;\ - case OMX_VIDEO_AVCLevel11 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_11;\ - break;\ - case OMX_VIDEO_AVCLevel12 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_12;\ - break;\ - case OMX_VIDEO_AVCLevel13 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_13;\ - break;\ - case OMX_VIDEO_AVCLevel2 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_20;\ - break;\ - case OMX_VIDEO_AVCLevel21 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_21;\ - break;\ - case OMX_VIDEO_AVCLevel22 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_22;\ - break;\ - case OMX_VIDEO_AVCLevel3 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_30;\ - break;\ - case OMX_VIDEO_AVCLevel31 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_31;\ - break;\ - case OMX_VIDEO_AVCLevel32 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_32;\ - break;\ - case OMX_VIDEO_AVCLevel4 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_40;\ - break;\ - case OMX_VIDEO_AVCLevel41 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_41;\ - break;\ - case OMX_VIDEO_AVCLevel42 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_42;\ - break;\ - case OMX_VIDEO_AVCLevel5 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_50;\ - break;\ - case OMX_VIDEO_AVCLevel51 :\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_51;\ - break;\ - default :\ - _e_= OMX_ErrorUnsupportedSetting;\ - break;\ - } - -#define GET_OMX_AVC_LFMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\ - if((_pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_NONE) || (_pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_DEFAULT)) {\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_ALL_EDGES ) {\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterDisable;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_SLICE_EDGES ) {\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterDisableSliceBoundary;\ - } else {\ - ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterMax;\ - _e_= OMX_ErrorNoMore;\ - } - - -#define SET_H264CODEC_LFMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\ - if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterEnable ) {\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_NONE;\ - } else if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterDisable ) {\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_ALL_EDGES;\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = 1;\ - } else if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterDisableSliceBoundary ) {\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_SLICE_EDGES;\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = 1;\ - } else {\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_MAX;\ - _e_= OMX_ErrorUnsupportedSetting;\ - } - -#define GET_OMX_FMO_SLIGRPMAPTYPE(_pCompPvtStruct_, _pParamStruct_, _e_)\ - if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_INTERLEAVED_SLICE_GRP ) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 0;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_DISPERSED_SLICE_GRP ) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 1;\ - } else if((_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_SLICE_GRP_MAP_DEFAULT) || (_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_RASTER_SCAN_SLICE_GRP)) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 2;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP ) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 3;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_BOX_OUT_SLICE_GRP ) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 4;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_WIPE_SLICE_GRP ) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 5;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_EXPLICIT_SLICE_GRP ) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 6;\ - } else {\ - _e_= OMX_ErrorNoMore;\ - } - -#define SET_H264CODEC_FMO_SLIGRPMAPTYPE(_pParamStruct_, _pCompPvtStruct_, _e_)\ - if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 0 ) {\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_INTERLEAVED_SLICE_GRP;\ - } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 1 ) {\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_DISPERSED_SLICE_GRP;\ - } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 2 ) {\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_RASTER_SCAN_SLICE_GRP;\ - } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 3 ) {\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP;\ - } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 4 ) {\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_BOX_OUT_SLICE_GRP;\ - } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 5 ) {\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_WIPE_SLICE_GRP;\ - } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 6 ) {\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_EXPLICIT_SLICE_GRP;\ - } else {\ - _e_= OMX_ErrorUnsupportedSetting;\ - } - -#define GET_OMX_FMO_SLICEMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\ - if((_pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_NONE) || (_pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT)) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCDefault;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_MBUNIT ) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCMBSlice;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) {\ - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCByteSlice;\ - } else {\ - _e_= OMX_ErrorNoMore;\ - } - -#define SET_H264CODEC_SLICEMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\ - if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCDefault ) {\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\ - } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCMBSlice ) {\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_MBUNIT;\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset=1;\ - } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCByteSlice ) {\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES;\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = 1;\ - } else {\ - _e_= OMX_ErrorUnsupportedSetting;\ - } - -#define GET_OMX_INTRAREFRESHMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\ - if((_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_NONE) || (_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_DEFAULT) || (_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_MAX)) {\ - ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode = OMX_VIDEO_IntraRefreshMax;\ - ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirMBs = 0;\ - ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirRef = 0;\ - ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nCirMBs = 0;\ - } else if( _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_CYCLIC_MBS ) {\ - ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode = OMX_VIDEO_IntraRefreshAdaptive;\ - ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirMBs = ((_pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth) * (_pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight)) / ((_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate) * 256);\ - ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirRef = 0;\ - ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nCirMBs = 0;\ - } else {\ - _e_= OMX_ErrorNoMore;\ - } - -#define SET_H264CODEC_INTRAREFRESHMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\ - if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode == OMX_VIDEO_IntraRefreshAdaptive ) {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_CYCLIC_MBS;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate = ((_pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth) * (_pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight)) / (((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirMBs * 256);\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_CYCLIC_MBS;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate;\ - } else if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode == OMX_VIDEO_IntraRefreshMax ) {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_NONE;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_NONE;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = 0;\ - } else {\ - _e_= OMX_ErrorUnsupportedSetting;\ - } - - -/*Set the Codec Chroma Format*/ -#define GET_OMX_COLORFORMAT(_pCompPvtStruct_, _e_)\ - if((_pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat == XDM_YUV_420SP)) {\ - _pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;\ - } else {\ - _e_ = OMX_ErrorNoMore; } - -#define SET_H264CODEC_CHROMAFORMAT(_pPortdefStruct_, _pCompPvtStruct_, _e_)\ - if((_pPortdefStruct_->format.video.eColorFormat) == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar ||\ - (_pPortdefStruct_->format.video.eColorFormat) == OMX_COLOR_FormatAndroidOpaque ||\ - (_pPortdefStruct_->format.video.eColorFormat) == OMX_COLOR_FormatYUV420Flexible) {\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat = XDM_YUV_420SP;\ - } else {\ - _e_= OMX_ErrorUnsupportedSetting; } - - -#define SET_H264CODEC_DEFAULT_IVIDENC2_PARAMS(_pCompPvtStruct_, _i_)\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.size = sizeof(IH264ENC_Params);\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.encodingPreset = XDM_USER_DEFINED;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.rateControlPreset = IVIDEO_USER_DEFINED;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.dataEndianness = XDM_BYTE;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxBitRate = -1;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.minBitRate = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat = XDM_YUV_420SP;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType = IVIDEO_PROGRESSIVE;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.operatingMode = IVIDEO_ENCODE_ONLY;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile = IH264_HIGH_PROFILE;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_42;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval =OMX_H264VE_MAX_INTER_FRAME_INTERVAL;\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\ - }\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputDataMode = IVIDEO_ENTIREFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.outputDataMode = IVIDEO_ENTIREFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.numInputDataUnits = 1;\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.numOutputDataUnits = 1;\ - for( _i_ = 0; _i_ < IVIDEO_MAX_NUM_METADATA_PLANES; _i_++ ) {\ - _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.metadataType[_i_] = IVIDEO_METADATAPLANE_NONE;\ - } - - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_RATECONTROLPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rateControlParamsPreset=IH264_RATECONTROLPARAMS_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ - }\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpI = OMX_H264VE_DEFAULT_QP_IFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxI = OMX_H264VE_DEFAULT_QPMAX_IFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinI = OMX_H264VE_DEFAULT_QPMIN_IFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpP = OMX_H264VE_DEFAULT_QP_PFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxP = OMX_H264VE_DEFAULT_QPMAX_PFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinP = OMX_H264VE_DEFAULT_QPMIN_PFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpOffsetB = OMX_H264VE_DEFAULT_QPOFFSET_BFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxB = OMX_H264VE_DEFAULT_QPMAX_BFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinB = OMX_H264VE_DEFAULT_QPMIN_BFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.removeExpensiveCoeff = OMX_FALSE;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.chromaQPIndexOffset = OMX_H264VE_DEFAULT_QPOFFSET_CHROMA;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.IPQualityFactor = IH264_QUALITY_FACTOR_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.HRDBufferSize = OMX_H264VE_DEFAULT_BITRATE;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.initialBufferLevel = pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioI = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioI = OMX_H264VE_DEFAULT_MAXPICSIZERATIOI;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioP = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioP = OMX_H264VE_DEFAULT_MAXPICSIZERATIOP;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioB = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioB = OMX_H264VE_DEFAULT_MAXPICSIZERATIOB;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enablePRC = 1;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enablePartialFrameSkip = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.discardSavedBits = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reserved = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.VBRDuration = 8;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.VBRsensitivity = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.skipDistributionWindowLength = 5;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.numSkipInDistributionWindow = 1;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enableHRDComplianceMode = 1;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.frameSkipThMulQ5 = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.vbvUseLevelThQ5 = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[0] = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[1] = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[2] = 0; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTERCODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset=IH264_INTERCODING_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeHorP = OMX_H264VE_DEFAULT_HORSEARCH_PFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeVerP = OMX_H264VE_DEFAULT_VERSEARCH_PFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeHorB = OMX_H264VE_DEFAULT_HORSEARCH_BFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeVerB = OMX_H264VE_DEFAULT_VERSEARCH_BFRAME;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.meAlgoMode = IH264ENC_MOTIONESTMODE_DEFAULT; - - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTRACODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_DEFAULT;\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x0FF;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x0;\ - } else {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x1F;\ - }\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x0;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x0FF;\ - } else {\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x01F;\ - }\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra16x16Enable = 0xF;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.chromaIntra8x8Enable = 0xF;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.chromaComponentEnable = IH264_CHROMA_COMPONENT_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.gdrOverlapRowsBtwFrames = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingBias = IH264ENC_INTRACODINGBIAS_DEFAULT; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_NALUCONTROLPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskStartOfSequence= 0x01A0;\ - _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIDRPicture = 0x01A0;\ - _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIntraPicture= 0x0002;\ - _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskNonIntraPicture= 0x0002;\ - _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskEndOfSequence= 0x0C00;\ - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SLICECODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceUnitSize = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[0] = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[1] = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[2] = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.streamFormat = IH264_STREAM_FORMAT_DEFAULT; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_LOOPFILTERPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = IH264_LOOPFILTER_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.filterOffsetA = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.filterOffsetB = 0; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_FMOCODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset = IH264_FMOCODING_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.numSliceGroups = 1;\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_SLICE_GRP_MAP_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeDirectionFlag = IH264ENC_SLICEGROUP_CHANGE_DIRECTION_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeRate = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeCycle = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupParams[0] = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupParams[1] = 0; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_VUICODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.vuiCodingPreset = IH264_VUICODING_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.aspectRatioInfoPresentFlag = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.aspectRatioIdc = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoSignalTypePresentFlag = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoFormat = IH264ENC_VIDEOFORMAT_NTSC;\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoFullRangeFlag = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.timingInfoPresentFlag = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.hrdParamsPresentFlag = XDAS_FALSE;\ - _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.numUnitsInTicks = 1000; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOINFOPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.stereoInfoPreset = IH264_STEREOINFO_DISABLE;\ - _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.topFieldIsLeftViewFlag = 1;\ - _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.viewSelfContainedFlag = 0; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOFRAMEPACKINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.framePackingPreset = IH264_FRAMEPACK_SEI_DISABLE;\ - _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.framePackingType = IH264_FRAMEPACK_TYPE_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame0PositionX = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame0PositionY = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame1PositionX = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame1PositionY = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.reservedByte = 0; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SVCCODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.svcExtensionFlag = IH264_SVC_EXTENSION_FLAG_DISABLE;\ - _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.dependencyID = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.qualityID = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.enhancementProfileID = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.layerIndex = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.refLayerDQId = 0; - -#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_EXTENDEDPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->interlaceCodingType = IH264_INTERLACE_FIELDONLY_ARF;\ - _pCompPvtStruct_->pVidEncStaticParams->bottomFieldIntra = OMX_FALSE;\ - _pCompPvtStruct_->pVidEncStaticParams->gopStructure = IH264ENC_GOPSTRUCTURE_DEFAULT;\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CAVLC;\ - } else {\ - _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\ - }\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_HIGH_PROFILE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_ADAPTIVE;\ - } else {\ - _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\ - }\ - _pCompPvtStruct_->pVidEncStaticParams->log2MaxFNumMinus4 = 10;\ - _pCompPvtStruct_->pVidEncStaticParams->picOrderCountType = IH264_POC_TYPE_DEFAULT;\ - _pCompPvtStruct_->pVidEncStaticParams->maxIntraFrameInterval = OMX_H264VE_DEFAULT_MAXINTRAFRAME_INTERVAL;\ - _pCompPvtStruct_->pVidEncStaticParams->enableWatermark = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->IDRFrameInterval = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->pConstantMemory = NULL;\ - _pCompPvtStruct_->pVidEncStaticParams->debugTraceLevel = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->lastNFramesToLog = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->enableAnalyticinfo = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->enableGMVSei = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\ - _pCompPvtStruct_->pVidEncStaticParams->enableRCDO = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->enableLongTermRefFrame = IH264ENC_LTRP_NONE;\ - _pCompPvtStruct_->pVidEncStaticParams->LTRPPeriod = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->numTemporalLayer = IH264_TEMPORAL_LAYERS_1;\ - _pCompPvtStruct_->pVidEncStaticParams->referencePicMarking = IH264_LONG_TERM_PICTURE;\ - _pCompPvtStruct_->pVidEncStaticParams->reservedParams[0] = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->reservedParams[1] = 0;\ - _pCompPvtStruct_->pVidEncStaticParams->reservedParams[2] = 0; - -#define OVERWRITE_H264CODEC_DEFAULT_STATIC_PARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_USERDEFINED;\ - _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIDRPicture = 0x0020;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset= IH264_INTERCODING_USERDEFINED;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_MILD;\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\ - _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_SET_CONSTRAINT_SET1_FLAG;\ - } - -#define ENABLE_4MV(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset = IH264_INTERCODING_USERDEFINED;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8;\ - _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8; - -#define SET_H264CODEC_DEFAULT_IVIDENC2_DYNAMICPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.size = sizeof(IH264ENC_DynamicParams);\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.inputHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.inputWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.refFrameRate = (OMX_H264VE_DEFAULT_FRAME_RATE) * 1000;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = (OMX_H264VE_DEFAULT_FRAME_RATE) * 1000;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_DEFAULT_BITRATE;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval = OMX_H264VE_DEFAULT_INTRAFRAME_INTERVAL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.ignoreOutbufSizeFlag = XDAS_TRUE;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.captureWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_NA_FRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\ - }\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy = IVIDENC2_MOTIONVECTOR_QUARTERPEL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.sampleAspectRatioHeight = OMX_H264VE_DEFAULT_ASPECT_RATIO_HEIGHT;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.sampleAspectRatioWidth = OMX_H264VE_DEFAULT_ASPECT_RATIO_WIDTH;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.putDataFxn = NULL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.putDataHandle = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getDataFxn = NULL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getDataHandle = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getBufferFxn = NULL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getBufferHandle = NULL;\ - _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.lateAcquireArg = -1; - - -#define SET_H264CODEC_DEFAULT_DYNAMIC_RATECONTROLPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ - }\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.rcAlgo = IH264_RATECONTROL_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpI = OMX_H264VE_DEFAULT_QP_IFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxI = OMX_H264VE_DEFAULT_QPMAX_IFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinI = OMX_H264VE_DEFAULT_QPMIN_IFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpP = OMX_H264VE_DEFAULT_QP_PFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxP = OMX_H264VE_DEFAULT_QPMAX_PFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinP = OMX_H264VE_DEFAULT_QPMIN_PFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpOffsetB = OMX_H264VE_DEFAULT_QPOFFSET_BFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxB = OMX_H264VE_DEFAULT_QPMAX_BFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinB = OMX_H264VE_DEFAULT_QPMIN_BFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.allowFrameSkip = OMX_FALSE;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.removeExpensiveCoeff = OMX_FALSE;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.chromaQPIndexOffset = OMX_H264VE_DEFAULT_QPOFFSET_CHROMA;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.IPQualityFactor = IH264_QUALITY_FACTOR_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.HRDBufferSize = OMX_H264VE_DEFAULT_BITRATE;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.initialBufferLevel = pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioI = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioI = OMX_H264VE_DEFAULT_MAXPICSIZERATIOI;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioP = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioP = OMX_H264VE_DEFAULT_MAXPICSIZERATIOP;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioB = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioB = OMX_H264VE_DEFAULT_MAXPICSIZERATIOB;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enablePRC = 1;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enablePartialFrameSkip = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.discardSavedBits = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reserved = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.VBRDuration = 8;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.VBRsensitivity = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.skipDistributionWindowLength = 5;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.numSkipInDistributionWindow = 1;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enableHRDComplianceMode = 1;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.frameSkipThMulQ5 = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.vbvUseLevelThQ5 = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[0] = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[1] = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[2] = 0; - - -#define SET_H264CODEC_DEFAULT_DYNAMIC_INTERCODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.interCodingPreset = IH264_INTERCODING_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeHorP = OMX_H264VE_DEFAULT_HORSEARCH_PFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeVerP = OMX_H264VE_DEFAULT_VERSEARCH_PFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeHorB = OMX_H264VE_DEFAULT_HORSEARCH_BFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeVerB = OMX_H264VE_DEFAULT_VERSEARCH_BFRAME;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.meAlgoMode = IH264ENC_MOTIONESTMODE_DEFAULT; - - -#define SET_H264CODEC_DEFAULT_DYNAMIC_INTRACODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_DEFAULT;\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x0FF;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x0;\ - } else {\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x1F;\ - }\ - if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x0;\ - } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x0FF;\ - } else {\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x01F;\ - }\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra16x16Enable = 0xF;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.chromaIntra8x8Enable = 0xF;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.chromaComponentEnable = IH264_CHROMA_COMPONENT_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.gdrOverlapRowsBtwFrames = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraCodingBias = IH264ENC_INTRACODINGBIAS_DEFAULT; - - -#define SET_H264CODEC_DEFAULT_DYNAMIC_SLICECODINGPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\ - _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[0] = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[1] = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[2] = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.streamFormat = IH264_STREAM_FORMAT_DEFAULT; - - -#define SET_H264CODEC_DEFAULT_DYNAMIC_IH264_EXTENDEDPARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncDynamicParams->sliceGroupChangeCycle = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->searchCenter.x = 0x7FFF;\ - _pCompPvtStruct_->pVidEncDynamicParams->searchCenter.y = 0x7FFF;\ - _pCompPvtStruct_->pVidEncDynamicParams->enableStaticMBCount = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->enableROI = 0;\ - _pCompPvtStruct_->pVidEncDynamicParams->reservedDynParams[0] = 0; - -#define OVERWRITE_H264CODEC_DEFAULT_DYNAMIC_PARAMS(_pCompPvtStruct_)\ - _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_MILD; - - -#define MAP_CODEC_TO_OMX_AVCLEVEL(_InCodecLevel_, _OutOMXLevel_, _nIndex_, _e_)\ - switch( _InCodecLevel_ ) {\ - case IH264_LEVEL_10 :\ - _OutOMXLevel_ = OMX_VIDEO_AVCLevel1;\ - _nIndex_ = 0;\ - break;\ - case IH264_LEVEL_1b :\ - _OutOMXLevel_ = OMX_VIDEO_AVCLevel1b;\ - _nIndex_ = 1;\ - break;\ - case IH264_LEVEL_11 :\ - _OutOMXLevel_ = OMX_VIDEO_AVCLevel11;\ - _nIndex_ = 2;\ - break;\ - case IH264_LEVEL_12 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel12;\ - _nIndex_ = 3;\ - break;\ - case IH264_LEVEL_13 :\ - _OutOMXLevel_ = OMX_VIDEO_AVCLevel13;\ - _nIndex_ = 4;\ - break;\ - case IH264_LEVEL_20 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel2;\ - _nIndex_ = 5;\ - break;\ - case IH264_LEVEL_21 :\ - _OutOMXLevel_=OMX_VIDEO_AVCLevel21;\ - _nIndex_ = 6;\ - break;\ - case IH264_LEVEL_22 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel22;\ - _nIndex_ = 7;\ - break;\ - case IH264_LEVEL_30 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel3;\ - _nIndex_ = 8;\ - break;\ - case IH264_LEVEL_31 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel31;\ - _nIndex_ = 9;\ - break;\ - case IH264_LEVEL_32 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel32;\ - _nIndex_ = 10;\ - break;\ - case IH264_LEVEL_40 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel4;\ - _nIndex_ = 11;\ - break;\ - case IH264_LEVEL_41 :\ - _OutOMXLevel_ = OMX_VIDEO_AVCLevel41;\ - _nIndex_ = 12;\ - break;\ - case IH264_LEVEL_42 :\ - _OutOMXLevel_ = OMX_VIDEO_AVCLevel42;\ - _nIndex_ = 13;\ - break;\ - case IH264_LEVEL_50 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel5;\ - _nIndex_ = 14;\ - break;\ - case IH264_LEVEL_51 :\ - _OutOMXLevel_= OMX_VIDEO_AVCLevel51;\ - _nIndex_ = 15;\ - break;\ - default :\ - _e_= OMX_ErrorNoMore;\ - _nIndex_ = 0xFFFFFFFF;\ - break;\ - } - -/* Error mapping b/n XDM and OMX */ -#define OMX_TI_GET_ERROR(_pCompPvtStruct_, _x_, _e_) \ - _e_ = OMX_ErrorUndefined; \ - if( XDM_ISFATALERROR(_x_)) { /*bit 15*/\ - _e_ = OMX_ErrorUndefined;\ - OSAL_ErrorTrace("Undefined From Codec");\ - }\ - if(((_x_) >> IH264ENC_LEVEL_INCOMPLAINT_PARAMETER) & 0x1 ) { /*bit 0*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Level Incompliant Param Setting");\ - }\ - if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_CONTENTTYPE) & 0x1 ) { /*bit 1*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Profile Incompliant Content type(progressive/Interlace) Setting");\ - }\ - if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_FMO_SETTING) & 0x1 ) { /*bit 2*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Profile Incompliant FMO Param Setting");\ - }\ - if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_TRANSFORMBLOCKSIZE) & 0x1 ) { /*bit 3*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Profile Incompliant Transform Block Size Setting");\ - }\ - if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_INTERFRAMEINTERVAL) & 0x1 ) { /*bit 4*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Profile Incompliant IntraFrame Interval Setting");\ - }\ - if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_SCALINGMATRIXPRESET) & 0x1 ) { /*bit 5*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Profile Incompliant Scaling Matrix Setting");\ - }\ - if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_ENTROPYCODINGMODE) & 0x1 ) { /*bit 6*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Profile Incompliant Entropy Coding Setting");\ - OSAL_ErrorTrace("_or_ Due to violation of slice size (crossing the limit)");\ - }\ - if(((_x_) >> IH264ENC_MAX_BIT_RATE_VOILATION) & 0x1 ) { /*bit 7*/\ - _e_ = OMX_ErrorOverflow;\ - OSAL_ErrorTrace("Max bits for one Unit (1 sec) Voilation");\ - }\ - if(((_x_) >> IH264ENC_IMPROPER_HDVICP2_STATE) & 0x1 ) { /*bit 16*/\ - _e_ = OMX_ErrorHardware;\ - OSAL_ErrorTrace("IVAHD Device is not proper state to use");\ - }\ - if(((_x_) >> IH264ENC_IMPROPER_STREAMFORMAT) & 0x1 ) { /*bit 17*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due To Improper StreamFormat");\ - }\ - if(((_x_) >> IH264ENC_IMPROPER_POCTYPE) & 0x1 ) { /*bit 18*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to InCorrect POC Type");\ - }\ - if(((_x_) >> IH264ENC_IMPROPER_DATASYNC_SETTING) & 0x1 ) { /*bit 19*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Imprper DataSync Settings");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_VIDENC2PARAMS) & 0x1 ) { /*bit 20*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due To Unsupported Videnc2 Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_RATECONTROLPARAMS) & 0x1 ) { /*bit 21*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due To Unsupported Rate Control Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_INTERCODINGPARAMS) & 0x1 ) { /*bit 22*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported Intercoding Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_INTRACODINGPARAMS) & 0x1 ) { /*bit 23*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported Intracoding Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_NALUNITCONTROLPARAMS) & 0x1 ) { /*bit 24*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported NALControl Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_SLICECODINGPARAMS) & 0x1 ) { /*bit 25*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported Slicecoding Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_LOOPFILTERPARAMS) & 0x1 ) { /*bit 26*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported LoopFilter Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_FMOCODINGPARAMS) & 0x1 ) { /*bit 27*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported FMOCoding Params or");\ - OSAL_ErrorTrace("DATASYNC::No of NALs in 1Kb of data is more than 8/ insufficient memory blocks or");\ - OSAL_ErrorTrace("Due to Unsupported setting in N frame process call scenario");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_VUICODINGPARAMS) & 0x1 ) { /*bit 28*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported VUIcoding Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_H264ENCPARAMS) & 0x1 ) { /*bit 29*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported H264ENC Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_VIDENC2DYNAMICPARAMS) & 0x1 ) { /*bit 30*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported VIDENC2DYNAMIC Params");\ - }\ - if(((_x_) >> IH264ENC_UNSUPPORTED_H264ENCDYNAMICPARAMS) & 0x1 ) { /*bit 31*/\ - _e_ = OMX_ErrorUnsupportedSetting;\ - OSAL_ErrorTrace("Due to Unsupported H264ENCDYNAMIC Params");\ - }\ - if( XDM_ISUNSUPPORTEDPARAM(_x_)) { /*bit 14*/\ - _e_ = OMX_ErrorBadParameter;\ - OSAL_ErrorTrace("Due to UnSupported Parameter");\ - }\ - if( XDM_ISUNSUPPORTEDINPUT(_x_)) { /*bit 13*/\ - _e_ = OMX_ErrorBadParameter;\ - OSAL_ErrorTrace("Due to Unsupported Input");\ - }\ - if( XDM_ISCORRUPTEDHEADER(_x_)) { /*bit 12*/\ - _e_ = OMX_ErrorStreamCorrupt;\ - OSAL_ErrorTrace("Due to Corrupt Header");\ - }\ - if( XDM_ISCORRUPTEDDATA(_x_)) { /*bit 11*/\ - _e_ = OMX_ErrorStreamCorrupt;\ - OSAL_ErrorTrace("Due to Corrupted Data");\ - }\ - if( XDM_ISINSUFFICIENTDATA(_x_)) { /*bit 10*/\ - _e_ = OMX_ErrorInsufficientResources;\ - OSAL_ErrorTrace("Due to Insufficient Data");\ - } - -/* Internal functions */ -OMX_ERRORTYPE OMXH264VE_InitFields(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXH264VE_InitialzeComponentPrivateParams(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXH264VE_SetAlgDefaultCreationParams(OMX_HANDLETYPE pHandle); - -OMX_ERRORTYPE OMXH264VE_SetAlgDefaultDynamicParams(OMX_HANDLETYPE pHandle); - -OMX_ERRORTYPE OMXH264VE_SetBufferDesc(OMX_HANDLETYPE pHandle, OMX_U32 nPortIndex); - -OMX_ERRORTYPE OMXH264VE_SetEncCodecReady(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXH264VE_UpdateParams(OMX_HANDLETYPE hComponent); - -/* Buffer statemachine Related*/ -OMX_ERRORTYPE OMXH264VE_FLUSHLockedBuffers(OMX_HANDLETYPE hComponent); -OMX_ERRORTYPE OMXH264VE_GetNextFreeBufHdr(OMX_HANDLETYPE hComponent, OMX_S32 *nBuffIndex, OMX_U32 nPortIndex); -OMX_ERRORTYPE OMXH264VE_GetNumCodecLockedBuffers(OMX_HANDLETYPE hComponent, OMX_U32 *nLockedBuffCount); -OMX_ERRORTYPE OMXH264VE_SetDynamicParamsToCodec(OMX_HANDLETYPE hComponent); - -OMX_ERRORTYPE OMXH264VE_VISACONTROL(VIDENC2_Handle handle, IVIDENC2_Cmd id, IVIDENC2_DynamicParams *dynParams, - IVIDENC2_Status *status, OMX_HANDLETYPE hComponent, XDAS_Int32 *retval); - -OMX_ERRORTYPE OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(OMX_HANDLETYPE hComponent, XDAS_Int32 *retval); - -/* Functions to check the max bit rate supported as per profile & level settings*/ -OMX_ERRORTYPE OMXH264VE_CheckBitRateCap(OMX_U32 targetBitRate, OMX_HANDLETYPE hComponent); - diff --git a/omx/videoencode/omx_h264_enc/src/omx_H264videoencoder.c b/omx/videoencode/omx_h264_enc/src/omx_H264videoencoder.c deleted file mode 100644 index c1312a7..0000000 --- a/omx/videoencode/omx_h264_enc/src/omx_H264videoencoder.c +++ /dev/null @@ -1,2278 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_H264_ENCODER" - -#include <MetadataBufferType.h> -#include "omx_H264videoencoder.h" -#include <OMX_IndexExt.h> -#include <libdce.h> - -#define COLORCONVERT_MAX_SUB_BUFFERS (3) - -#define COLORCONVERT_BUFTYPE_VIRTUAL (0x0) -#define COLORCONVERT_BUFTYPE_ION (0x1) -#define COLORCONVERT_BUFTYPE_GRALLOCOPAQUE (0x2) - -static OMX_ERRORTYPE OMXH264VE_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nParamIndex, - OMX_PTR pParamStruct); - -static OMX_ERRORTYPE OMXH264VE_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nParamIndex, - OMX_PTR pParamStruct); - -static OMX_ERRORTYPE OMXH264VE_GetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pConfigData); - -static OMX_ERRORTYPE OMXH264VE_SetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pConfigData); - -static OMX_ERRORTYPE OMXH264VE_ComponentTunnelRequest(OMX_HANDLETYPE hComponent, - OMX_U32 nPort, - OMX_HANDLETYPE hTunneledComp, - OMX_U32 nTunneledPort, - OMX_TUNNELSETUPTYPE *pTunnelSetup); - -static OMX_ERRORTYPE OMXH264VE_CommandNotify(OMX_HANDLETYPE hComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, - OMX_PTR pCmdData); - -static OMX_ERRORTYPE OMXH264VE_DataNotify(OMX_HANDLETYPE hComponent); - - -static OMX_ERRORTYPE OMXH264VE_ComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); - - -static OMX_ERRORTYPE OMXH264VE_GetExtensionIndex(OMX_HANDLETYPE hComponent, - OMX_STRING cParameterName, - OMX_INDEXTYPE *pIndexType); - - -int COLORCONVERT_PlatformOpaqueToNV12(void *hCC, - void *pSrc[COLORCONVERT_MAX_SUB_BUFFERS], - void *pDst[COLORCONVERT_MAX_SUB_BUFFERS], - int nWidth, int nHeight, int nStride, - int nSrcBufType,int nDstBufType) -{ - IMG_gralloc_module_public_t const* module = hCC; - int nErr = -1; - (void)nStride; - - if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_VIRTUAL)) { - nErr = module->Blit(module, pSrc[0], pDst, HAL_PIXEL_FORMAT_NV12); - } else if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE )) { - nErr = module->Blit2(module, pSrc[0], pDst[0], nWidth, nHeight, 0, 0); - } - - return nErr; -} - -OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OSAL_ERROR tStatus = OSAL_ErrNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - - OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); - - /* Allocate memory for H264VE Component's private data area */ - pHandle->pComponentPrivate = (OMXH264VidEncComp *)OSAL_Malloc(sizeof(OMXH264VidEncComp)); - OMX_CHECK(pHandle->pComponentPrivate != NULL, OMX_ErrorInsufficientResources); - tStatus = OSAL_Memset(pHandle->pComponentPrivate, 0x0, sizeof(OMXH264VidEncComp)); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter); - - /*Initialize the Component Private handle*/ - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - eError= OMXH264VE_InitFields(pHandle); - OMX_CHECK(OMX_ErrorNone == eError, eError); - - /*initialize the Hooks to Notify Command and Data from Base Comp to Derived Comp */ - pH264VEComp->sBase.fpCommandNotify = OMXH264VE_CommandNotify; - pH264VEComp->sBase.fpDataNotify = OMXH264VE_DataNotify; - - /* initialize the base component */ - eError = OMXBase_ComponentInit(hComponent); - OMX_CHECK(OMX_ErrorNone == eError, eError); - - strcpy((char *)pH264VEComp->sBase.pPvtData->cTaskName, "H264VideoEncoder"); - pH264VEComp->sBase.pPvtData->nStackSize = OMX_H264VE_STACKSIZE; - pH264VEComp->sBase.pPvtData->nPrioirty = OMX_H264VE_DEFAULT_TASKPRIORITY; - - /*Setting default properties. PreCondition: NumOfPorts is filled and all pointers allocated*/ - eError = OMXBase_SetDefaultProperties(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); - - /* Override the function pointers of pHandle "OMX_COMPONENTTYPE" - * which Base cannot handle and needs to be taken care by the Dervied comp*/ - pHandle->GetParameter = OMXH264VE_GetParameter; - pHandle->SetParameter = OMXH264VE_SetParameter; - pHandle->SetConfig = OMXH264VE_SetConfig; - pHandle->GetConfig = OMXH264VE_GetConfig; - pHandle->ComponentDeInit = OMXH264VE_ComponentDeinit; - pHandle->GetExtensionIndex = OMXH264VE_GetExtensionIndex; - pHandle->ComponentTunnelRequest = OMXH264VE_ComponentTunnelRequest; - - eError= OMXH264VE_InitialzeComponentPrivateParams(pHandle); - OMX_CHECK(OMX_ErrorNone == eError, eError); - - /* Open the Engine*/ - pH264VEComp->pCEhandle = Engine_open(OMX_ENGINE_NAME, NULL, &pH264VEComp->tCEerror); - if( pH264VEComp->pCEhandle == NULL ) { - OSAL_ErrorTrace("Engine creation: Could not open engine \n"); - eError = OMX_ErrorInsufficientResources; - goto EXIT; - } - - pH264VEComp->bInputMetaDataBufferMode = OMX_FALSE; - pH264VEComp->mAllocDev = NULL; - pH264VEComp->hCC = NULL; - -EXIT: - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace(" H264VE Comp Initialization Failed...! "); - if( pHandle ) { - pHandle->ComponentDeInit(hComponent); - } - } - - return (eError); -} - - -static OMX_ERRORTYPE OMXH264VE_GetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nParamIndex, - OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortParams = NULL; - OMX_VIDEO_PARAM_AVCTYPE *LAVCParams=NULL; - OMX_VIDEO_PARAM_VBSMCTYPE *LVBSMC = NULL; - OMX_STATETYPE nLCurState; - OMX_BOOL bAllocateLocalAVC=OMX_FALSE; - OMX_U32 nPortIndex; - OMX_U32 *pConsumerUsage; - OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef=NULL; - struct DescribeColorFormatParams *Colorparams; - - /* Check all the input parametrs */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - OMX_CHECK(pParamStruct != NULL, OMX_ErrorBadParameter); - - /*initialize the component handle and component pvt handle*/ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - /* Allocate memory for LAVCParams */ - LAVCParams = (OMX_VIDEO_PARAM_AVCTYPE *)OSAL_Malloc(sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - OMX_CHECK(LAVCParams != NULL, OMX_ErrorInsufficientResources); - bAllocateLocalAVC=OMX_TRUE; - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState=pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - /* GetParameter can't be invoked incase the comp is in Invalid State */ - OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation); - - switch( (int) nParamIndex ) { - /* case OMX_IndexParamVideoInit: required for Standard Video Encoder as per Spec & is defined at BASE */ - /* case OMX_IndexParamPortDefinition: required for Standard Video Encoder as per Spec & is defined at BASE */ - /* required for Standard Video Encoder as per Spec .. - client uses this to query the format supported by the port */ - case OMX_IndexParamVideoPortFormat : - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError); - pVideoPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; - /* Retrieving the Input Port params */ - if( pVideoPortParams->nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex ) { - /*Get the compression format*/ - pVideoPortParams->eCompressionFormat = OMX_VIDEO_CodingUnused; - - /*Get the Frame rate : from the codec Dynamic Params...Q16 format*/ - pVideoPortParams->xFramerate = (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate / 1000) << 16; - - /*Get the supported (only 420SP is supported) color formats : from the Codec creation time Params*/ - switch( pVideoPortParams->nIndex ) { - case 0 : - GET_OMX_COLORFORMAT(pH264VEComp, eError); - pVideoPortParams->eColorFormat = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat; - break; - case 1 : - pVideoPortParams->eColorFormat = OMX_COLOR_FormatAndroidOpaque; - break; - case 2: - pVideoPortParams->eColorFormat = OMX_COLOR_FormatYUV420Flexible; - break; - default : - eError = OMX_ErrorNoMore; - break; - } - } - /* Retrieving the Output Port params */ - else if( pVideoPortParams->nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex ) { - - /*Get the Color Format*/ - pVideoPortParams->eColorFormat = OMX_COLOR_FormatUnused; - - /*Get the Frame Rate */ - pVideoPortParams->xFramerate = 0; - - /*Get the Supported CompressionFormats: only AVC is supported*/ - switch( pVideoPortParams->nIndex ) { - case 0 : - pVideoPortParams->eCompressionFormat = OMX_VIDEO_CodingAVC; - break; - default : - eError=OMX_ErrorNoMore; - break; - } - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - /* required for Standard Video Encoder as per Spec & - Client uses this to retrieve the Info related to the AVC rate control type*/ - case OMX_IndexParamVideoBitrate : - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_BITRATETYPE, eError); - if(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - /*Get the Rate Control Algorithm: from the Codec Creation Time Params*/ - GET_OMX_RC_ALG(pH264VEComp, pParamStruct, eError); - - /*Get the Target Bit Rate: from the Codec Dynamic Params*/ - ((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate= - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate; - - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - /* required for Standard Video Encoder as per Spec & - Client uses this to retrieve the Info related to the AVC structure type*/ - case OMX_IndexParamVideoAvc : - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError); - if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - GET_OMX_AVC_PARAMS(pH264VEComp, pParamStruct); - /*Get the Profile value from the Codec Creation Params*/ - GET_OMX_AVC_PROFILE(pH264VEComp, pParamStruct, eError); - - /*Get the level from the Codec Creation Params*/ - GET_OMX_AVC_LEVEL(pH264VEComp, pParamStruct, eError); - - /*get the LoopFilter mode form the Codec Creation Time Params*/ - GET_OMX_AVC_LFMODE(pH264VEComp, pParamStruct, eError); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - /* Client uses this to retrieve the Info related to the Motion vector type*/ - case OMX_IndexParamVideoMotionVector : - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MOTIONVECTORTYPE, eError); - if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - /*Get the MV Accuracy from Codec Dynamic Params*/ - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->eAccuracy = - (OMX_VIDEO_MOTIONVECTORTYPE)pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy; - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bUnrestrictedMVs = OMX_TRUE; /*by Default Codec Supports*/ - /*Number of MVs depend on the min Block size selected*/ - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bFourMV = - (pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_8x8 ? OMX_TRUE : OMX_FALSE); - /*Get the Search Range from the search Range for P Frame*/ - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange = - pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorP; - - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange = - pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerP; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - /* Client uses this to configure Info related to the quantization parameter type*/ - case OMX_IndexParamVideoQuantization : - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_QUANTIZATIONTYPE, eError); - if(((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI = pH264VEComp->pVidEncStaticParams->rateControlParams.qpI; - ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP = pH264VEComp->pVidEncStaticParams->rateControlParams.qpP; - ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB = (pH264VEComp->pVidEncStaticParams->rateControlParams.qpP) - + (pH264VEComp->pVidEncStaticParams->rateControlParams.qpOffsetB); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoSliceFMO : - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCSLICEFMO, eError); - if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nNumSliceGroups = - pH264VEComp->pVidEncStaticParams->fmoCodingParams.numSliceGroups; - - /*get the fmo slice grp type form the Codec Creation Time Params*/ - GET_OMX_FMO_SLIGRPMAPTYPE(pH264VEComp, pParamStruct, eError); - - /*get the slice mode from the Codec Creation Time Params*/ - GET_OMX_FMO_SLICEMODE(pH264VEComp, pParamStruct, eError); - - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoIntraRefresh : - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_INTRAREFRESHTYPE, eError); - if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - GET_OMX_INTRAREFRESHMODE(pH264VEComp, pParamStruct, eError); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - /* required for Standard Video Encoder as per Spec*/ - case OMX_IndexParamVideoProfileLevelCurrent : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - if(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - /*Get the Codec Profile */ - GET_OMX_AVC_PROFILE(pH264VEComp, LAVCParams, eError); - ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile = LAVCParams->eProfile; - - /*Get the Codec level */ - GET_OMX_AVC_LEVEL(pH264VEComp, LAVCParams, eError); - - ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel = LAVCParams->eLevel; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - /* required for Standard Video Encoder as per Spec*/ - case OMX_IndexParamVideoProfileLevelQuerySupported : - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - switch(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nProfileIndex ) { - case 0 : - ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile = OMX_VIDEO_AVCProfileBaseline; - ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel = OMX_VIDEO_AVCLevel51; - break; - case 1 : - ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile=OMX_VIDEO_AVCProfileMain; - ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel=OMX_VIDEO_AVCLevel51; - break; - case 2 : - ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile=OMX_VIDEO_AVCProfileHigh; - ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel=OMX_VIDEO_AVCLevel51; - break; - default : - eError =OMX_ErrorNoMore; - } - OMX_CHECK(OMX_ErrorNone == eError, eError); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoVBSMC : - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState=pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_VBSMCTYPE, eError); - if(((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - LVBSMC = ((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct); - if( pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_8x8 ) { - /*4MV case*/ - LVBSMC->b16x16=OMX_TRUE; - LVBSMC->b16x8=OMX_TRUE; - LVBSMC->b8x16=OMX_TRUE; - LVBSMC->b8x8=OMX_TRUE; - LVBSMC->b8x4=OMX_FALSE; - LVBSMC->b4x8=OMX_FALSE; - LVBSMC->b4x4=OMX_FALSE; - } else if( pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_16x16 ) { - /*1 MV case*/ - /*set the same value for both P & B frames prediction*/ - LVBSMC->b16x16=OMX_TRUE; - LVBSMC->b16x8=OMX_FALSE; - LVBSMC->b8x16=OMX_FALSE; - LVBSMC->b8x8=OMX_FALSE; - LVBSMC->b8x4=OMX_FALSE; - LVBSMC->b4x8=OMX_FALSE; - LVBSMC->b4x4=OMX_FALSE; - } else { - eError = OMX_ErrorNoMore; - } - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamConsumerUsageBits: - //parameter is uint32 - pConsumerUsage = (OMX_U32*)(pParamStruct); - *pConsumerUsage = 0x00; - eError = OMX_ErrorNone; - break; - - case (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat: - Colorparams = (struct DescribeColorFormatParams*)(pParamStruct); - - pInputPortDef = &(pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef); - struct MediaImage *image = &(Colorparams->sMediaImage); - memset(image, 0, sizeof(MediaImage)); - - image->mWidth = pInputPortDef->format.video.nFrameWidth; - image->mHeight = pInputPortDef->format.video.nFrameHeight; - - image->mType = MEDIA_IMAGE_TYPE_YUV; - image->mNumPlanes = 3; - image->mBitDepth = 8; - - image->mPlane[Y].mOffset = 0; - image->mPlane[Y].mColInc = 1; - image->mPlane[Y].mRowInc = pInputPortDef->format.video.nStride; - image->mPlane[Y].mHorizSubsampling = 1; - image->mPlane[Y].mVertSubsampling = 1; - - image->mPlane[U].mOffset = pInputPortDef->format.video.nStride * pInputPortDef->format.video.nFrameHeight; - image->mPlane[U].mColInc = 2; - image->mPlane[U].mRowInc = pInputPortDef->format.video.nStride; - image->mPlane[U].mHorizSubsampling = 2; - image->mPlane[U].mVertSubsampling = 2; - - image->mPlane[V].mOffset = image->mPlane[U].mOffset + 1; - image->mPlane[V].mColInc = 2; - image->mPlane[V].mRowInc = pInputPortDef->format.video.nStride; - image->mPlane[V].mHorizSubsampling = 2; - image->mPlane[V].mVertSubsampling = 2; - - break; - - /* redirects the call to "OMXBase_GetParameter" which supports standard comp indexes */ - default : - eError = OMXBase_GetParameter(hComponent, nParamIndex, pParamStruct); - OMX_CHECK(OMX_ErrorNone == eError, eError); - break; - - } - -EXIT: - if( bAllocateLocalAVC ) { - OSAL_Free(LAVCParams); - } - - return (eError); -} - -static OMX_ERRORTYPE OMXH264VE_SetParameter(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nParamIndex, - OMX_PTR pParamStruct) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortParams = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pPortDef=NULL; - OMX_PARAM_PORTDEFINITIONTYPE *pLocalPortDef=NULL; - OMX_VIDEO_PARAM_AVCTYPE *LAVCParams=NULL; - OMX_VIDEO_PARAM_VBSMCTYPE *LVBSMC = NULL; - OMX_U32 nPortIndex; - OMX_STATETYPE nLCurState; - OMX_BOOL bLCodecCreateFlag=OMX_FALSE; - PARAMS_UPDATE_STATUS bLCallxDMSetParams=NO_PARAM_CHANGE; - OMX_BOOL bAllocateLocalAVC=OMX_FALSE; - - /* Check for the input parameters */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - OMX_CHECK(pParamStruct != NULL, OMX_ErrorBadParameter); - - /*initialize the component handle and component pvt handle*/ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - /* Allocate memory for LAVCParams */ - LAVCParams = (OMX_VIDEO_PARAM_AVCTYPE *)OSAL_Malloc(sizeof(OMX_VIDEO_PARAM_AVCTYPE)); - OMX_CHECK(LAVCParams != NULL, OMX_ErrorInsufficientResources); - bAllocateLocalAVC = OMX_TRUE; - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - /* SetParameter can't be invoked incase the comp is in Invalid State */ - OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation); - - switch( (int) nParamIndex ) { - case OMX_IndexParamVideoInit : - OSAL_Info("In OMX_IndexParamVideoInit"); - /* SetParameter can be invoked only when the comp is in loaded or on a disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - OMX_CHECK((((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber == 0), OMX_ErrorUnsupportedSetting); - OMX_CHECK((((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts == 2), OMX_ErrorUnsupportedSetting); - OSAL_Memcpy(pH264VEComp->sBase.pVideoPortParams, pParamStruct, sizeof(OMX_PORT_PARAM_TYPE)); - break; - - case OMX_IndexParamPortDefinition : - OSAL_Info("In OMX_IndexParamPortDefinition"); - OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, eError); - pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; - nPortIndex = pPortDef->nPortIndex; - - /*check for valid port index */ - OMX_CHECK(nPortIndex < ((pH264VEComp->sBase.pVideoPortParams->nStartPortNumber) + - (pH264VEComp->sBase.pVideoPortParams->nPorts)), OMX_ErrorBadPortIndex); - - /*successful only when the comp is in loaded or on a disabled port*/ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded) || - (pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.bEnabled == OMX_FALSE), - OMX_ErrorIncorrectStateOperation); - pLocalPortDef = &(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef); - - OMX_CHECK((pPortDef->nBufferCountActual >= - pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.nBufferCountMin), OMX_ErrorUnsupportedSetting); - - pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.nBufferCountActual = pPortDef->nBufferCountActual; - /*if frame height/widht changes then change the buffer requirements accordingly*/ - if( nPortIndex == OMX_H264VE_INPUT_PORT ) { - if (pH264VEComp->bInputMetaDataBufferMode) { - pPortDef->format.video.nStride = ALIGN(pPortDef->format.video.nStride, HW_ALIGN); - } - - OMX_CHECK(((pPortDef->format.video.nFrameWidth & 0x0F) == 0), OMX_ErrorUnsupportedSetting); /*Width should be multiple of 16*/ - if( pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) { - OMX_CHECK(((pPortDef->format.video.nFrameHeight & 0x01) == 0), OMX_ErrorUnsupportedSetting); /* Width should be multiple of 16 */ - } else { - OMX_CHECK(((pPortDef->format.video.nFrameHeight & 0x03) == 0), OMX_ErrorUnsupportedSetting); /* Width should be multiple of 16 */ - } - if (pPortDef->format.video.nStride % 16 != 0) { - eError = OMX_ErrorUnsupportedSetting; - break; - } - OMX_CHECK(((OMX_U32)pPortDef->format.video.nStride >= pPortDef->format.video.nFrameWidth), OMX_ErrorUnsupportedSetting); - - OMX_CHECK((pPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) || - (pPortDef->format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) || - (pPortDef->format.video.eColorFormat == OMX_COLOR_FormatYUV420Flexible), - OMX_ErrorUnsupportedSetting); - if((pPortDef->format.video.nFrameWidth < 96) || (pPortDef->format.video.nFrameHeight < 80)) { - eError=OMX_ErrorUnsupportedSetting; - break; - } - SET_H264CODEC_CHROMAFORMAT(pPortDef, pH264VEComp, eError); - - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - // Storing the CLient provided frame rate in internal port def structure for i/p port - if( pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate != pPortDef->format.video.xFramerate) { - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate = - pPortDef->format.video.xFramerate; - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = - (pPortDef->format.video.xFramerate >> 16) * 1000; - } - - if((pLocalPortDef->format.video.nFrameHeight != pPortDef->format.video.nFrameHeight) || - (pLocalPortDef->format.video.nFrameWidth != pPortDef->format.video.nFrameWidth) || - (pLocalPortDef->format.video.nStride != pPortDef->format.video.nStride)) { - pLocalPortDef->format.video.nStride =pPortDef->format.video.nStride; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth = - pPortDef->format.video.nFrameWidth; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight = - pPortDef->format.video.nFrameHeight; - - /*Update the Sliceheight as well*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nSliceHeight = - pPortDef->format.video.nFrameHeight; - - pH264VEComp->pVidEncStaticParams->videnc2Params.maxHeight = pPortDef->format.video.nFrameHeight; - pH264VEComp->pVidEncStaticParams->videnc2Params.maxWidth = pPortDef->format.video.nFrameWidth; - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputWidth = pPortDef->format.video.nFrameWidth; - - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.captureWidth = pPortDef->format.video.nStride; - - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputHeight = pPortDef->format.video.nFrameHeight; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferSize = - (pPortDef->format.video.nFrameHeight * pPortDef->format.video.nFrameWidth * 3 )/2; - - bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - OSAL_Memcpy(&(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.format), &(pPortDef->format), - sizeof(OMX_VIDEO_PORTDEFINITIONTYPE)); - - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = - (pPortDef->format.video.nFrameHeight * pPortDef->format.video.nStride * 3) / 2; - - if (pH264VEComp->bInputMetaDataBufferMode) { - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = sizeof(OMX_MetaDataBuffer); - } - - /* read only field value. update with the frame height.for now codec does not supports the sub frame processing*/ - pLocalPortDef->format.video.nSliceHeight=pPortDef->format.video.nFrameHeight; - - bLCodecCreateFlag = OMX_TRUE; - pH264VEComp->bSetParamInputIsDone = OMX_TRUE; - } - } else { - /*OUTPUT Port*/ - OMX_CHECK((pPortDef->format.video.nFrameWidth == - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth), - OMX_ErrorUnsupportedSetting); - OMX_CHECK((pPortDef->format.video.nFrameHeight == - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight), - OMX_ErrorUnsupportedSetting); - - if( pPortDef->format.video.xFramerate != 0 ) { - OSAL_WarningTrace("Non-zero framerate rate set on o/p port. Setting frame rate is supported only on i/p port"); - pPortDef->format.video.xFramerate = 0; - } - eError = OMXH264VE_CheckBitRateCap(pPortDef->format.video.nBitrate, hComponent); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - OSAL_Memcpy(&(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.format), &(pPortDef->format), - sizeof(OMX_VIDEO_PORTDEFINITIONTYPE)); - - /*Not to modify the read only field value*/ - pLocalPortDef->format.video.nSliceHeight = - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight; - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate; - - if (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate < OMX_H264VE_MIN_BITRATE) { - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_MIN_BITRATE; - } - - OMX_CHECK(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat == - OMX_VIDEO_CodingAVC, OMX_ErrorUnsupportedSetting); - bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX; - } - break; - - /* client uses this to modify the format type of an port */ - case OMX_IndexParamVideoPortFormat : - OSAL_Info("In OMX_IndexParamVideoPortFormat"); - /* SetParameter can be invoked only when the comp is in loaded or on a disabled port */ - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError); - pVideoPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; - nPortIndex = pVideoPortParams->nPortIndex; - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded) || - (pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.bEnabled == OMX_FALSE), - OMX_ErrorIncorrectStateOperation); - /* Specifying the Video port format type params */ - if( nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex ) { - pLocalPortDef = &(pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef); - if((pLocalPortDef->format.video.xFramerate != pVideoPortParams->xFramerate) || - (pLocalPortDef->format.video.eColorFormat != pVideoPortParams->eColorFormat)) { - SET_H264CODEC_CHROMAFORMAT(pLocalPortDef, pH264VEComp, eError); - - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - /*Set the Codec Params accordingly*/ - pLocalPortDef->format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - pLocalPortDef->format.video.xFramerate = pVideoPortParams->xFramerate; - pLocalPortDef->format.video.eColorFormat = pVideoPortParams->eColorFormat; - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = - (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate >> 16) * 1000; - bLCodecCreateFlag = OMX_TRUE; - } - } else if( nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex ) { - pLocalPortDef = &(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef); - /*set the corresponding Portdef fields*/ - if((pLocalPortDef->format.video.xFramerate != pVideoPortParams->xFramerate) || - (pLocalPortDef->format.video.eCompressionFormat != pVideoPortParams->eCompressionFormat)) { - if( pVideoPortParams->xFramerate != 0 ) { - OSAL_ErrorTrace("Non-zero framerate rate set on o/p port. Setting frame rate is supported only on i/p port"); - eError = OMX_ErrorUnsupportedSetting; - goto EXIT; - } - pLocalPortDef->format.video.eCompressionFormat = pVideoPortParams->eCompressionFormat; - pLocalPortDef->format.video.xFramerate = pVideoPortParams->xFramerate; - pLocalPortDef->format.video.eColorFormat = OMX_COLOR_FormatUnused; - OMX_CHECK(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat == - OMX_VIDEO_CodingAVC, OMX_ErrorUnsupportedSetting); - bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - } - } else { - eError = OMX_ErrorBadPortIndex; - break; - } - break; - - /* Client uses this to configure Video Bit rate type and target bit-rate */ - case OMX_IndexParamVideoBitrate : - OSAL_Info("In OMX_IndexParamVideoBitrate"); - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_BITRATETYPE, eError); - if(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - /*check for the rateControlPreset can be set only when it is IVIDEO_USER_DEFINED*/ - if( pH264VEComp->pVidEncStaticParams->videnc2Params.rateControlPreset != IVIDEO_USER_DEFINED ) { - OSAL_ErrorTrace("Rate control preset is not set to User defined"); - eError = OMX_ErrorUnsupportedSetting; - goto EXIT; - } - /*Set the Codec Rate Control Algorithm: */ - SET_H264CODEC_RC_ALG(pParamStruct, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - /*Set the Preset to User Defined*/ - if((((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->eControlRate) != OMX_Video_ControlRateVariable ) { - pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset = 1; //UserDefined - } - eError = OMXH264VE_CheckBitRateCap(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate, hComponent); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - /*Set the Codec Target Bit Rate: from the Codec Dynamic Params*/ - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = - ((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate; - - if (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate < OMX_H264VE_MIN_BITRATE) { - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_MIN_BITRATE; - } - - /*Update the output port bit rate as well...for the get param to reflect the proper values*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate = - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - /* Client uses this to configure AVC structure Parameters*/ - case OMX_IndexParamVideoAvc : - OSAL_Info("In OMX_IndexParamVideoAvc"); - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError); - if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - /*Set the Codec Profile */ - SET_H264CODEC_PROFILE(pParamStruct, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - - /*Set the Codec level */ - SET_H264CODEC_LEVEL(pParamStruct, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - - eError = OMXH264VE_CheckBitRateCap(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate, hComponent); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - - SET_H264CODEC_PARAMS_FROM_AVC(pParamStruct, pH264VEComp); - - /*Set the LoopFilter mode */ - SET_H264CODEC_LFMODE(pParamStruct, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - - /*depending on the interframe interval (nBframes supported) update the buffer requirements */ - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin = - pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval; - if( pH264VEComp->bSetParamInputIsDone == OMX_TRUE ) { - if((pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual) < - (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin)) { - eError=OMX_ErrorBadParameter; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual = - pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval; - OSAL_ErrorTrace("need to set the no of buffers properly (buffactual < min requirement)"); - goto EXIT; - } - } else { - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual = - pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval; - } - OSAL_Info("input port buff actual =%d", pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoMotionVector : - OSAL_Info("In OMX_IndexParamVideoMotionVector"); - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MOTIONVECTORTYPE, eError); - if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - /*Get the MV Accuracy from Codec Dynamic Params*/ - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy = - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->eAccuracy; - /*Number of MVs depend on the min Block size selected*/ - if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bFourMV ) { - pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8; - pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8; - } else { - pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_16x16; - pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_16x16; - } - /*Set the Search Range for P Frame*/ - pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorP = - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange; - pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerP = - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange; - /*Set the Search Range for B Frame*/ - pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorB = - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange; - pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerB = - OMX_H264VE_DEFAULT_VERSEARCH_BFRAME; /*the only supported value by codec*/ - - /*Update the corresponding Dynamic params also*/ - /*Set the Search Range for P Frame*/ - pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeHorP = - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange; - pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeVerP = - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange; - /*Set the Search Range for B Frame*/ - pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeHorB = - ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange; - pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeVerB = - OMX_H264VE_DEFAULT_VERSEARCH_BFRAME; /*the only supported value by codec*/ - pH264VEComp->pVidEncStaticParams->interCodingParams.interCodingPreset = 1; //User Defined - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoQuantization : - OSAL_Info("In OMX_IndexParamVideoQuantization"); - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_QUANTIZATIONTYPE, eError); - if(((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset = - IH264_RATECONTROLPARAMS_USERDEFINED; - pH264VEComp->pVidEncStaticParams->rateControlParams.qpI = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI; - pH264VEComp->pVidEncStaticParams->rateControlParams.qpP = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP; - (pH264VEComp->pVidEncStaticParams->rateControlParams.qpOffsetB) = - ((((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB) - - (((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP)); - - /*Update the corresponding Dynamic params also*/ - pH264VEComp->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset = - IH264_RATECONTROLPARAMS_USERDEFINED; - pH264VEComp->pVidEncDynamicParams->rateControlParams.qpI = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI; - pH264VEComp->pVidEncDynamicParams->rateControlParams.qpP = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP; - (pH264VEComp->pVidEncDynamicParams->rateControlParams.qpOffsetB) = - ((((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB) - - (((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP)); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoSliceFMO : - OSAL_Info("In OMX_IndexParamVideoSliceFMO"); - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCSLICEFMO, eError); - if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - pH264VEComp->pVidEncStaticParams->fmoCodingParams.numSliceGroups = - ((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nNumSliceGroups; - /*Set the slicegrp type*/ - SET_H264CODEC_FMO_SLIGRPMAPTYPE(pParamStruct, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - - /*Set the slicemode*/ - SET_H264CODEC_SLICEMODE(pParamStruct, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - - /*Update the corresponding Dynamic params also*/ - pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode = - pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoIntraRefresh : - OSAL_Info("In OMX_IndexParamVideoIntraRefresh"); - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_INTRAREFRESHTYPE, eError); - if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - //SET_H264CODEC_INTRAREFRESHMODE(pParamStruct, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoVBSMC : - OSAL_Info("In OMX_IndexParamVideoVBSMC"); - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_VBSMCTYPE, eError); - if(((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - LVBSMC = ((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct); - if((LVBSMC->b16x16 == OMX_TRUE) && (LVBSMC->b16x8 == OMX_TRUE) && (LVBSMC->b8x16 == OMX_TRUE) && - (LVBSMC->b8x8 == OMX_TRUE) && (LVBSMC->b8x4 == OMX_FALSE) && (LVBSMC->b4x8 == OMX_FALSE) && - (LVBSMC->b4x4 == OMX_FALSE)) { - /*4MV case*/ - /*set the same value for both P & B frames prediction*/ - pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8; - pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8; - } else if((LVBSMC->b16x16 == OMX_TRUE) && (LVBSMC->b16x8 == OMX_FALSE) && (LVBSMC->b8x16 == OMX_FALSE) && - (LVBSMC->b8x8 == OMX_FALSE) && (LVBSMC->b8x4 == OMX_FALSE) && (LVBSMC->b4x8 == OMX_FALSE) && - (LVBSMC->b4x4 == OMX_FALSE)) { - /*1 MV case*/ - /*set the same value for both P & B frames prediction*/ - pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_16x16; - pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_16x16; - } else { - eError = OMX_ErrorUnsupportedSetting; - } - pH264VEComp->pVidEncStaticParams->interCodingParams.interCodingPreset = 1; //User Defined - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamVideoProfileLevelCurrent : - OSAL_Info("In OMX_IndexParamVideoProfileLevelCurrent"); - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); - if(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - /*Set the Codec Profile */ - LAVCParams->eProfile = (OMX_VIDEO_AVCPROFILETYPE)((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile; - SET_H264CODEC_PROFILE(LAVCParams, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - - /*Set the Codec level */ - LAVCParams->eLevel = (OMX_VIDEO_AVCLEVELTYPE)((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel; - SET_H264CODEC_LEVEL(LAVCParams, pH264VEComp, eError); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexParamStandardComponentRole : - /*Nothing to do Right Now As the Component supports only one Role: AVC*/ - /*if it suppots multiple roles then need to set the params (Component Pvt, Codec Create & Dynamic acordingly*/ - break; - case (OMX_INDEXTYPE)OMX_TI_IndexEncoderReceiveMetadataBuffers: - /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - - struct OMX_StoreMetaDataInBuffersParams *meta = (OMX_StoreMetaDataInBuffersParams *)pParamStruct; - nPortIndex = meta->nPortIndex; - - if (meta->bStoreMetaData) { - if (nPortIndex == OMX_H264VE_INPUT_PORT) { - hw_module_t const* module = NULL; - eError = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); - if (eError == 0) { - pH264VEComp->hCC = (void *) ((IMG_gralloc_module_public_t const *)module); - pH264VEComp->bInputMetaDataBufferMode = OMX_TRUE; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = sizeof(OMX_MetaDataBuffer); - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride = - ALIGN(pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride, HW_ALIGN); - } - } else { - eError = OMX_ErrorUnsupportedSetting; - } - } - break; - - /* redirects the call to "OMXBase_SetParameter" which supports standard comp indexes */ - default : - OSAL_Info("In Default: Call to BASE Set Parameter"); - eError = OMXBase_SetParameter(hComponent, nParamIndex, pParamStruct); - OMX_CHECK(OMX_ErrorNone == eError, eError); - break; - } - - if( bLCodecCreateFlag == OMX_TRUE ) { - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCodecCreateSettingsChange=OMX_TRUE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } - if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) { - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_OMX; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } - -EXIT: - - if( bAllocateLocalAVC ) { - OSAL_Free(LAVCParams); - } - - return (eError); -} - - -static OMX_ERRORTYPE OMXH264VE_GetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pConfigData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_STATETYPE nLCurState; - - /* Check the input params */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - OMX_CHECK(pConfigData != NULL, OMX_ErrorBadParameter); - - /*initialize the component handle and component pvt handle*/ - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - /* GetConfig can't be invoked when the comp is in Invalid state */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation); - - /* Take care of Supported Indexes over here */ - switch( nIndex ) { - /* Client uses this to retrieve the bitrate structure*/ - case OMX_IndexConfigVideoBitrate : - OSAL_Info("In OMX_IndexConfigVideoBitrate"); - /*required for Standard Video Encoder as per Spec*/ - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_BITRATETYPE, eError); - if(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - ((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate = - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigVideoFramerate : - OSAL_Info("In OMX_IndexConfigVideoFramerate"); - /*required for Standard Video Encoder as per Spec*/ - OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_FRAMERATETYPE, eError); - if(((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_INPUT_PORT ) { - ((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate = - (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate << 16) / 1000; /*Q16 format*/ - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - /* Client uses this to configure the intra refresh period */ - case OMX_IndexConfigVideoAVCIntraPeriod : - OSAL_Info("In OMX_IndexConfigVideoAVCIntraPeriod"); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_AVCINTRAPERIOD, eError); - if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod = pH264VEComp->pVidEncStaticParams->IDRFrameInterval; - ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPFrames = - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigVideoIntraVOPRefresh : - OSAL_Info("In OMX_IndexConfigVideoIntraVOPRefresh"); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_INTRAREFRESHVOPTYPE, eError); - if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - ((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->IntraRefreshVOP = - ((pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame == IVIDEO_I_FRAME) ? OMX_TRUE : OMX_FALSE); - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigVideoNalSize : - OSAL_Info("In OMX_IndexConfigVideoNalSize"); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_NALSIZE, eError); - if(((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) { - ((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nNaluBytes = - pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize; - } else { - eError = OMX_ErrorUnsupportedSetting; - } - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigPriorityMgmt : - OSAL_Info("In OMX_IndexConfigPriorityMgmt"); - - default : - OSAL_Info("In Default: Call to BASE GetConfig"); - eError = OMXBase_GetConfig(hComponent, nIndex, pConfigData); - OMX_CHECK(OMX_ErrorNone == eError, eError); - break; - } - -EXIT: - return (eError); - -} - - -static OMX_ERRORTYPE OMXH264VE_SetConfig(OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pConfigData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_STATETYPE nLCurState; - OMX_BOOL bLCodecCreateFlag=OMX_FALSE; - OMX_U32 tStatus; - PARAMS_UPDATE_STATUS bLCallxDMSetParams=NO_PARAM_CHANGE; - - /* Check the input params */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - OMX_CHECK(pConfigData != NULL, OMX_ErrorBadParameter); - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - /* SetConfig can't be invoked when the comp is in Invalid state */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation); - - /* Take care of Supported Indices over here */ - switch( nIndex ) { - case OMX_IndexConfigVideoBitrate : - OSAL_Info("In OMX_IndexConfigVideoBitrate"); - /*required for Standard Video Encoder as per Spec*/ - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_BITRATETYPE, eError); - if(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - eError = OMXH264VE_CheckBitRateCap(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate, hComponent); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = - ((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate; - - if (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate < OMX_H264VE_MIN_BITRATE) { - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_MIN_BITRATE; - } - - /*Update the output port bit rate as well...for the get param to reflect the proper values*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate = - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate; - /*set the HRD biffer size appropriately*/ - if( pH264VEComp->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY ) { - pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize = - (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2; - } else { - pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize = - (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate); - } - bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX; - - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigVideoFramerate : - OSAL_Info("In OMX_IndexConfigVideoFramerate"); - /*required for Standard Video Encoder as per Spec*/ - OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_FRAMERATETYPE, eError); - if(((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_INPUT_PORT ) { - if( pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate != - (((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate)) { - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = - ((((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate) >> 16) * 1000; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate = - (((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate); - bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX; - } - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigVideoAVCIntraPeriod : - OSAL_Info("In OMX_IndexConfigVideoAVCIntraPeriod"); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_AVCINTRAPERIOD, eError); - if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - nLCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - /*If Client want to set the IDR frame Interval */ - if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod != 1 ) { - /*IDR frame Interval is other than the Component default settings - - it is possible only when the component is in loaded state*/ - OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); - pH264VEComp->pVidEncStaticParams->IDRFrameInterval = ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod; - bLCodecCreateFlag = OMX_TRUE; - } - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval = - ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPFrames; - bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigVideoIntraVOPRefresh : - OSAL_Info("In OMX_IndexConfigVideoIntraVOPRefresh"); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_INTRAREFRESHVOPTYPE, eError); - if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->IntraRefreshVOP ) { - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_IDR_FRAME; - } else { - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_NA_FRAME; - } - bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigVideoNalSize : - OSAL_Info("In OMX_IndexConfigVideoNalSize"); - /* Check for the correct nSize & nVersion information */ - OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_NALSIZE, eError); - if(((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT ) { - pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES; - pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_USERDEFINED; - } - if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) { - OMX_CHECK(pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType != IVIDEO_INTERLACED, - OMX_ErrorUnsupportedSetting); - OMX_CHECK(pH264VEComp->pVidEncStaticParams->entropyCodingMode != IH264_ENTROPYCODING_CABAC, - OMX_ErrorUnsupportedSetting); - OMX_CHECK(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputWidth >= 128, - OMX_ErrorUnsupportedSetting); - OMX_CHECK(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval == 1, - OMX_ErrorUnsupportedSetting); - pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize = - ((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nNaluBytes; - - bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - if((nLCurState == OMX_StateLoaded) && (eError == OMX_ErrorNone)) { - if( pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT ) { - pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES; - pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_USERDEFINED; - } - pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceUnitSize = - pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize; - } - } else { - eError = OMX_ErrorUnsupportedSetting; - } - } else { - eError = OMX_ErrorBadPortIndex; - } - break; - - case OMX_IndexConfigPriorityMgmt : - OSAL_ErrorTrace("In OMX_IndexConfigPriorityMgmt"); - - break; - - default : - OSAL_Info("In Default: Call to BASE SetConfig"); - eError = OMXBase_SetConfig(hComponent, nIndex, pConfigData); - OMX_CHECK(OMX_ErrorNone == eError, eError); - break; - } - - if( bLCodecCreateFlag == OMX_TRUE ) { - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCodecCreateSettingsChange = OMX_TRUE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } - - if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) { - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } - -EXIT: - - return (eError); -} - - -static OMX_ERRORTYPE OMXH264VE_CommandNotify(OMX_HANDLETYPE hComponent, - OMX_COMMANDTYPE Cmd, - OMX_U32 nParam, - OMX_PTR pCmdData) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_U32 i; - OMX_STATETYPE tCurState, tNewState; - XDAS_Int32 retval = 0; - (void)pCmdData; - - /* Check the input parameters */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - - /* Complete all the operations like Alg Instance create or - * allocation of any resources which are specific to the Component, Notify this - * Asynchronous event completion to the Base Comp via ReturnEventNotify call*/ - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - tCurState = pH264VEComp->sBase.tCurState; - tNewState = pH264VEComp->sBase.tNewState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - switch( Cmd ) { - case OMX_CommandStateSet : - /* Incase if the comp is moving from loaded to idle */ - if((tCurState == OMX_StateLoaded) && (tNewState == OMX_StateIdle)) { - OSAL_Info("In OMX_CommandStateSet:Loaded to Idle"); - eError = OMXH264VE_SetEncCodecReady(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - - /* Incase if the comp is moving from idle to executing, process buffers if an supplier port */ - else if(((tCurState == OMX_StateIdle) && (tNewState == OMX_StateExecuting)) || - ((tCurState == OMX_StateIdle) && (tNewState == OMX_StatePause))) { - OSAL_Info("In OMX_CommandStateSet:Idle to Executing"); - - pH264VEComp->pCodecInBufferArray = (OMX_BUFFERHEADERTYPE **)OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) * - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual); - OMX_CHECK(pH264VEComp->pCodecInBufferArray != NULL, OMX_ErrorInsufficientResources); - /*allocate the memory for the bufferhdrs*/ - for (i = 0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) { - pH264VEComp->pCodecInBufferArray[i] = NULL; - } - - pH264VEComp->pCodecInBufferBackupArray = (OMXBase_BufHdrPvtData *)OSAL_Malloc(sizeof(OMXBase_BufHdrPvtData) * - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual); - - OMX_CHECK(pH264VEComp->pCodecInBufferBackupArray != NULL, OMX_ErrorInsufficientResources); - } - /* Incase If the comp is moving to Idle from executing, return all the buffers back to the IL client*/ - else if(((tCurState == OMX_StateExecuting) && (tNewState == OMX_StateIdle)) || - ((tCurState == OMX_StatePause) && (tNewState == OMX_StateIdle))) { - OSAL_Info("In OMX_CommandStateSet:Executing/Pause to Idle"); - - /*Flushout all the locked buffers*/ - eError=OMXH264VE_FLUSHLockedBuffers(pHandle); - OMX_CHECK(eError == OMX_ErrorNone, eError); - if( pH264VEComp->bCodecCreate ) { - /*Codec Call: control call with command XDM_RESET*/ - OSAL_Info("Call Codec_RESET "); - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval != VIDENC2_EOK ) { - OSAL_ErrorTrace("Got error from the Codec_RESET call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - - if( pH264VEComp->pCodecInBufferArray ) { - OSAL_Free(pH264VEComp->pCodecInBufferArray); - } - - if (pH264VEComp->bInputMetaDataBufferMode && pH264VEComp->pBackupBuffers) { - for (i = 0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++) { - if(pH264VEComp->pBackupBuffers[i]) { - //unregister this buffer with DRM - dce_buf_unlock(1, (size_t *)&(pH264VEComp->pCodecInBufferBackupArray[i].sMemHdr[0].dma_buf_fd)); - pH264VEComp->mAllocDev->free(pH264VEComp->mAllocDev, (buffer_handle_t)(pH264VEComp->pBackupBuffers[i])); - pH264VEComp->pBackupBuffers[i] = NULL; - } - } - OSAL_Free(pH264VEComp->pBackupBuffers); - pH264VEComp->pBackupBuffers = NULL; - } - - if( pH264VEComp->pCodecInBufferBackupArray ) { - OSAL_Free(pH264VEComp->pCodecInBufferBackupArray); - } - - if(pH264VEComp && pH264VEComp->mAllocDev) { - gralloc_close(pH264VEComp->mAllocDev); - pH264VEComp->mAllocDev = NULL; - } - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->nCodecConfigSize = 0; - pH264VEComp->bAfterGenHeader = OMX_FALSE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - /* Update the Generate Header Params : to continue with New stream w/o codec create */ - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - pH264VEComp->bSendCodecConfig = OMX_TRUE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } - /* State transition from pause to executing state */ - else if((tCurState == OMX_StatePause) && - (tNewState == OMX_StateExecuting)) { - OSAL_Info("In OMX_CommandStateSet:Pause to Executing"); - } else if((tCurState == OMX_StateExecuting) && - (tNewState == OMX_StatePause)) { - } else if((tCurState == OMX_StateIdle) && - (tNewState == OMX_StateLoaded)) { - OSAL_Info("In OMX_CommandStateSet:Idle to Loaded"); - /* Delete the Codec Instance */ - if( pH264VEComp->bCodecCreate && pH264VEComp->pVidEncHandle) { - VIDENC2_delete(pH264VEComp->pVidEncHandle); - pH264VEComp->pVidEncHandle = NULL; - } - pH264VEComp->bCodecCreate=OMX_FALSE; - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_OMX; - pH264VEComp->bSendCodecConfig=OMX_TRUE; - pH264VEComp->bSetParamInputIsDone = OMX_FALSE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } else if( tNewState == OMX_StateInvalid ) { - OSAL_Info("In OMX_CommandStateSet:Invalid state"); - /* Delete the Codec Instance */ - if( pH264VEComp->bCodecCreate && pH264VEComp->pVidEncHandle) { - VIDENC2_delete(pH264VEComp->pVidEncHandle); - pH264VEComp->pVidEncHandle = NULL; - } - pH264VEComp->bCodecCreate=OMX_FALSE; - } - break; - - case OMX_CommandFlush : - OSAL_Info("In OMX_CommandFlush"); - OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)), - OMX_ErrorBadParameter); - if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) { - if( pH264VEComp->bCodecCreate ) { - /*Codec Call: control call with command XDM_FLUSH*/ - OSAL_Info("Call CodecFlush "); - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval != VIDENC2_EOK ) { - OSAL_ErrorTrace("Got error from the CodecFlush call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - /*Flushout all the locked buffers*/ - eError = OMXH264VE_FLUSHLockedBuffers(pHandle); - OMX_CHECK(eError == OMX_ErrorNone, eError); - /* Reset the Codec : to continue with New stream w/o codec create */ - if( pH264VEComp->bCodecCreate ) { - /*Codec Call: control call with command XDM_RESET*/ - OSAL_Info("Call Codec_RESET "); - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval != VIDENC2_EOK ) { - OSAL_ErrorTrace("Got error from the Codec_RESET call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - pH264VEComp->bSendCodecConfig = OMX_TRUE; - pH264VEComp->nCodecConfigSize = 0; - pH264VEComp->bAfterGenHeader = OMX_FALSE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } - if(nParam == OMX_H264VE_OUTPUT_PORT) { - /*do nothing*/ - } - break; - - case OMX_CommandPortDisable : - OSAL_Info("In OMX_CommandPortDisable"); - OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)), - OMX_ErrorBadParameter); - if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) { - if( pH264VEComp->bCodecCreate ) { - /*control call with command XDM_FLUSH*/ - OSAL_Info("Call CodecFlush "); - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval != VIDENC2_EOK ) { - OSAL_ErrorTrace("Got error from the CodecFlush call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - /*Flushout all the locked buffers*/ - eError= OMXH264VE_FLUSHLockedBuffers(pHandle); - OMX_CHECK(eError == OMX_ErrorNone, eError); - /* Reset the Codec : to continue with New stream w/o codec create */ - if( pH264VEComp->bCodecCreate ) { - /*Codec Call: control call with command XDM_RESET*/ - OSAL_Info("Call Codec_RESET "); - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval != VIDENC2_EOK ) { - OSAL_ErrorTrace("Got error from the Codec_RESET call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - pH264VEComp->bInputPortDisable = OMX_TRUE; - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - pH264VEComp->bSendCodecConfig = OMX_TRUE; - pH264VEComp->bSetParamInputIsDone = OMX_FALSE; - pH264VEComp->nCodecConfigSize = 0; - pH264VEComp->bAfterGenHeader = OMX_FALSE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } - if( nParam == OMX_H264VE_OUTPUT_PORT ) { - /*do nothing*/ - } - break; - - case OMX_CommandPortEnable : - OSAL_Info("In OMX_CommandPortEnable"); - /*base is taking care of allocating all the resources*/ - OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)), - OMX_ErrorBadParameter); - if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) { - if((pH264VEComp->bCodecCreate) & (pH264VEComp->bInputPortDisable) & (pH264VEComp->bCodecCreateSettingsChange)) { - /* Delete the old Codec Instance */ - if( pH264VEComp->pVidEncHandle ) { - VIDENC2_delete(pH264VEComp->pVidEncHandle); - pH264VEComp->pVidEncHandle = NULL; - } - - /* Create a New Codec Instance */ - eError = OMXH264VE_SetEncCodecReady(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } /*end if codec create*/ - /*Reset the port disable flag */ - pH264VEComp->bInputPortDisable = OMX_FALSE; - } /*end if(i/p or ALL )*/ - if( nParam == OMX_H264VE_OUTPUT_PORT ) { - /*do nothing*/ - } - break; - - default : - OSAL_Info("In Default"); - eError = OMX_ErrorBadParameter; - OMX_CHECK(eError == OMX_ErrorNone, eError); - break; - } - - /* Note: Notify this completion to the Base comp via ReturnEventNotify call */ - OSAL_Info("Notify Base via ReturnEventNotify "); - eError = pH264VEComp->sBase.fpReturnEventNotify(hComponent, OMX_EventCmdComplete, Cmd, nParam, NULL); - OMX_CHECK(eError == OMX_ErrorNone, eError); - -EXIT: - - return (eError); -} - - -static OMX_ERRORTYPE OMXH264VE_DataNotify(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pComp = NULL; - OMX_BUFFERHEADERTYPE *pOutBufHeader = NULL; - OMX_U32 nInMsgCount = 0, nOutMsgCount = 0, i, j; - XDAS_Int32 retval = 0; - OMX_STATETYPE tCurState; - PARAMS_UPDATE_STATUS bLCallxDMSetParams; - OMX_BOOL bLEOS=OMX_FALSE; - OMX_BOOL bLCodecFlush=OMX_FALSE; - OMX_S32 InBufferHdrIndex = -1; - OMX_U32 LCodecLockedBufferCount = 0; - OMX_BOOL bLCallCodecProcess = OMX_FALSE; - OMXBase_CodecConfigBuf AttrParams; - OMX_BOOL bLSendCodecConfig; - void *srcPtr = NULL, *dstPtr = NULL; - OMX_U32 step, stride; - - /* Check the input parameters */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pComp = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate; - - /* Strat buffer processing only when the comp is in Executing state and the Port are Enabled*/ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - tCurState = pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - if((tCurState == OMX_StateExecuting) && (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bEnabled) - && (pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bEnabled)) { - - eError = pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount); - OMX_CHECK(((eError == OMX_ErrorNone) || (eError == OMX_TI_WarningEosReceived)), OMX_ErrorInsufficientResources); - - eError = pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources); - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - bLSendCodecConfig = pH264VEComp->bSendCodecConfig; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - if( bLSendCodecConfig ) { - if((nOutMsgCount > 0) && (nInMsgCount > 0)) { - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - bLCallxDMSetParams=pH264VEComp->bCallxDMSetParams; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) { - eError = OMXH264VE_SetDynamicParamsToCodec(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; - /* Update the OutBuf details before the Codec Process call */ - pH264VEComp->pVedEncOutBufs->descs[0].memType = XDM_MEMTYPE_RAW; - pH264VEComp->pVedEncOutBufs->descs[0].buf = (XDAS_Int8 *)(pH264VEComp->sCodecConfigData.sBuffer); - pH264VEComp->pVedEncOutBufs->descs[0].bufSize.bytes = SPS_PPS_HEADER_DATA_SIZE; - - /* Update the InBuf details before the Codec Process call */ - for( i = 0; i < (OMX_U32)pH264VEComp->pVedEncInBufs->numPlanes; i++ ) { - pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)(pH264VEComp->pTempBuffer[i]); - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; - pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = - (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes); - } - - /* Update the InArgs details before the Codec Process call */ - pH264VEComp->pVidEncInArgs->videnc2InArgs.size = sizeof(IVIDENC2_InArgs); - pH264VEComp->pVidEncInArgs->videnc2InArgs.control=IVIDENC2_CTRL_NONE; - pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = 1000; /*to overcome the limitation inside the Codec- codec checks for NULL*/ - - /* Update the OutArgs details before the Codec Process call */ - pH264VEComp->pVidEncOutArgs->videnc2OutArgs.size = sizeof(IVIDENC2_OutArgs); - - /* Call the Codec Process call */ - eError = OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(hComponent, &retval); - OMX_CHECK(eError == OMX_ErrorNone, eError); - - ALOGE("BytesGenerated=%d", (OMX_U32)pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated); - ALOGE("freed ID=%d", (OMX_U32)pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]); - - /* Send the Condec Config Data to the Client */ - AttrParams.sBuffer = pH264VEComp->sCodecConfigData.sBuffer; - AttrParams.sBuffer->size = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated; - pH264VEComp->sBase.pPvtData->fpDioControl(pComp, OMX_H264VE_OUTPUT_PORT, OMX_DIO_CtrlCmd_SetCtrlAttribute, &AttrParams); - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_ENCODE_AU; - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bSendCodecConfig =OMX_FALSE; - pH264VEComp->nCodecConfigSize = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated; - pH264VEComp->bAfterGenHeader = OMX_TRUE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - } else { - goto EXIT; - } - } - - /* check for both input and output */ - eError=pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount); - OMX_CHECK(((eError == OMX_ErrorNone) || (eError == OMX_TI_WarningEosReceived)), OMX_ErrorInsufficientResources); - - eError=pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources); - - /* if both are ready-> process data */ - while(((nInMsgCount > 0) && (nOutMsgCount > 0)) || ((pH264VEComp->bAfterEOSReception) && (nOutMsgCount > 0))) { - /*dequeue the output buffer*/ - eError = pH264VEComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR*)(&pOutBufHeader)); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources); - ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC; - - /*branch the control flow based on the Before EOS /After EOS processing*/ - if( !pH264VEComp->bAfterEOSReception ) { - OSAL_Info("Before EOS reception Case"); - /*get the free bufhdr from the inputbufhdrarray*/ - eError = OMXH264VE_GetNextFreeBufHdr(pComp, &InBufferHdrIndex, OMX_H264VE_INPUT_PORT); - OMX_CHECK(((InBufferHdrIndex != -1) && (eError == OMX_ErrorNone)), OMX_ErrorInsufficientResources); - - /*dequeue the input buffer*/ - eError = pH264VEComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_H264VE_INPUT_PORT, - (OMX_PTR*)&(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])); - OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources); - ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->bufSt = OWNED_BY_CODEC; - - if((pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])->nFlags & OMX_BUFFERFLAG_EOS ) { - bLEOS = OMX_TRUE; - pH264VEComp->bPropagateEOSToOutputBuffer = OMX_TRUE; - bLCodecFlush = OMX_TRUE; - } - - if(((pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])->nFilledLen) == 0 ) { - /*update the buffer status to free & return the buffer to the client*/ - ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->bufSt = OWNED_BY_US; - - pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT, - (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])); - - ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US; - - pH264VEComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); - if( bLEOS ) { - bLCallCodecProcess = OMX_FALSE; - } else { - OSAL_ErrorTrace("++++++++Input Buffer Sent with no DATA & no EOS flag++++++++++++"); - goto CHECKCOUNT; - } - } else { - /* Update the Input buffer details before the Codec Process call */ - for( i = 0; i < (OMX_U32)pH264VEComp->pVedEncInBufs->numPlanes; i++ ) { - if( i == 0 ) { - if (pH264VEComp->bInputMetaDataBufferMode) { - OMX_U32 *pTempBuffer; - OMX_U32 nMetadataBufferType; - IMG_native_handle_t* pGrallocHandle=NULL; - pTempBuffer = (OMX_U32 *) (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pBuffer); - nMetadataBufferType = *pTempBuffer; - if(nMetadataBufferType == kMetadataBufferTypeGrallocSource){ - buffer_handle_t tBufHandle; - pTempBuffer++; - tBufHandle = *((buffer_handle_t *)pTempBuffer); - pGrallocHandle = (IMG_native_handle_t*) tBufHandle; - if (pGrallocHandle->iFormat != HAL_PIXEL_FORMAT_NV12) { - if (pH264VEComp->pBackupBuffers == NULL) { - /* Open gralloc allocator and allocate the backup buffers */ - gralloc_open(pH264VEComp->hCC, &(pH264VEComp->mAllocDev)); - OMX_CHECK(pH264VEComp->mAllocDev != NULL, OMX_ErrorInsufficientResources); - - pH264VEComp->pBackupBuffers = (IMG_native_handle_t **)OSAL_Malloc(sizeof(IMG_native_handle_t*) * - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual); - OMX_CHECK(pH264VEComp->pBackupBuffers != NULL, OMX_ErrorInsufficientResources); - - for (j = 0; j < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; j++ ) { - pH264VEComp->pBackupBuffers[j] = NULL; - int err = pH264VEComp->mAllocDev->alloc(pH264VEComp->mAllocDev, - (int) pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - (int) pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - (int) HAL_PIXEL_FORMAT_NV12, (int) GRALLOC_USAGE_HW_RENDER, - (buffer_handle_t *)(&(pH264VEComp->pBackupBuffers[j])), (int *) &stride); - OMX_CHECK(err == 0, err); - - //Get the DMA BUFF_FDs from the gralloc pointers - pH264VEComp->pCodecInBufferBackupArray[j].sMemHdr[0].dma_buf_fd = (OMX_U32)((pH264VEComp->pBackupBuffers[j])->fd[0]); - //register this buffer with DRM - dce_buf_lock(1, (size_t *)&(pH264VEComp->pCodecInBufferBackupArray[j].sMemHdr[0].dma_buf_fd)); - } - } - - /* Invoke color conversion routine here */ - COLORCONVERT_PlatformOpaqueToNV12(pH264VEComp->hCC, (void **) &pGrallocHandle, - (void **) &pH264VEComp->pBackupBuffers[InBufferHdrIndex], - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight, - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth, - COLORCONVERT_BUFTYPE_GRALLOCOPAQUE, - COLORCONVERT_BUFTYPE_GRALLOCOPAQUE ); - - - pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0].offset = (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->nOffset); - - pH264VEComp->pVedEncInBufs->planeDesc[i].buf = - (XDAS_Int8 *)&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0]); - - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_TILEDPAGE; - } - else { - pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0].dma_buf_fd = (OMX_U32)(pGrallocHandle->fd[0]); - pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0].offset = (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->nOffset); - - pH264VEComp->pVedEncInBufs->planeDesc[i].buf = - (XDAS_Int8 *)&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0]); - - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_TILEDPAGE; - } - } - } else { - ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0].offset = (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->nOffset); - - pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0]); - - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; - } - pH264VEComp->pVedEncInBufs->imagePitch[0] = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride; - pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->pVedEncInBufs->imagePitch[0]) * (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight); - - } else if( i == 1 ) { - if (pH264VEComp->bInputMetaDataBufferMode) { - //Nothing to be done; color conversion and fd xlation is done during the plane0 processing - memcpy(&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1]), &(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0]), sizeof(MemHeader)); - - pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1].offset = - ((pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride) * - (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight)); - - pH264VEComp->pVedEncInBufs->planeDesc[i].buf = - (XDAS_Int8 *)&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1]); - - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_TILEDPAGE; - } else { - memcpy(&((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[1], &((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0], sizeof(MemHeader)); - - ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[1].offset = ((pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride) * (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight)); - - pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[1]); - - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; - } - pH264VEComp->pVedEncInBufs->imagePitch[1] = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride; - pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->pVedEncInBufs->imagePitch[1]) * (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight) / 2; - - } else { - eError = OMX_ErrorUnsupportedSetting; - OSAL_ErrorTrace("only NV12 is supproted currently; wrong param from Codec"); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - } - bLCallCodecProcess=OMX_TRUE; - } - } else { - OSAL_Info("After EOS reception Case"); - eError = OMXH264VE_GetNumCodecLockedBuffers(pComp, &LCodecLockedBufferCount); - OMX_CHECK(eError == OMX_ErrorNone, eError); - if( LCodecLockedBufferCount > 0 ) { - /*After EOS reception No need to provide Input for the Process, hence passing tempbuffers*/ - for( i = 0; i < (OMX_U32)pH264VEComp->pVedEncInBufs->numPlanes; i++ ) { - pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)(pH264VEComp->pTempBuffer[i]); - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; - pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = - (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes); - } - bLCallCodecProcess=OMX_TRUE; - } else { - /*Update the OutBufHeader*/ - pOutBufHeader->nOffset = 0; - pOutBufHeader->nFilledLen = 0; - pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; - pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); - pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE; - /*notify the EOSEvent to the client*/ - pH264VEComp->bNotifyEOSEventToClient = OMX_TRUE; - bLCallCodecProcess = OMX_FALSE; - } - } - if( bLCallCodecProcess ) { - if( !pH264VEComp->bAfterEOSReception ) { - OSAL_Info("update the Dynamic params before Process"); - /* Call to xDM Set Params depending on the pH264VEComp->bCallxDMSetParams flag status before the process call */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - bLCallxDMSetParams = pH264VEComp->bCallxDMSetParams; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) { - eError = OMXH264VE_SetDynamicParamsToCodec(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - } - /* Update the Output buffer details before the Codec Process call */ - OSAL_Info("Update the Output buffer details before the Codec Process call"); - /*Note: this implementation assumes - a) output buffer is always 1D - b) if in case of multiple output buffers that need to given to codec for each process call - they are allocated in contiguous memory - */ - if( pH264VEComp->pVedEncOutBufs->numBufs != 1 ) { - eError = OMX_ErrorUnsupportedSetting; - OSAL_ErrorTrace("Encoder Output Buffer is assigned as 2D Buffer"); - goto EXIT; - } - - pH264VEComp->pVedEncOutBufs->descs[0].buf = - (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]); - - pH264VEComp->pVedEncOutBufs->descs[0].bufSize.bytes = pOutBufHeader->nAllocLen; - - /* Update the InArgs details before the Codec Process call */ - OSAL_Info("Update the InArgs before the Codec Process call"); - pH264VEComp->pVidEncInArgs->videnc2InArgs.size = sizeof(IH264ENC_InArgs); - pH264VEComp->pVidEncInArgs->videnc2InArgs.control = IVIDENC2_CTRL_NONE; - - if( !pH264VEComp->bAfterEOSReception ) { - pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = InBufferHdrIndex + 1; - /*Zero is not a valid input so increasing the bufferIndex value by 1*/ - } else { - pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = 0; /*Zero is not a valid input */ - } - - pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] = 0; - /* Update the OutArgs details before the Codec Process call */ - OSAL_Info("Update the OutArgs before the Codec Process call"); - pH264VEComp->pVidEncOutArgs->videnc2OutArgs.size = sizeof(IVIDENC2_OutArgs); - - /* Codec Process call */ - eError = OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(hComponent, &retval); - OMX_CHECK(eError == OMX_ErrorNone, eError); - - /* Send the input & corresponding output buffers Back to the Client when the codec frees */ - /*Note: implementation is based on - a) after every process, there will be at max one input buffer that can be freed - b)for every input buffer that is freed ......there will be corresponding o/p buffer - */ - if( pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]) { - /*Non Zero ID : valid free buffer ID*/ - ALOGE("Codec freed input buffer with ID =%d", (OMX_U32)pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]); - - /* Propagate the Time Stamps from input to Corresponding Output */ - OSAL_Info("Propagate the timestamp"); - pOutBufHeader->nTimeStamp = - (pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)])->nTimeStamp; - - /* Send the input buffers Back to the Client */ - pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]->nFilledLen = 0; - /*Completely Consumed*/ - pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]->nOffset = 0; - - ((OMXBase_BufHdrPvtData *)((pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)])->pPlatformPrivate))->bufSt = OWNED_BY_US; - - pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT, - pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]); - /*check for the EOS */ - if( pH264VEComp->bPropagateEOSToOutputBuffer ) { - /*Send the Output with EOS after sending all the previous buffers*/ - eError = OMXH264VE_GetNumCodecLockedBuffers(pComp, &LCodecLockedBufferCount); - OMX_CHECK(eError == OMX_ErrorNone, eError); - if(LCodecLockedBufferCount == 0) { - /*No locked buffers*/ - pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; - pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE; - } - } - - /* Check for IDR frame & update the Output BufferHdr Flags */ - if(((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.encodedFrameType) == IVIDEO_IDR_FRAME) || - ((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.encodedFrameType) == IVIDEO_I_FRAME)) { - pOutBufHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; - } - - /* Send the output buffers Back to the Client */ - OSAL_Info("Send the output buffers Back to the Client"); - /*Update the OutBufHeader*/ - if( pH264VEComp->bAfterGenHeader ) { - pOutBufHeader->nOffset = pH264VEComp->nCodecConfigSize; - pOutBufHeader->nFilledLen = ((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated) - - (pH264VEComp->nCodecConfigSize)); - pH264VEComp->bAfterGenHeader = OMX_FALSE; - pH264VEComp->nCodecConfigSize = 0; - } else { - pOutBufHeader->nOffset = 0; - pOutBufHeader->nFilledLen = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated; - } - /* Return this output buffer to the Base comp via ReturnDataNotify call - * to communciate with the IL client incase of Non-Tunneling or tunneled - * component in case of tunneling*/ - ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US; - pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); - } else { - if( pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated == 0 ) { - /*free ID ==0 so no inputbuffer is freed & thus no o/p should be generated*/ - OSAL_Info("codec locked the buffer so do the DIO_Cancel for the outputbuffer"); - OSAL_Info("bytes generated is Zero & retain the output buffers via DIO_Cancel"); - ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US; - pH264VEComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); - } else { - if((!pH264VEComp->bAfterEOSReception) || - ((pH264VEComp->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskEndOfSequence) == 0x0)) { - OSAL_ErrorTrace("***********something gone wrong***********"); - goto EXIT; - } - /* Send the output buffers Back to the Client */ - OSAL_Info("Send the output buffers Back to the Client"); - /*Update the OutBufHeader*/ - pOutBufHeader->nOffset = 0; - pOutBufHeader->nFilledLen = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated; - pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; - pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE; - /*notify the EOSEvent to the client*/ - pH264VEComp->bNotifyEOSEventToClient = OMX_TRUE; - /* Return this output buffer to the Base comp via ReturnDataNotify call - * to communciate with the IL client incase of Non-Tunneling or tunneled - * component in case of tunneling*/ - ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US; - pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); - } - } - } - /*Call to xDM_FLUSH when Input with EOS flag has been received*/ - if( bLCodecFlush ) { - /*control call with command XDM_FLUSH*/ - OSAL_Info("Call CodecFlush "); - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval == VIDENC2_EFAIL ) { - OSAL_ErrorTrace("Got error from the CodecControl call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - /*Set the bCodecFlush to True ....no need to call codec flush during idle->Loaded Transition*/ - pH264VEComp->bCodecFlush = OMX_TRUE; - bLEOS= OMX_FALSE; - bLCodecFlush = OMX_FALSE; - /* after EOS no need to provide extra input buffer */ - pH264VEComp->bAfterEOSReception = OMX_TRUE; - } - if( pH264VEComp->bNotifyEOSEventToClient ) { - /* Reset the Codec : to continue with New stream w/o codec create */ - if( pH264VEComp->bCodecCreate ) { - /*Codec Call: control call with command XDM_RESET*/ - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval != VIDENC2_EOK ) { - OSAL_ErrorTrace("Got error from the Codec_RESET call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - /* Notify EOS event flag to the Base Component via ReturnEventNotify - * call , which communciates with the IL Client */ - pH264VEComp->sBase.fpReturnEventNotify(hComponent, OMX_EventBufferFlag, - OMX_H264VE_OUTPUT_PORT, - OMX_BUFFERFLAG_EOS, NULL); - /*reset the flags*/ - pH264VEComp->bAfterEOSReception = OMX_FALSE; - pH264VEComp->bNotifyEOSEventToClient = OMX_FALSE; - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bSendCodecConfig = OMX_TRUE; - pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; - pH264VEComp->nCodecConfigSize = 0; - pH264VEComp->bAfterGenHeader = OMX_FALSE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - goto EXIT; - } - -CHECKCOUNT: - /*get the buffer count for the next loop execution*/ - pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount); - pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount); - ALOGE("Input Msg Count=%d, Output Msg Count=%d for the Next process loop", nInMsgCount, nOutMsgCount); - } /*end of process call loop*/ - } else { - OSAL_WarningTrace("!!!!!!!!!!!Incorrect State operation/ ports need to be enabled!!!!!!!!"); - } - -EXIT: - - return (eError); - -} - -static OMX_ERRORTYPE OMXH264VE_ComponentDeinit(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_U32 i; - - - /* Check the input parameters */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pComp = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate; - - OMXBase_UtilCleanupIfError(hComponent); - - - if( pH264VEComp->sBase.cComponentName ) { - OSAL_Free(pH264VEComp->sBase.cComponentName); - pH264VEComp->sBase.cComponentName = NULL; - } - - /* Calling OMX Base Component Deinit */ - OSAL_Info("Call BaseComponent Deinit"); - eError = OMXBase_ComponentDeinit(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - /*Allocating memory for port properties before calling SetDefaultProperties*/ - OSAL_Info("DeInitialize DerToBase.PortProperties"); - - pH264VEComp->bInputMetaDataBufferMode = OMX_FALSE; - - /*Add CE deinit related stuff here*/ - if( pH264VEComp->pCEhandle ) { - OSAL_Info("Call Engine_Close"); - Engine_close(pH264VEComp->pCEhandle); - } - - /* Free up the H264VE component's private area */ - OSAL_Free(pH264VEComp->sBase.pAudioPortParams); - OSAL_Free(pH264VEComp->sBase.pVideoPortParams); - OSAL_Free(pH264VEComp->sBase.pImagePortParams); - OSAL_Free(pH264VEComp->sBase.pOtherPortParams); - memplugin_free_noheader(pH264VEComp->sCodecConfigData.sBuffer); - memplugin_free_noheader(pH264VEComp->pTempBuffer[0]); - memplugin_free_noheader(pH264VEComp->pTempBuffer[1]); - memplugin_free(pH264VEComp->pVedEncOutBufs); - memplugin_free(pH264VEComp->pVedEncInBufs); - memplugin_free(pH264VEComp->pVidEncOutArgs); - memplugin_free(pH264VEComp->pVidEncInArgs); - memplugin_free(pH264VEComp->pVidEncStatus); - memplugin_free(pH264VEComp->pVidEncDynamicParams); - memplugin_free(pH264VEComp->pVidEncStaticParams); - - OSAL_Free(pH264VEComp); - pH264VEComp = NULL; - -EXIT: - OSAL_Info("At the End of Component DeInit"); - return (eError); -} - - -OMX_ERRORTYPE OMXH264VE_GetExtensionIndex(OMX_HANDLETYPE hComponent, - OMX_STRING cParameterName, - OMX_INDEXTYPE *pIndexType) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pComp; - OMXH264VidEncComp *pH264VEComp = NULL; - - /* Check the input parameters */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - - pComp = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate; - - OMX_CHECK(pH264VEComp != NULL, OMX_ErrorBadParameter); - - OMX_CHECK(cParameterName != NULL, OMX_ErrorBadParameter); - OMX_CHECK(pIndexType != NULL, OMX_ErrorBadParameter); - if( pH264VEComp->sBase.tCurState == OMX_StateInvalid ) { - eError = OMX_ErrorInvalidState; - goto EXIT; - } - if( strlen(cParameterName) > 127 ) { - //strlen does not include �\0� size, hence 127 - eError = OMX_ErrorBadParameter; - goto EXIT; - } - - if(strcmp(cParameterName, "OMX.google.android.index.storeMetaDataInBuffers") == 0) { - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexEncoderReceiveMetadataBuffers; - goto EXIT; - } else if( strcmp(cParameterName, "OMX.google.android.index.describeColorFormat") == 0 ) { - // If Index type is Time Stamp In Decode Order - *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat; - goto EXIT; - } - - eError = OMX_ErrorUnsupportedIndex; - -EXIT: - return (eError); -} - - -static OMX_ERRORTYPE OMXH264VE_ComponentTunnelRequest(OMX_HANDLETYPE hComponent, - OMX_U32 nPort, - OMX_HANDLETYPE hTunneledComp, - OMX_U32 nTunneledPort, - OMX_TUNNELSETUPTYPE *pTunnelSetup) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - (void)nPort, hTunneledComp, nTunneledPort, pTunnelSetup; - - /* Check all the input parametrs */ - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - OMX_CHECK((pH264VEComp != NULL), OMX_ErrorBadParameter); - - eError = OMX_ErrorNotImplemented; - OSAL_ErrorTrace("in omx-h264e ComponentTunnelRequest :: enable input subframe processing first"); - OMX_CHECK(OMX_ErrorNone == eError, eError); - -EXIT: - return (eError); -} - - diff --git a/omx/videoencode/omx_h264_enc/src/omx_H264videoencoderutils.c b/omx/videoencode/omx_h264_enc/src/omx_H264videoencoderutils.c deleted file mode 100644 index 6859995..0000000 --- a/omx/videoencode/omx_h264_enc/src/omx_H264videoencoderutils.c +++ /dev/null @@ -1,989 +0,0 @@ -/* - * Copyright (C) Texas Instruments - http://www.ti.com/ - * - * 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. - */ - -#define LOG_TAG "OMX_H264_ENCODERUTILS" - -#include "omx_H264videoencoder.h" - -OMX_H264_LVL_BITRATE OMX_H264_BP_MP_BITRATE_SUPPORT[] = -{ - { OMX_VIDEO_AVCLevel1, 64000 }, - { OMX_VIDEO_AVCLevel1b, 128000 }, - { OMX_VIDEO_AVCLevel11, 192000 }, - { OMX_VIDEO_AVCLevel12, 384000 }, - { OMX_VIDEO_AVCLevel13, 768000 }, - { OMX_VIDEO_AVCLevel2, 2000000 }, - { OMX_VIDEO_AVCLevel21, 4000000 }, - { OMX_VIDEO_AVCLevel22, 4000000 }, - { OMX_VIDEO_AVCLevel3, 10000000 }, - { OMX_VIDEO_AVCLevel31, 14000000 }, - { OMX_VIDEO_AVCLevel32, 20000000 }, - { OMX_VIDEO_AVCLevel4, 20000000 }, - { OMX_VIDEO_AVCLevel41, 50000000 }, - { OMX_VIDEO_AVCLevel42, 50000000 }, - { OMX_VIDEO_AVCLevel5, 50000000 }, //according to the spec the bit rate supported is 135000000, here the 50mpbs limit is as per the current codec version - { OMX_VIDEO_AVCLevel51, 50000000 } //according to the spec the bit rate supported is 240000000, here the 50mpbs limit is as per the current codec version -}; - -OMX_H264_LVL_BITRATE OMX_H264_HP_BITRATE_SUPPORT[] = -{ - { OMX_VIDEO_AVCLevel1, 80000 }, - { OMX_VIDEO_AVCLevel1b, 160000 }, - { OMX_VIDEO_AVCLevel11, 240000 }, - { OMX_VIDEO_AVCLevel12, 480000 }, - { OMX_VIDEO_AVCLevel13, 960000 }, - { OMX_VIDEO_AVCLevel2, 2500000 }, - { OMX_VIDEO_AVCLevel21, 5000000 }, - { OMX_VIDEO_AVCLevel22, 5000000 }, - { OMX_VIDEO_AVCLevel3, 12500000 }, - { OMX_VIDEO_AVCLevel31, 17500000 }, - { OMX_VIDEO_AVCLevel32, 25000000 }, - { OMX_VIDEO_AVCLevel4, 25000000 }, - { OMX_VIDEO_AVCLevel41, 62500000 }, - { OMX_VIDEO_AVCLevel42, 62500000 }, - { OMX_VIDEO_AVCLevel5, 62500000 }, //according to the spec the bit rate supported is 168750000, here the 62.5mpbs limit is as per the current codec version - { OMX_VIDEO_AVCLevel51, 62500000 } //according to the spec the bit rate supported is 300000000, here the 62.5mpbs limit is as per the current codec version -}; - -OMX_ERRORTYPE OMXH264VE_InitFields(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - - OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); - - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - pH264VEComp->sBase.cComponentName = (OMX_STRING )OSAL_Malloc(sizeof(OMX_U8) * OMX_MAX_STRINGNAME_SIZE); - OMX_CHECK(pH264VEComp->sBase.cComponentName != NULL, OMX_ErrorInsufficientResources); - - strcpy(pH264VEComp->sBase.cComponentName, OMX_H264VE_COMP_NAME); - - /* Fill component's version, this may not be same as the OMX Specification version */ - pH264VEComp->sBase.nComponentVersion.s.nVersionMajor = OMX_H264VE_COMP_VERSION_MAJOR; - pH264VEComp->sBase.nComponentVersion.s.nVersionMinor = OMX_H264VE_COMP_VERSION_MINOR; - pH264VEComp->sBase.nComponentVersion.s.nRevision = OMX_H264VE_COMP_VERSION_REVISION; - pH264VEComp->sBase.nComponentVersion.s.nStep = OMX_H264VE_COMP_VERSION_STEP; - - /* Initialize Audio Port parameters */ - OSAL_Info("Initialize Audio Port Params"); - pH264VEComp->sBase.pAudioPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); - OMX_CHECK(pH264VEComp->sBase.pAudioPortParams != NULL, OMX_ErrorInsufficientResources); - - OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pAudioPortParams, OMX_PORT_PARAM_TYPE); - pH264VEComp->sBase.pAudioPortParams->nPorts = 0; - pH264VEComp->sBase.pAudioPortParams->nStartPortNumber = 0; - - /* Initialize Video Port parameters */ - OSAL_Info("Initialize Video Port Params"); - pH264VEComp->sBase.pVideoPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); - OMX_CHECK(pH264VEComp->sBase.pVideoPortParams != NULL, OMX_ErrorInsufficientResources); - - OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pVideoPortParams, OMX_PORT_PARAM_TYPE); - pH264VEComp->sBase.pVideoPortParams->nPorts = OMX_H264VE_NUM_PORTS; - pH264VEComp->sBase.pVideoPortParams->nStartPortNumber = OMX_H264VE_DEFAULT_START_PORT_NUM; - - /* Initialize Image Port parameters */ - OSAL_Info("Initialize Image Port Params"); - pH264VEComp->sBase.pImagePortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); - OMX_CHECK(pH264VEComp->sBase.pImagePortParams != NULL, OMX_ErrorInsufficientResources); - - OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pImagePortParams, OMX_PORT_PARAM_TYPE); - pH264VEComp->sBase.pImagePortParams->nPorts = 0; - pH264VEComp->sBase.pImagePortParams->nStartPortNumber = 0; - - /* Initialize Other Port parameters */ - OSAL_Info("Initialize Other Port Params"); - pH264VEComp->sBase.pOtherPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); - OMX_CHECK(pH264VEComp->sBase.pOtherPortParams != NULL, OMX_ErrorInsufficientResources); - - OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pOtherPortParams, OMX_PORT_PARAM_TYPE); - pH264VEComp->sBase.pOtherPortParams->nPorts = 0; - pH264VEComp->sBase.pOtherPortParams->nStartPortNumber = 0; - - /* Initialize the Total Number of Ports and Start Port Number*/ - OSAL_Info("Initialize Component Port Params"); - pH264VEComp->sBase.nNumPorts = OMX_H264VE_NUM_PORTS; - pH264VEComp->sBase.nMinStartPortIndex = OMX_H264VE_DEFAULT_START_PORT_NUM; - - /* Overriding this value. Notify derived component only when data is available on all ports */ - pH264VEComp->sBase.bNotifyForAnyPort = OMX_FALSE; - - /* Allocate Memory for Static Parameter */ - pH264VEComp->pVidEncStaticParams = (IH264ENC_Params *) memplugin_alloc(sizeof(IH264ENC_Params), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pVidEncStaticParams != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pH264VEComp->pVidEncStaticParams, 0x0, sizeof(IH264ENC_Params)); - - /* Allocate Memory for Dynamic Parameter */ - pH264VEComp->pVidEncDynamicParams = (IH264ENC_DynamicParams *) memplugin_alloc(sizeof(IH264ENC_DynamicParams), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pVidEncDynamicParams != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pH264VEComp->pVidEncDynamicParams, 0x0, sizeof(IH264ENC_DynamicParams)); - - /* Allocate Memory for status Parameter */ - pH264VEComp->pVidEncStatus = (IH264ENC_Status *) memplugin_alloc(sizeof(IH264ENC_Status), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pVidEncStatus != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pH264VEComp->pVidEncStatus, 0x0, sizeof(IH264ENC_Status)); - - /* Allocate Memory for InArgs Parameter */ - pH264VEComp->pVidEncInArgs = (IH264ENC_InArgs *) memplugin_alloc(sizeof(IH264ENC_InArgs), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pVidEncInArgs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pH264VEComp->pVidEncInArgs, 0x0, sizeof(IH264ENC_InArgs)); - - /* Allocate Memory for OutArgs Parameter */ - pH264VEComp->pVidEncOutArgs = (IH264ENC_OutArgs *) memplugin_alloc(sizeof(IH264ENC_OutArgs), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pVidEncOutArgs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pH264VEComp->pVidEncOutArgs, 0x0, sizeof(IH264ENC_OutArgs)); - - /* Allocate Memory for InDesc Parameter */ - pH264VEComp->pVedEncInBufs = (IVIDEO2_BufDesc *) memplugin_alloc(sizeof(IVIDEO2_BufDesc), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pVedEncInBufs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pH264VEComp->pVedEncInBufs, 0x0, sizeof(IVIDEO2_BufDesc)); - - /* Allocate Memory for OutDesc Parameter */ - pH264VEComp->pVedEncOutBufs = (XDM2_BufDesc *) memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pVedEncOutBufs != NULL, OMX_ErrorInsufficientResources); - OSAL_Memset(pH264VEComp->pVedEncOutBufs, 0x0, sizeof(XDM2_BufDesc)); - -EXIT: - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("in fn OMXH264VE_SesBaseParameters"); - } - - return (eError); - - } - - -OMX_ERRORTYPE OMXH264VE_InitialzeComponentPrivateParams(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_U32 i = 0; - OSAL_ERROR tStatus = OSAL_ErrNone; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - - OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); - - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - OSAL_Info("Update the default Port Params"); - - /* Set the Port Definition (OMX_PARAM_PORTDEFINITIONTYPE) Values : INPUT PORT */ - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex = OMX_H264VE_INPUT_PORT; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.eDir = OMX_DirInput; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual = OMX_H264VE_DEFAULT_INPUT_BUFFER_COUNT; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin = OMX_H264VE_MIN_INPUT_BUFFER_COUNT; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = OMX_H264VE_DEFAULT_INPUT_BUFFER_SIZE; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bEnabled = OMX_TRUE; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bPopulated = OMX_FALSE; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.eDomain = OMX_PortDomainVideo; - /*Update the Domain (Video) Specific values*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.cMIMEType = NULL; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.pNativeRender = NULL; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH; /*should be multiples of 16*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride = OMX_H264VE_DEFAULT_FRAME_WIDTH; /*setting the stride as atleaset equal to width (should be multiples of 16)*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nSliceHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; /*setting the sliceheight as equal to frame height*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nBitrate = OMX_H264VE_DEFAULT_BITRATE; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate = (OMX_H264VE_DEFAULT_FRAME_RATE << 16); - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment = OMX_FALSE; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat =OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.pNativeWindow = NULL; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bBuffersContiguous=OMX_FALSE; - pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferAlignment=32; /*H264 Encoder Codec has alignment restriction for input buffers */ - - /* Set the Port Definition (OMX_PARAM_PORTDEFINITIONTYPE)Values : OUTPUT PORT */ - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex = OMX_H264VE_OUTPUT_PORT; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.eDir = OMX_DirOutput; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferCountActual = OMX_H264VE_DEFAULT_OUTPUT_BUFFER_COUNT; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferCountMin = OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferSize = OMX_H264VE_DEFAULT_OUTPUT_BUFFER_SIZE; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bEnabled = OMX_TRUE; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bPopulated = OMX_FALSE; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.eDomain = OMX_PortDomainVideo; - /*Update the Domain (Video) Specific values*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.cMIMEType = NULL; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.pNativeRender = NULL; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nStride = 0; //Stride is not used on port having bitstream buffers - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nSliceHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; /*setting the sliceheight as equal frame height*/ - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate = OMX_H264VE_DEFAULT_BITRATE; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.xFramerate = 0; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment = OMX_FALSE; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eColorFormat = OMX_COLOR_FormatUnused; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.pNativeWindow = NULL; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bBuffersContiguous=OMX_FALSE; - pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferAlignment=0; /*No Alignment required for output buffers*/ - - OSAL_Info("SetH264AlgDefaultCreationParams "); - /* Set the Default IVIDENC2_Params: videnc2Params . Does not Adhere to Codec Defaults. Can be modified */ - SET_H264CODEC_DEFAULT_IVIDENC2_PARAMS(pH264VEComp, i); - /* Adheres to Codec Defaults. To be modified only when codec default params change */ - eError = OMXH264VE_SetAlgDefaultCreationParams(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); - - /*Overwrite some of the codec static defaults*/ - OVERWRITE_H264CODEC_DEFAULT_STATIC_PARAMS(pH264VEComp); - pH264VEComp->pVidEncStaticParams->IDRFrameInterval = 1; /*All I frames are IDR frames*/ - - OSAL_Info("SetH264AlgDefaultDynamicParams "); - /* Set the IVIDENC2_DynamicParams videnc2DynamicParams */ - SET_H264CODEC_DEFAULT_IVIDENC2_DYNAMICPARAMS(pH264VEComp); - eError = OMXH264VE_SetAlgDefaultDynamicParams(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); - - /*Overwrite some of the codec static defaults*/ - OVERWRITE_H264CODEC_DEFAULT_DYNAMIC_PARAMS(pH264VEComp); - /*Enable 4 MV*/ - ENABLE_4MV(pH264VEComp); - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; - - pH264VEComp->bCodecCreate = OMX_FALSE; /*codec creation hasn't happened yet*/ - pH264VEComp->bCodecCreateSettingsChange = OMX_FALSE; /*set to true when Create time settings are modified*/ - pH264VEComp->bInputPortDisable = OMX_FALSE; /*flag to indicate codec creation is required or not */ - pH264VEComp->bCodecFlush = OMX_FALSE; - - pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE; - pH264VEComp->pCodecInBufferArray = NULL; - pH264VEComp->bAfterEOSReception = OMX_FALSE; - pH264VEComp->bNotifyEOSEventToClient = OMX_FALSE; - pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE; - pH264VEComp->bSetParamInputIsDone = OMX_FALSE; - - pH264VEComp->bSendCodecConfig = OMX_TRUE; - - pH264VEComp->sCodecConfigData.sBuffer = OSAL_Malloc(sizeof(MemHeader)); - pH264VEComp->sCodecConfigData.sBuffer->ptr - = memplugin_alloc_noheader(pH264VEComp->sCodecConfigData.sBuffer, (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->sCodecConfigData.sBuffer->ptr != NULL, OMX_ErrorInsufficientResources); - - tStatus = OSAL_Memset(pH264VEComp->sCodecConfigData.sBuffer->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE)); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter); - - - pH264VEComp->pTempBuffer[0] = OSAL_Malloc(sizeof(MemHeader)); - pH264VEComp->pTempBuffer[0]->ptr - = memplugin_alloc_noheader(pH264VEComp->pTempBuffer[0], (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pTempBuffer[0]->ptr != NULL, OMX_ErrorInsufficientResources); - - tStatus = OSAL_Memset(pH264VEComp->pTempBuffer[0]->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE)); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter); - - pH264VEComp->pTempBuffer[1] = OSAL_Malloc(sizeof(MemHeader)); - pH264VEComp->pTempBuffer[1]->ptr - = memplugin_alloc_noheader(pH264VEComp->pTempBuffer[1], (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0); - OMX_CHECK(pH264VEComp->pTempBuffer[1]->ptr != NULL, OMX_ErrorInsufficientResources); - - tStatus = OSAL_Memset(pH264VEComp->pTempBuffer[1]->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE)); - OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter); - - pH264VEComp->nCodecConfigSize = 0; - pH264VEComp->bAfterGenHeader = OMX_FALSE; - -EXIT: - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace(" in fn OMXH264VE_InitialzeComponentPrivateParams"); - } - - return (eError); - -} - -OMX_ERRORTYPE OMXH264VE_SetAlgDefaultCreationParams(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - /* Set the Default IH264ENC_RateControlParams: rateControlParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_RATECONTROLPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_InterCodingParams interCodingParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTERCODINGPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_IntraCodingParams intraCodingParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTRACODINGPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_NALUControlParams nalUnitControlParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_NALUCONTROLPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_SliceCodingParams sliceCodingParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SLICECODINGPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_LoopFilterParams loopFilterParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_LOOPFILTERPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_FMOCodingParams fmoCodingParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_FMOCODINGPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_VUICodingParams vuiCodingParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_VUICODINGPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_StereoInfoParams stereoInfoParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOINFOPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_FramePackingSEIParams framePackingSEIParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOFRAMEPACKINGPARAMS(pH264VEComp); - - /* Set the Default IH264ENC_SVCCodingParams svcCodingParams */ - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SVCCODINGPARAMS(pH264VEComp); - - SET_H264CODEC_DEFAULT_STATIC_IH264ENC_EXTENDEDPARAMS(pH264VEComp); - -EXIT: - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("in fn OMXH264VE_SetAlgDefaultCreationParams"); - } - - return (eError); -} - -OMX_ERRORTYPE OMXH264VE_SetAlgDefaultDynamicParams(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - /* Set the IH264ENC_RateControlParams rateControlParams */ - SET_H264CODEC_DEFAULT_DYNAMIC_RATECONTROLPARAMS(pH264VEComp); - - /* Set the IH264ENC_InterCodingParams interCodingParams */ - SET_H264CODEC_DEFAULT_DYNAMIC_INTERCODINGPARAMS(pH264VEComp); - - /* Set the IH264ENC_IntraCodingParams interCodingParams */ - SET_H264CODEC_DEFAULT_DYNAMIC_INTRACODINGPARAMS(pH264VEComp); - - /* Set the IH264ENC_SliceCodingParams sliceCodingParams */ - SET_H264CODEC_DEFAULT_DYNAMIC_SLICECODINGPARAMS(pH264VEComp); - - SET_H264CODEC_DEFAULT_DYNAMIC_IH264_EXTENDEDPARAMS(pH264VEComp); - -EXIT: - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace(" in fn OMXH264VE_SetAlgDefaultDynamicParams"); - } - return (eError); -} - - -OMX_ERRORTYPE OMXH264VE_SetBufferDesc(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_U8 i; - OMX_U32 extWidth, extHeight, extStride; - - /* Check the input parameters, this should be TRUE else report an Error */ - OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - - OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - if( nPortIndex == OMX_H264VE_INPUT_PORT ) { - pH264VEComp->pVedEncInBufs->numPlanes = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minNumInBufs; - for( i=0; i < pH264VEComp->pVedEncInBufs->numPlanes; i++ ) { - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.inBufMemoryType[i]; - if( pH264VEComp->pVedEncInBufs->planeDesc[i].memType == XDM_MEMTYPE_RAW ) { - pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = - pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes; - } else { - /* Since we support non-tiler input buffers for encoding, change the memtype */ - pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; - pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].tileMem.width) * (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].tileMem.height); - } - } - - OSAL_Info("Update the Image,Active region of Codec params"); - extWidth = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth; /*stride is already checked during codec creation that it should be multiples of 16*/ - extStride = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride; - extHeight = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight; - - pH264VEComp->pVedEncInBufs->imageRegion.topLeft.x = 0; - pH264VEComp->pVedEncInBufs->imageRegion.topLeft.y = 0; - pH264VEComp->pVedEncInBufs->imageRegion.bottomRight.x = extStride; - - pH264VEComp->pVedEncInBufs->activeFrameRegion.topLeft.x = 0; - pH264VEComp->pVedEncInBufs->activeFrameRegion.topLeft.y = 0; - pH264VEComp->pVedEncInBufs->activeFrameRegion.bottomRight.x = extWidth; - - pH264VEComp->pVedEncInBufs->imagePitch[0] = extStride; - pH264VEComp->pVedEncInBufs->imagePitch[1] = extStride; - pH264VEComp->pVedEncInBufs->topFieldFirstFlag = OMX_TRUE; - - pH264VEComp->pVedEncInBufs->contentType = IVIDEO_PROGRESSIVE; - pH264VEComp->pVedEncInBufs->activeFrameRegion.bottomRight.y = extHeight; - pH264VEComp->pVedEncInBufs->imageRegion.bottomRight.y = extHeight; - - pH264VEComp->pVedEncInBufs->secondFieldOffsetWidth[0] = 0; - pH264VEComp->pVedEncInBufs->secondFieldOffsetWidth[1] = 0; - pH264VEComp->pVedEncInBufs->secondFieldOffsetHeight[0] = 0; - pH264VEComp->pVedEncInBufs->secondFieldOffsetHeight[1] = 0; - pH264VEComp->pVedEncInBufs->chromaFormat = XDM_YUV_420SP; - - } else if( nPortIndex == OMX_H264VE_OUTPUT_PORT ) { - pH264VEComp->pVedEncOutBufs->numBufs = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minNumOutBufs; - for( i=0; i < pH264VEComp->pVedEncOutBufs->numBufs; i++ ) { - pH264VEComp->pVedEncOutBufs->descs[i].memType = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.outBufMemoryType[i]; - if( pH264VEComp->pVedEncOutBufs->descs[i].memType == XDM_MEMTYPE_RAW ) { - pH264VEComp->pVedEncOutBufs->descs[i].bufSize.bytes = - pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minOutBufSize[i].bytes; - } else { - /* since the output buffers are always non-tiled, change the memory type & size to RAW memory type*/ - pH264VEComp->pVedEncOutBufs->descs[i].memType = XDM_MEMTYPE_RAW; - pH264VEComp->pVedEncOutBufs->descs[i].bufSize.bytes = - pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minOutBufSize[i].bytes; - } - } - } else { - eError=OMX_ErrorBadPortIndex; - } - -EXIT: - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("in fn OMXH264VE_SetBufferDesc"); - } - - return (eError); - -} - -OMX_ERRORTYPE OMXH264VE_SetEncCodecReady(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - XDAS_Int32 retval = 0; - - /* Check the input parameters */ - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - /*set the HRD buffer size appropriately*/ - if( pH264VEComp->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY ) { - pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize = - (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2; - pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize = - (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2; - } else { - pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize = - (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate); - pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize = - (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate); - } - pH264VEComp->pVidEncStaticParams->rateControlParams.initialBufferLevel = - pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize; - pH264VEComp->pVidEncDynamicParams->rateControlParams.initialBufferLevel = - pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize; - pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_USERDEFINED; - - if( pH264VEComp->pVidEncStaticParams->videnc2Params.maxHeight & 0x01 ) { - eError = OMX_ErrorUnsupportedSetting; - OSAL_ErrorTrace("Incorrect Height Settings"); - OSAL_ErrorTrace("for Progressive Port Def Height need be multiple of 2"); - OSAL_ErrorTrace("for Interlace Port Def Height need be multiple of 4"); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - - /* Create H264 Encoder Instance */ - pH264VEComp->pVidEncHandle = VIDENC2_create(pH264VEComp->pCEhandle, - OMX_H264V_ENCODER_NAME, - (VIDENC2_Params *)(pH264VEComp->pVidEncStaticParams)); - - OMX_CHECK(pH264VEComp->pVidEncHandle != NULL, OMX_ErrorInsufficientResources); - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCodecCreate=OMX_TRUE; - pH264VEComp->bCodecCreateSettingsChange=OMX_FALSE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - /* Set the Dynamic Parameters to the Codec */ - eError = OMXH264VE_SetDynamicParamsToCodec(hComponent); - OMX_CHECK(eError == OMX_ErrorNone, eError); - - /* Get the Codec Status Parametrs and Update the Component private Params accordingly */ - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_GETSTATUS, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval == VIDENC2_EFAIL ) { - OSAL_Info("Got error from the Codec GetbufInfo call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - - eError= OMXH264VE_UpdateParams(pHandle); - OMX_CHECK(eError == OMX_ErrorNone, eError); - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - /* get bufffer information: - * control->XDM_GETBUFINFO call always has to ensure the control->XDM_SETPARAMS call has done before - * Get the Buf Info from the Codec */ - OSAL_Info("call to xDM GetBufInfo"); - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_GETBUFINFO, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval == VIDENC2_EFAIL ) { - OSAL_Info("Got error from the Codec GetbufInfo call"); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - OMX_CHECK(eError == OMX_ErrorNone, eError); - /* Initialize the Inputbufs and Outputbufs with the values that Codec Expects */ - eError=OMXH264VE_SetBufferDesc(pHandle, OMX_H264VE_INPUT_PORT); - OMX_CHECK(eError == OMX_ErrorNone, eError); - - eError=OMXH264VE_SetBufferDesc(pHandle, OMX_H264VE_OUTPUT_PORT); - OMX_CHECK(eError == OMX_ErrorNone, eError); - -EXIT: - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("in fn OMXH264VE_SetEncCodecReady"); - } - - return (eError); - -} - -OMX_ERRORTYPE OMXH264VE_UpdateParams(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_STATETYPE tState; - - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - OSAL_Info("Update the OMX Component structures with Codec Structures"); - - pH264VEComp->pVidEncStaticParams->videnc2Params.encodingPreset = pH264VEComp->pVidEncStatus->videnc2Status.encodingPreset; - - pH264VEComp->pVidEncStaticParams->videnc2Params.rateControlPreset = pH264VEComp->pVidEncStatus->videnc2Status.rateControlPreset; - - pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = pH264VEComp->pVidEncStatus->videnc2Status.maxInterFrameInterval; - - pH264VEComp->pVidEncStaticParams->videnc2Params.inputChromaFormat = pH264VEComp->pVidEncStatus->videnc2Status.inputChromaFormat; - - pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType = pH264VEComp->pVidEncStatus->videnc2Status.inputContentType; - - pH264VEComp->pVidEncStaticParams->videnc2Params.operatingMode = pH264VEComp->pVidEncStatus->videnc2Status.operatingMode; - - pH264VEComp->pVidEncStaticParams->videnc2Params.profile = pH264VEComp->pVidEncStatus->videnc2Status.profile; - - pH264VEComp->pVidEncStaticParams->videnc2Params.level = pH264VEComp->pVidEncStatus->videnc2Status.level; - - pH264VEComp->pVidEncStaticParams->videnc2Params.inputDataMode = pH264VEComp->pVidEncStatus->videnc2Status.inputDataMode; - pH264VEComp->pVidEncStaticParams->videnc2Params.outputDataMode = pH264VEComp->pVidEncStatus->videnc2Status.outputDataMode; - - OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams), &(pH264VEComp->pVidEncStatus->videnc2Status.encDynamicParams), - sizeof (IVIDENC2_DynamicParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->rateControlParams), &(pH264VEComp->pVidEncStatus->rateControlParams), - sizeof (IH264ENC_RateControlParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->interCodingParams), &(pH264VEComp->pVidEncStatus->interCodingParams), - sizeof (IH264ENC_InterCodingParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->intraCodingParams), &(pH264VEComp->pVidEncStatus->intraCodingParams), - sizeof (IH264ENC_IntraCodingParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->nalUnitControlParams), &(pH264VEComp->pVidEncStatus->nalUnitControlParams), - sizeof (IH264ENC_NALUControlParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->sliceCodingParams), &(pH264VEComp->pVidEncStatus->sliceCodingParams), - sizeof (IH264ENC_SliceCodingParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->loopFilterParams), &(pH264VEComp->pVidEncStatus->loopFilterParams), - sizeof (IH264ENC_LoopFilterParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->fmoCodingParams), &(pH264VEComp->pVidEncStatus->fmoCodingParams), - sizeof (IH264ENC_FMOCodingParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->vuiCodingParams), &(pH264VEComp->pVidEncStatus->vuiCodingParams), - sizeof (IH264ENC_VUICodingParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->stereoInfoParams), &(pH264VEComp->pVidEncStatus->stereoInfoParams), - sizeof (IH264ENC_StereoInfoParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->framePackingSEIParams), &(pH264VEComp->pVidEncStatus->framePackingSEIParams), - sizeof (IH264ENC_FramePackingSEIParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->svcCodingParams), &(pH264VEComp->pVidEncStatus->svcCodingParams), - sizeof (IH264ENC_SVCCodingParams)); - - pH264VEComp->pVidEncStaticParams->interlaceCodingType = pH264VEComp->pVidEncStatus->interlaceCodingType; - - pH264VEComp->pVidEncStaticParams->bottomFieldIntra = pH264VEComp->pVidEncStatus->bottomFieldIntra; - - pH264VEComp->pVidEncStaticParams->gopStructure = pH264VEComp->pVidEncStatus->gopStructure; - - pH264VEComp->pVidEncStaticParams->entropyCodingMode = pH264VEComp->pVidEncStatus->entropyCodingMode; - - pH264VEComp->pVidEncStaticParams->transformBlockSize =pH264VEComp->pVidEncStatus->transformBlockSize; - - pH264VEComp->pVidEncStaticParams->log2MaxFNumMinus4 = pH264VEComp->pVidEncStatus->log2MaxFNumMinus4; - - pH264VEComp->pVidEncStaticParams->picOrderCountType = pH264VEComp->pVidEncStatus->picOrderCountType; - - pH264VEComp->pVidEncStaticParams->enableWatermark = pH264VEComp->pVidEncStatus->enableWatermark; - - pH264VEComp->pVidEncStaticParams->IDRFrameInterval =pH264VEComp->pVidEncStatus->IDRFrameInterval; - - pH264VEComp->pVidEncStaticParams->maxIntraFrameInterval =pH264VEComp->pVidEncStatus->maxIntraFrameInterval; - - pH264VEComp->pVidEncStaticParams->debugTraceLevel = pH264VEComp->pVidEncStatus->debugTraceLevel; - - pH264VEComp->pVidEncStaticParams->lastNFramesToLog = pH264VEComp->pVidEncStatus->lastNFramesToLog; - - pH264VEComp->pVidEncStaticParams->enableAnalyticinfo =pH264VEComp->pVidEncStatus->enableAnalyticinfo; - - pH264VEComp->pVidEncStaticParams->enableGMVSei =pH264VEComp->pVidEncStatus->enableGMVSei; - - pH264VEComp->pVidEncStaticParams->constraintSetFlags =pH264VEComp->pVidEncStatus->constraintSetFlags; - - pH264VEComp->pVidEncStaticParams->enableRCDO =pH264VEComp->pVidEncStatus->enableRCDO; - - pH264VEComp->pVidEncStaticParams->enableLongTermRefFrame =pH264VEComp->pVidEncStatus->enableLongTermRefFrame; - - pH264VEComp->pVidEncStaticParams->LTRPPeriod =pH264VEComp->pVidEncStatus->LTRPPeriod; - - pH264VEComp->pVidEncStaticParams->numTemporalLayer =pH264VEComp->pVidEncStatus->numTemporalLayer; - - pH264VEComp->pVidEncStaticParams->referencePicMarking =pH264VEComp->pVidEncStatus->referencePicMarking; - - pH264VEComp->pVidEncDynamicParams->searchCenter.x = pH264VEComp->pVidEncStatus->searchCenter.x; - - pH264VEComp->pVidEncDynamicParams->searchCenter.x = pH264VEComp->pVidEncStatus->searchCenter.y; - - pH264VEComp->pVidEncDynamicParams->enableStaticMBCount =pH264VEComp->pVidEncStatus->enableStaticMBCount; - - pH264VEComp->pVidEncDynamicParams->enableROI = pH264VEComp->pVidEncStatus->enableROI; - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - tState=pH264VEComp->sBase.tCurState; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - if((tState == OMX_StateLoaded) || (tState == OMX_StateIdle)) { - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->rateControlParams), &(pH264VEComp->pVidEncStatus->rateControlParams), - sizeof (IH264ENC_RateControlParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->interCodingParams), &(pH264VEComp->pVidEncStatus->interCodingParams), - sizeof (IH264ENC_InterCodingParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->sliceCodingParams), &(pH264VEComp->pVidEncStatus->sliceCodingParams), - sizeof (IH264ENC_SliceCodingParams)); - - OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->intraCodingParams), &(pH264VEComp->pVidEncStatus->intraCodingParams), - sizeof (IH264ENC_IntraCodingParams)); - } - -EXIT: - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("in fn OMXH264VE_UpdateParams"); - } - - return (eError); -} - -OMX_ERRORTYPE OMXH264VE_FLUSHLockedBuffers(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_U32 i; - - /* Check the input parameters */ - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) { - if(pH264VEComp->pCodecInBufferArray && pH264VEComp->pCodecInBufferArray[i]) { - OMXBase_BufHdrPvtData *pPvtData = (OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate); - if (pPvtData->bufSt == OWNED_BY_CODEC ) { - pH264VEComp->pCodecInBufferArray[i]->nOffset = 0; - /*update the status to free*/ - pPvtData->bufSt = OWNED_BY_US; - pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT, pH264VEComp->pCodecInBufferArray[i]); - } - } - } - -EXIT: - return (eError); -} - -OMX_ERRORTYPE OMXH264VE_GetNextFreeBufHdr(OMX_HANDLETYPE hComponent, OMX_S32 *nBuffIndex, OMX_U32 nPortIndex) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_BOOL bFreeBuffFound = OMX_FALSE; - OMX_S32 LBufIndex = -1; - OMX_U32 i; - - /* Check the input parameters */ - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - if( nPortIndex == OMX_H264VE_INPUT_PORT ) { - for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) { - if(!pH264VEComp->pCodecInBufferArray[i] || - ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate))->bufSt != OWNED_BY_CODEC ) { - bFreeBuffFound=OMX_TRUE; - LBufIndex=i; - break; - } - } - } else { - eError = OMX_ErrorBadParameter; - } - -EXIT: - - if( bFreeBuffFound ) { - *nBuffIndex=LBufIndex; - } else { - *nBuffIndex=-1; - } - return (eError); -} - -OMX_ERRORTYPE OMXH264VE_SetDynamicParamsToCodec(OMX_HANDLETYPE hComponent) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - XDAS_Int32 retval = 0; - - /* Check the input parameters */ - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.size = sizeof(IH264ENC_DynamicParams); - pH264VEComp->pVidEncStatus->videnc2Status.size = sizeof(IH264ENC_Status); - - if((pH264VEComp->bSendCodecConfig)) { - pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; - pH264VEComp->nCodecConfigSize = 0; - pH264VEComp->bAfterGenHeader = OMX_FALSE; - } - - pH264VEComp->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset = 2; //Existing - - pH264VEComp->pVidEncDynamicParams->interCodingParams.interCodingPreset = 2; //Existing - - pH264VEComp->pVidEncDynamicParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_EXISTING; - - pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = 2; //Existing - - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_CODEC; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_SETPARAMS, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); - if( retval == VIDENC2_EFAIL ) { - ALOGE("pH264VEComp->pVidEncStatus->videnc2Status.extendedError = %x", - (OMX_U32)pH264VEComp->pVidEncStatus->videnc2Status.extendedError); - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); - OMX_CHECK(eError == OMX_ErrorNone, eError); - } - - -EXIT: - return (eError); -} - -OMX_ERRORTYPE OMXH264VE_GetNumCodecLockedBuffers(OMX_HANDLETYPE hComponent, OMX_U32 *nLockedBuffCount) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_COMPONENTTYPE *pHandle = NULL; - OMX_U32 LBuffLockedCount = 0; - OMX_U32 i; - - /* Check the input parameters */ - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - - for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) { - if((pH264VEComp->pCodecInBufferArray[i]) && - ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate))->bufSt == OWNED_BY_CODEC ) { - LBuffLockedCount++; - - } - } - - *nLockedBuffCount=LBuffLockedCount; - -EXIT: - return (eError); -} - -OMX_ERRORTYPE OMXH264VE_VISACONTROL(VIDENC2_Handle handle, IVIDENC2_Cmd id, IVIDENC2_DynamicParams *dynParams, - IVIDENC2_Status *status, OMX_HANDLETYPE hComponent, XDAS_Int32 *retval) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - (void)handle; - - /*Check for the Params*/ - OMX_CHECK(((hComponent != NULL) && (dynParams != NULL) && (status != NULL) && (retval != NULL)), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = pHandle->pComponentPrivate; - - (*retval) = VIDENC2_control(pH264VEComp->pVidEncHandle, id, dynParams, status); - -EXIT: - return (eError); -} - - -OMX_ERRORTYPE OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(OMX_HANDLETYPE hComponent, XDAS_Int32 *retval) -{ - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_COMPONENTTYPE *pHandle = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - PARAMS_UPDATE_STATUS bLCallxDMSetParams = NO_PARAM_CHANGE; - OMX_U32 sLretval = VIDENC2_EOK; - - /*Check for the Params*/ - OMX_CHECK(((hComponent != NULL) && (retval != NULL)), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = pHandle->pComponentPrivate; - - OSAL_Info("Before the Codec Process call"); - sLretval = VIDENC2_process(pH264VEComp->pVidEncHandle, - (pH264VEComp->pVedEncInBufs), - (pH264VEComp->pVedEncOutBufs), - (IVIDENC2_InArgs *)(pH264VEComp->pVidEncInArgs), - (IVIDENC2_OutArgs *)(pH264VEComp->pVidEncOutArgs)); - - if( sLretval == (OMX_U32)VIDENC2_EFAIL ) { - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncOutArgs->videnc2OutArgs.extendedError, eError); - if( eError != OMX_ErrorNone ) { - ALOGE("Got error 0x%x from the Codec Process call", eError); - goto UPDATE_PARAMS; - } - } - - /* Get the Codec Status Parameters if there has been a setconfig which has been translated to the codec */ - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - bLCallxDMSetParams=pH264VEComp->bCallxDMSetParams; - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - - if( bLCallxDMSetParams == PARAMS_UPDATED_AT_CODEC ) { - OSAL_Info("Update the Codec Params after Codec Process call: call xDM control->GetStatus"); - sLretval = VIDENC2_control(pH264VEComp->pVidEncHandle, XDM_GETSTATUS, - (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), - (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus)); - if( sLretval == (OMX_U32)VIDENC2_EFAIL ) { - OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncOutArgs->videnc2OutArgs.extendedError, eError); - if( eError != OMX_ErrorNone ) { - OSAL_ErrorTrace("Got error 0x%x from the Codec Get Status Control call", eError); - goto UPDATE_PARAMS; - } - } - } - -UPDATE_PARAMS: - if( eError == OMX_ErrorNone ) { - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - bLCallxDMSetParams = pH264VEComp->bCallxDMSetParams; - if( bLCallxDMSetParams == PARAMS_UPDATED_AT_CODEC ) { - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - eError= OMXH264VE_UpdateParams(hComponent); - OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); - pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE; - } - OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); - } - -EXIT: - if( retval ) { - *retval = sLretval; - } - - return (eError); -} - -/* Function to check the max bit rate supported as per profile & level settings*/ -OMX_ERRORTYPE OMXH264VE_CheckBitRateCap(OMX_U32 targetBitRate, OMX_HANDLETYPE hComponent) -{ - OMX_COMPONENTTYPE *pHandle = NULL; - OMXH264VidEncComp *pH264VEComp = NULL; - OMX_ERRORTYPE eError = OMX_ErrorNone; - OMX_VIDEO_AVCLEVELTYPE eOMXLevel; - OMX_U32 nTableIndex = 0xFFFFFFFF; - - /* Check the input parameters */ - OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); - pHandle = (OMX_COMPONENTTYPE *)hComponent; - pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; - OMX_CHECK((pH264VEComp != NULL), OMX_ErrorBadParameter); - - MAP_CODEC_TO_OMX_AVCLEVEL(pH264VEComp->pVidEncStaticParams->videnc2Params.level, eOMXLevel, nTableIndex, eError); - OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); - OMX_CHECK(nTableIndex != 0xFFFFFFFF, OMX_ErrorUnsupportedSetting); - - if( pH264VEComp->pVidEncStaticParams->videnc2Params.profile == IH264_HIGH_PROFILE ) { - ALOGE(" HIGH PROFILE, Level %d Max Bit Rate Supported = %d", eOMXLevel, OMX_H264_HP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport); - OMX_CHECK(targetBitRate <= OMX_H264_HP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport, OMX_ErrorUnsupportedSetting); - } else { - ALOGE(" BASE/MAIN PROFILE, Level %d Max Bit Rate Supported = %d", eOMXLevel, OMX_H264_BP_MP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport); - OMX_CHECK(targetBitRate <= OMX_H264_BP_MP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport, OMX_ErrorUnsupportedSetting); - } - -EXIT: - return (eError); -} - - |