diff options
author | Andrew F. Davis | 2018-06-14 12:45:00 -0500 |
---|---|---|
committer | Praneeth Bajjuri | 2018-06-14 12:46:18 -0500 |
commit | 4720ea4441562d2dc7751da7ea90844b0b9baef5 (patch) | |
tree | 5d4171c7f27237225bde2ddf8d70483deb8e70d7 | |
parent | f7f858c48827a2e4e2199e60689855cfa2abf393 (diff) | |
download | hardware-ti-dra7xx-4720ea4441562d2dc7751da7ea90844b0b9baef5.tar.gz hardware-ti-dra7xx-4720ea4441562d2dc7751da7ea90844b0b9baef5.tar.xz hardware-ti-dra7xx-4720ea4441562d2dc7751da7ea90844b0b9baef5.zip |
OMX: Remove OMX Support
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 @@ | |||
17 | 17 | ||
18 | PRODUCT_PACKAGES += \ | 18 | PRODUCT_PACKAGES += \ |
19 | hwcomposer.am57x \ | 19 | hwcomposer.am57x \ |
20 | libmmrpc \ | ||
21 | libdce \ | ||
22 | libOMX_Core \ | ||
23 | libOMX \ | ||
24 | libosal \ | ||
25 | libOMX.TI.DUCATI1.VIDEO.H264E \ | ||
26 | libstagefrighthw \ | ||
27 | libOMX.TI.DUCATI1.VIDEO.DECODER \ | ||
28 | camera.am57x \ | 20 | camera.am57x \ |
29 | libtiutils | 21 | libtiutils |
30 | 22 | ||
diff --git a/jacinto6.mk b/jacinto6.mk index 87cd29f..29a75c8 100644 --- a/jacinto6.mk +++ b/jacinto6.mk | |||
@@ -17,14 +17,6 @@ | |||
17 | 17 | ||
18 | PRODUCT_PACKAGES += \ | 18 | PRODUCT_PACKAGES += \ |
19 | hwcomposer.jacinto6 \ | 19 | hwcomposer.jacinto6 \ |
20 | libmmrpc \ | ||
21 | libdce \ | ||
22 | libOMX_Core \ | ||
23 | libOMX \ | ||
24 | libosal \ | ||
25 | libOMX.TI.DUCATI1.VIDEO.H264E \ | ||
26 | libstagefrighthw \ | ||
27 | libOMX.TI.DUCATI1.VIDEO.DECODER \ | ||
28 | camera.jacinto6 \ | 20 | camera.jacinto6 \ |
29 | libtiutils | 21 | libtiutils |
30 | 22 | ||
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 @@ | |||
1 | ifeq ($(TARGET_BOARD_PLATFORM), $(filter $(TARGET_BOARD_PLATFORM), jacinto6 am57x)) | ||
2 | include $(all-subdir-makefiles) | ||
3 | 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 @@ | |||
1 | # OMX CORE Library # | ||
2 | LOCAL_PATH:= $(call my-dir) | ||
3 | |||
4 | include $(CLEAR_VARS) | ||
5 | |||
6 | LOCAL_SRC_FILES:= \ | ||
7 | omx_core/src/OMX_Core.c \ | ||
8 | omx_core/src/OMX_Core_Wrapper.c | ||
9 | |||
10 | LOCAL_C_INCLUDES += \ | ||
11 | frameworks/native/include/media/openmax \ | ||
12 | $(LOCAL_PATH)/omx_core/inc \ | ||
13 | $(LOCAL_PATH)/../osal/inc \ | ||
14 | hardware/ti/dce/ \ | ||
15 | |||
16 | LOCAL_SHARED_LIBRARIES := \ | ||
17 | libdl \ | ||
18 | libosal \ | ||
19 | libutils \ | ||
20 | liblog \ | ||
21 | libdce | ||
22 | |||
23 | LOCAL_CFLAGS += -DBUILDOS_ANDROID -DSTATIC_TABLE | ||
24 | LOCAL_MODULE:= libOMX_Core | ||
25 | LOCAL_MODULE_TAGS:= optional | ||
26 | LOCAL_VENDOR_MODULE := true | ||
27 | include $(BUILD_SHARED_LIBRARY) | ||
28 | |||
29 | # OMX Base library # | ||
30 | include $(CLEAR_VARS) | ||
31 | LOCAL_SRC_FILES:= \ | ||
32 | omx_base_comp/src/omx_base.c \ | ||
33 | omx_base_comp/src/omx_base_callbacks.c \ | ||
34 | omx_base_comp/src/omx_base_internal.c \ | ||
35 | omx_base_comp/src/omx_base_process.c \ | ||
36 | omx_base_dio_plugin/src/omx_base_dio.c \ | ||
37 | omx_base_dio_plugin/src/omx_base_dio_table.c \ | ||
38 | omx_base_dio_plugin/src/omx_base_dio_non_tunnel.c | ||
39 | |||
40 | LOCAL_C_INCLUDES += \ | ||
41 | frameworks/native/include/media/openmax \ | ||
42 | $(LOCAL_PATH)/omx_core/inc \ | ||
43 | $(LOCAL_PATH)/../osal/inc \ | ||
44 | system/core/include/cutils \ | ||
45 | $(LOCAL_PATH)/omx_base_dio_plugin/inc/ \ | ||
46 | $(LOCAL_PATH)/omx_base_comp/inc/ \ | ||
47 | hardware/ti/dce/ | ||
48 | |||
49 | |||
50 | LOCAL_SHARED_LIBRARIES := \ | ||
51 | libosal \ | ||
52 | libc \ | ||
53 | liblog \ | ||
54 | libcutils \ | ||
55 | libutils \ | ||
56 | libdce | ||
57 | |||
58 | LOCAL_CFLAGS += -DBUILDOS_ANDROID | ||
59 | |||
60 | LOCAL_MODULE:= libOMX | ||
61 | LOCAL_MODULE_TAGS:= optional | ||
62 | LOCAL_VENDOR_MODULE := true | ||
63 | |||
64 | 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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _D_OMX_BASE_H_ | ||
18 | #define _D_OMX_BASE_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <stdio.h> | ||
25 | #include <string.h> | ||
26 | #include <stdlib.h> | ||
27 | |||
28 | #include <OMX_Core.h> | ||
29 | #include <OMX_Component.h> | ||
30 | #include <osal_error.h> | ||
31 | #include <osal_mutex.h> | ||
32 | #include <osal_memory.h> | ||
33 | #include <osal_pipes.h> | ||
34 | #include <osal_events.h> | ||
35 | #include <osal_task.h> | ||
36 | #include <omx_base_internal.h> | ||
37 | #include <omx_base_utils.h> | ||
38 | #include <memplugin.h> | ||
39 | |||
40 | #define OMX_NOPORT 0xFFFFFFFE | ||
41 | #define OMX_BASE_INPUT_PORT 0 | ||
42 | #define OMX_BASE_OUTPUT_PORT 1 | ||
43 | #define OMX_BASE_NUM_OF_PORTS 2 | ||
44 | #define OMX_BASE_DEFAULT_START_PORT_NUM 0 | ||
45 | #define DEFAULT_COMPOENENT 0 | ||
46 | #define MAX_PLANES_PER_BUFFER 3 | ||
47 | |||
48 | |||
49 | /* | ||
50 | * buffer life cycle | ||
51 | */ | ||
52 | typedef enum OMXBase_BufferStatus{ | ||
53 | OWNED_BY_US, | ||
54 | OWNED_BY_CLIENT, | ||
55 | OWNED_BY_CODEC | ||
56 | }OMXBase_BufStatus; | ||
57 | |||
58 | /** Platform private buffer header | ||
59 | */ | ||
60 | typedef struct OMXBase_BufHdrPrivateData { | ||
61 | MemHeader sMemHdr[MAX_PLANES_PER_BUFFER]; | ||
62 | OMXBase_BufStatus bufSt; | ||
63 | OMX_BOOL bIsLocked; | ||
64 | }OMXBase_BufHdrPvtData; | ||
65 | |||
66 | typedef struct OMXBase_CodecConfigBuffer { | ||
67 | MemHeader *sBuffer; | ||
68 | } OMXBase_CodecConfigBuf; | ||
69 | |||
70 | /** Port properties. | ||
71 | */ | ||
72 | typedef struct OMXBase_PortProperties { | ||
73 | OMX_U32 nWatermark; | ||
74 | BufAccessMode eDataAccessMode; | ||
75 | MemRegion eBufMemoryType; | ||
76 | OMX_U32 nNumComponentBuffers; | ||
77 | OMX_U32 nTimeoutForDequeue; | ||
78 | }OMXBase_PortProps; | ||
79 | |||
80 | /** Base port definition | ||
81 | */ | ||
82 | typedef struct OMXBase_Port{ | ||
83 | OMX_PARAM_PORTDEFINITIONTYPE sPortDef; | ||
84 | OMX_BUFFERHEADERTYPE **pBufferlist; | ||
85 | OMXBase_PortProps sProps; | ||
86 | OMX_BOOL bIsBufferAllocator; | ||
87 | OMX_BOOL bIsInTransition; | ||
88 | OMX_BOOL bIsFlushingBuffers; | ||
89 | OMX_BOOL bEosRecd; | ||
90 | OMX_U32 nBufferCnt; | ||
91 | OMX_PTR pBufAllocFreeEvent; | ||
92 | OMX_PTR pDioOpenCloseSem; | ||
93 | OMX_PTR hDIO; | ||
94 | OMX_U32 nCachedBufferCnt; | ||
95 | }OMXBase_Port; | ||
96 | |||
97 | /* OMX base component structure | ||
98 | */ | ||
99 | typedef struct OMXBaseComp | ||
100 | { | ||
101 | OMX_STRING cComponentName; | ||
102 | OMX_VERSIONTYPE nComponentVersion; | ||
103 | OMX_PORT_PARAM_TYPE *pAudioPortParams; | ||
104 | OMX_PORT_PARAM_TYPE *pVideoPortParams; | ||
105 | OMX_PORT_PARAM_TYPE *pImagePortParams; | ||
106 | OMX_PORT_PARAM_TYPE *pOtherPortParams; | ||
107 | OMX_U32 nNumPorts; | ||
108 | OMX_U32 nMinStartPortIndex; | ||
109 | OMXBase_Port **pPorts; | ||
110 | OMX_BOOL bNotifyForAnyPort; | ||
111 | OMXBaseComp_Pvt *pPvtData; | ||
112 | OMX_STATETYPE tCurState; | ||
113 | OMX_STATETYPE tNewState; | ||
114 | OMX_PTR pMutex; | ||
115 | |||
116 | OMX_ERRORTYPE (*fpCommandNotify)(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE Cmd, | ||
117 | OMX_U32 nParam, OMX_PTR pCmdData); | ||
118 | |||
119 | OMX_ERRORTYPE (*fpDataNotify)(OMX_HANDLETYPE hComponent); | ||
120 | |||
121 | |||
122 | OMX_ERRORTYPE (*fpReturnEventNotify)(OMX_HANDLETYPE hComponent, OMX_EVENTTYPE eEvent, | ||
123 | OMX_U32 nEventData1, OMX_U32 nEventData2, OMX_PTR pEventData); | ||
124 | |||
125 | OMX_ERRORTYPE (*fpXlateBuffHandle)(OMX_HANDLETYPE hComponent, OMX_PTR pBufferHdr, OMX_BOOL bRegister); | ||
126 | |||
127 | }OMXBaseComp; | ||
128 | |||
129 | |||
130 | OMX_ERRORTYPE OMXBase_ComponentInit(OMX_IN OMX_HANDLETYPE hComponent); | ||
131 | |||
132 | OMX_ERRORTYPE OMXBase_SetCallbacks(OMX_IN OMX_HANDLETYPE hComponent, | ||
133 | OMX_IN OMX_CALLBACKTYPE *pCallbacks, | ||
134 | OMX_IN OMX_PTR pAppData); | ||
135 | |||
136 | OMX_ERRORTYPE OMXBase_GetComponentVersion(OMX_IN OMX_HANDLETYPE hComponent, | ||
137 | OMX_OUT OMX_STRING pComponentName, | ||
138 | OMX_OUT OMX_VERSIONTYPE *pComponentVersion, | ||
139 | OMX_OUT OMX_VERSIONTYPE *pSpecVersion, | ||
140 | OMX_OUT OMX_UUIDTYPE *pComponentUUID); | ||
141 | |||
142 | OMX_ERRORTYPE OMXBase_SendCommand(OMX_IN OMX_HANDLETYPE hComponent, | ||
143 | OMX_IN OMX_COMMANDTYPE Cmd, | ||
144 | OMX_IN OMX_U32 nParam1, | ||
145 | OMX_IN OMX_PTR pCmdData); | ||
146 | |||
147 | OMX_ERRORTYPE OMXBase_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, | ||
148 | OMX_IN OMX_INDEXTYPE nParamIndex, | ||
149 | OMX_INOUT OMX_PTR pParamStruct); | ||
150 | |||
151 | OMX_ERRORTYPE OMXBase_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, | ||
152 | OMX_IN OMX_INDEXTYPE nIndex, | ||
153 | OMX_IN OMX_PTR pParamStruct); | ||
154 | |||
155 | |||
156 | OMX_ERRORTYPE OMXBase_GetConfig(OMX_IN OMX_HANDLETYPE hComponent, | ||
157 | OMX_IN OMX_INDEXTYPE nIndex, | ||
158 | OMX_INOUT OMX_PTR pComponentConfigStructure); | ||
159 | |||
160 | |||
161 | OMX_ERRORTYPE OMXBase_SetConfig(OMX_IN OMX_HANDLETYPE hComponent, | ||
162 | OMX_IN OMX_INDEXTYPE nIndex, | ||
163 | OMX_IN OMX_PTR pComponentConfigStructure); | ||
164 | |||
165 | OMX_ERRORTYPE OMXBase_GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, | ||
166 | OMX_IN OMX_STRING cParameterName, | ||
167 | OMX_OUT OMX_INDEXTYPE *pIndexType); | ||
168 | |||
169 | |||
170 | OMX_ERRORTYPE OMXBase_GetState(OMX_IN OMX_HANDLETYPE hComponent, | ||
171 | OMX_OUT OMX_STATETYPE *pState); | ||
172 | |||
173 | |||
174 | OMX_ERRORTYPE OMXBase_UseBuffer(OMX_IN OMX_HANDLETYPE hComponent, | ||
175 | OMX_INOUT OMX_BUFFERHEADERTYPE * *ppBufferHdr, | ||
176 | OMX_IN OMX_U32 nPortIndex, | ||
177 | OMX_IN OMX_PTR pAppPrivate, | ||
178 | OMX_IN OMX_U32 nSizeBytes, | ||
179 | OMX_IN OMX_U8 *pBuffer); | ||
180 | |||
181 | OMX_ERRORTYPE OMXBase_AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent, | ||
182 | OMX_INOUT OMX_BUFFERHEADERTYPE * *ppBuffer, | ||
183 | OMX_IN OMX_U32 nPortIndex, | ||
184 | OMX_IN OMX_PTR pAppPrivate, | ||
185 | OMX_IN OMX_U32 nSizeBytes); | ||
186 | |||
187 | |||
188 | OMX_ERRORTYPE OMXBase_FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, | ||
189 | OMX_IN OMX_U32 nPortIndex, | ||
190 | OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); | ||
191 | |||
192 | |||
193 | OMX_ERRORTYPE OMXBase_EmptyThisBuffer(OMX_IN OMX_HANDLETYPE hComponent, | ||
194 | OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); | ||
195 | |||
196 | |||
197 | OMX_ERRORTYPE OMXBase_FillThisBuffer(OMX_IN OMX_HANDLETYPE hComponent, | ||
198 | OMX_IN OMX_BUFFERHEADERTYPE *pBuffer); | ||
199 | |||
200 | |||
201 | OMX_ERRORTYPE OMXBase_ComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); | ||
202 | |||
203 | |||
204 | OMX_ERRORTYPE OMXBase_UseEGLImage(OMX_IN OMX_HANDLETYPE hComponent, | ||
205 | OMX_INOUT OMX_BUFFERHEADERTYPE * *ppBufferHdr, | ||
206 | OMX_IN OMX_U32 nPortIndex, | ||
207 | OMX_IN OMX_PTR pAppPrivate, | ||
208 | OMX_IN void *eglImage); | ||
209 | |||
210 | OMX_ERRORTYPE OMXBase_ComponentRoleEnum(OMX_IN OMX_HANDLETYPE hComponent, | ||
211 | OMX_OUT OMX_U8 *cRole, | ||
212 | OMX_IN OMX_U32 nIndex); | ||
213 | |||
214 | #ifdef __cplusplus | ||
215 | } | ||
216 | #endif | ||
217 | |||
218 | #endif /* _OMX_BASE_H_ */ | ||
219 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_BASE_INTERNAL_H_ | ||
18 | #define _OMX_BASE_INTERNAL_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <OMX_Core.h> | ||
25 | #include <OMX_Component.h> | ||
26 | #include <omx_base_dio_plugin.h> | ||
27 | |||
28 | #define CMDEVENT (0x00000100) | ||
29 | |||
30 | #define DATAEVENT (0x00000200) | ||
31 | |||
32 | #define ENDEVENT (0x00f00000) | ||
33 | |||
34 | #define OMXBase_CmdStateSet (0x00001000) | ||
35 | |||
36 | #define OMXBase_CmdPortEnable (0x00002000) | ||
37 | |||
38 | #define OMXBase_CmdPortDisable (0x00003000) | ||
39 | |||
40 | #define OMXBase_CmdFlush (0x00004000) | ||
41 | |||
42 | #define OMXBase_CmdMarkBuffer (0x00005000) | ||
43 | |||
44 | #define OMXBase_MAXCMDS 10 | ||
45 | |||
46 | #define BUF_ALLOC_EVENT (0x00000001) | ||
47 | |||
48 | #define BUF_FREE_EVENT (0x00000002) | ||
49 | |||
50 | #define BUF_FAIL_EVENT (0x00000004) | ||
51 | |||
52 | #define STATE_LOADED_EVENT (0x00000001) | ||
53 | #define STATE_IDLE_EVENT (0x00000002) | ||
54 | #define STATE_EXEC_EVENT (0x00000004) | ||
55 | #define STATE_PAUSE_EVENT (0x00000008) | ||
56 | #define ERROR_EVENT (0x00000010) | ||
57 | #define PORT_ENABLE_EVENT (0x00000020) | ||
58 | #define PORT_DISABLE_EVENT (0x00000040) | ||
59 | |||
60 | #define STATE_TRANSITION_TIMEOUT 500 | ||
61 | #define STATE_TRANSITION_LONG_TIMEOUT 5000 | ||
62 | |||
63 | /** Priority of the Component thread */ | ||
64 | #define OMX_BASE_THREAD_PRIORITY (10) | ||
65 | |||
66 | /** Stack Size of the Comp thread*/ | ||
67 | #define OMX_BASE_THREAD_STACKSIZE (50 * 1024) | ||
68 | |||
69 | |||
70 | /** OMX Base Command params | ||
71 | * This structure contains the params required to execute command | ||
72 | * @param cmd : command to execute | ||
73 | * @param nParam : parameter for the command to be executed | ||
74 | * @param pCmdData : pointer to the command data | ||
75 | */ | ||
76 | typedef struct OMXBase_CmdParams { | ||
77 | OMX_COMMANDTYPE eCmd; | ||
78 | OMX_U32 unParam; | ||
79 | OMX_PTR pCmdData; | ||
80 | }OMXBase_CmdParams; | ||
81 | |||
82 | /** OMX Base component private structure | ||
83 | */ | ||
84 | typedef struct OMXBaseComp_Private { | ||
85 | OMX_U8 cTaskName[OMX_BASE_MAXNAMELEN]; | ||
86 | OMX_U32 nStackSize; | ||
87 | OMX_U32 nPrioirty; | ||
88 | OMX_PTR pThreadId; | ||
89 | OMX_CALLBACKTYPE sAppCallbacks; | ||
90 | OMX_BOOL bForceNotifyOnce; | ||
91 | OMX_PTR pCmdPipe; | ||
92 | OMX_PTR pCmdDataPipe; | ||
93 | OMX_PTR pTriggerEvent; | ||
94 | OMX_PTR pCmdCompleteEvent; | ||
95 | OMX_PTR pErrorCmdcompleteEvent; | ||
96 | OMX_PTR pCmdPipeMutex; | ||
97 | OMX_PTR pNewStateMutex; | ||
98 | OMX_PTR pPortDisableMutex; | ||
99 | OMX_ERRORTYPE (*fpInvokeProcessFunction)(OMX_HANDLETYPE hComponent, | ||
100 | OMX_U32 retEvent); | ||
101 | |||
102 | OMX_ERRORTYPE (*fpDioGetCount)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_U32 *pCount); | ||
103 | |||
104 | OMX_ERRORTYPE (*fpDioQueue)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pBuffHeader); | ||
105 | |||
106 | OMX_ERRORTYPE (*fpDioDequeue)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR *pBuffHeader); | ||
107 | |||
108 | OMX_ERRORTYPE (*fpDioSend)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pBuffHeader); | ||
109 | |||
110 | OMX_ERRORTYPE (*fpDioCancel)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pBuffHeader); | ||
111 | |||
112 | OMX_ERRORTYPE (*fpDioControl)(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, | ||
113 | OMX_DIO_CtrlCmdType nCmdType, OMX_PTR pParams); | ||
114 | }OMXBaseComp_Pvt; | ||
115 | |||
116 | /* Initialization and control functions */ | ||
117 | OMX_ERRORTYPE OMXBase_PrivateInit(OMX_HANDLETYPE hComponent); | ||
118 | |||
119 | OMX_ERRORTYPE OMXBase_PrivateDeInit(OMX_HANDLETYPE hComponent); | ||
120 | |||
121 | OMX_ERRORTYPE OMXBase_SetDefaultProperties(OMX_HANDLETYPE hComponent); | ||
122 | |||
123 | void OMXBase_CompThreadEntry(void *arg); | ||
124 | |||
125 | OMX_ERRORTYPE OMXBase_InitializePorts(OMX_HANDLETYPE hComponent); | ||
126 | |||
127 | OMX_ERRORTYPE OMXBase_DeinitializePorts(OMX_HANDLETYPE hComponent); | ||
128 | |||
129 | OMX_ERRORTYPE OMXBase_DisablePort(OMX_HANDLETYPE hComponent, | ||
130 | OMX_U32 nParam); | ||
131 | |||
132 | OMX_ERRORTYPE OMXBase_EnablePort(OMX_HANDLETYPE hComponent, | ||
133 | OMX_U32 nParam); | ||
134 | |||
135 | OMX_ERRORTYPE OMXBase_FlushBuffers(OMX_HANDLETYPE hComponent, | ||
136 | OMX_U32 nParam); | ||
137 | |||
138 | OMX_ERRORTYPE OMXBase_HandleStateTransition(OMX_HANDLETYPE hComponent, | ||
139 | OMX_U32 nParam); | ||
140 | |||
141 | |||
142 | /* Event processing */ | ||
143 | OMX_ERRORTYPE OMXBase_EventNotifyToClient(OMX_HANDLETYPE hComponent, | ||
144 | OMX_COMMANDTYPE Cmd, | ||
145 | OMX_U32 nParam, | ||
146 | OMX_PTR pCmdData); | ||
147 | OMX_BOOL OMXBase_IsCmdPending (OMX_HANDLETYPE hComponent); | ||
148 | |||
149 | OMX_ERRORTYPE OMXBase_ProcessEvents(OMX_HANDLETYPE hComponent, | ||
150 | OMX_U32 retEvent); | ||
151 | |||
152 | OMX_ERRORTYPE OMXBase_ProcessTriggerEvent(OMX_HANDLETYPE hComponent, | ||
153 | OMX_U32 EventToSet); | ||
154 | |||
155 | OMX_ERRORTYPE OMXBase_CB_ReturnEventNotify(OMX_HANDLETYPE hComponent, | ||
156 | OMX_EVENTTYPE eEvent, | ||
157 | OMX_U32 nData1, OMX_U32 nData2, | ||
158 | OMX_PTR pEventData); | ||
159 | |||
160 | /* DIO functions */ | ||
161 | OMX_BOOL OMXBase_IsDioReady(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex); | ||
162 | |||
163 | OMX_ERRORTYPE OMXBase_DIO_Init (OMX_HANDLETYPE hComponent, | ||
164 | OMX_U32 nPortIndex, | ||
165 | OMX_STRING cChannelType, | ||
166 | OMX_PTR pCreateParams); | ||
167 | |||
168 | OMX_ERRORTYPE OMXBase_DIO_Open (OMX_HANDLETYPE hComponent, | ||
169 | OMX_U32 nPortIndex, | ||
170 | OMX_PTR pOpenParams); | ||
171 | |||
172 | OMX_ERRORTYPE OMXBase_DIO_Close (OMX_HANDLETYPE hComponent, | ||
173 | OMX_U32 nPortIndex); | ||
174 | |||
175 | OMX_ERRORTYPE OMXBase_DIO_Queue (OMX_HANDLETYPE hComponent, | ||
176 | OMX_U32 nPortIndex, | ||
177 | OMX_PTR pBuffHeader); | ||
178 | |||
179 | OMX_ERRORTYPE OMXBase_DIO_Dequeue (OMX_HANDLETYPE hComponent, | ||
180 | OMX_U32 nPortIndex, | ||
181 | OMX_PTR *pBuffHeader); | ||
182 | |||
183 | OMX_ERRORTYPE OMXBase_DIO_Send (OMX_HANDLETYPE hComponent, | ||
184 | OMX_U32 nPortIndex, | ||
185 | OMX_PTR pBuffHeader); | ||
186 | |||
187 | OMX_ERRORTYPE OMXBase_DIO_Cancel (OMX_HANDLETYPE hComponent, | ||
188 | OMX_U32 nPortIndex, | ||
189 | OMX_PTR pBuffHeader); | ||
190 | |||
191 | OMX_ERRORTYPE OMXBase_DIO_Control (OMX_HANDLETYPE hComponent, | ||
192 | OMX_U32 nPortIndex, | ||
193 | OMX_DIO_CtrlCmdType nCmdType, | ||
194 | OMX_PTR pParams); | ||
195 | |||
196 | OMX_ERRORTYPE OMXBase_DIO_GetCount (OMX_HANDLETYPE hComponent, | ||
197 | OMX_U32 nPortIndex, | ||
198 | OMX_U32 *pCount); | ||
199 | |||
200 | OMX_ERRORTYPE OMXBase_DIO_Deinit (OMX_HANDLETYPE hComponent, | ||
201 | OMX_U32 nPortIndex); | ||
202 | |||
203 | /* Error Handling */ | ||
204 | |||
205 | OMX_ERRORTYPE OMXBase_Error_EventHandler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, | ||
206 | OMX_EVENTTYPE eEvent, OMX_U32 nData1, | ||
207 | OMX_U32 nData2, OMX_PTR pEventData); | ||
208 | |||
209 | OMX_ERRORTYPE OMXBase_Error_FillBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, | ||
210 | OMX_BUFFERHEADERTYPE *pBuffer); | ||
211 | |||
212 | OMX_ERRORTYPE OMXBase_Error_EmptyBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, | ||
213 | OMX_BUFFERHEADERTYPE *pBuffer); | ||
214 | |||
215 | void OMXBase_HandleFailEvent(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE eCmd, | ||
216 | OMX_U32 nPortIndex); | ||
217 | OMX_ERRORTYPE OMXBase_UtilCleanupIfError(OMX_HANDLETYPE hComponent); | ||
218 | |||
219 | /* Miscellaneous */ | ||
220 | |||
221 | OMX_ERRORTYPE OMXBase_GetUVBuffer(OMX_HANDLETYPE hComponent, | ||
222 | OMX_U32 nPortIndex, | ||
223 | OMX_PTR pBufHdr, OMX_PTR *pUVBuffer); | ||
224 | |||
225 | |||
226 | |||
227 | #ifdef __cplusplus | ||
228 | } | ||
229 | #endif | ||
230 | |||
231 | #endif /* _OMX_BASE_INTERNAL_H_ */ | ||
232 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_BASE_UTILS_H_ | ||
18 | #define _OMX_BASE_UTILS_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <osal_trace.h> | ||
25 | |||
26 | #define OMX_CHECK(_COND_, _ERRORCODE_) do { \ | ||
27 | if( !(_COND_)) { eError = _ERRORCODE_; \ | ||
28 | OSAL_ErrorTrace("Failed check: " # _COND_); \ | ||
29 | OSAL_ErrorTrace("Returning error: " # _ERRORCODE_); \ | ||
30 | goto EXIT; } \ | ||
31 | } while( 0 ) | ||
32 | |||
33 | #define OMX_BASE_CHK_VERSION(_pStruct_, _sName_, _e_) do { \ | ||
34 | if(((_sName_ *)_pStruct_)->nSize != sizeof(_sName_)) { \ | ||
35 | _e_ = OMX_ErrorBadParameter; \ | ||
36 | OSAL_ErrorTrace("Incorrect 'nSize' field. Returning OMX_ErrorBadParameter"); \ | ||
37 | goto EXIT; } \ | ||
38 | if((((_sName_ *)_pStruct_)->nVersion.s.nVersionMajor != 0x1) || \ | ||
39 | ((((_sName_ *)_pStruct_)->nVersion.s.nVersionMinor != 0x1) && \ | ||
40 | ((_sName_ *)_pStruct_)->nVersion.s.nVersionMinor != 0x0 )) { \ | ||
41 | _e_ = OMX_ErrorVersionMismatch; \ | ||
42 | OSAL_ErrorTrace("Version mismatch. Returning OMX_ErrorVersionMismatch"); \ | ||
43 | goto EXIT; } \ | ||
44 | } while( 0 ) | ||
45 | |||
46 | #define OMX_BASE_INIT_STRUCT_PTR(_pStruct_, _sName_) do { \ | ||
47 | OSAL_Memset((_pStruct_), 0x0, sizeof(_sName_)); \ | ||
48 | (_pStruct_)->nSize = sizeof(_sName_); \ | ||
49 | (_pStruct_)->nVersion.s.nVersionMajor = 0x1; \ | ||
50 | (_pStruct_)->nVersion.s.nVersionMinor = 0x1; \ | ||
51 | (_pStruct_)->nVersion.s.nRevision = 0x2; \ | ||
52 | (_pStruct_)->nVersion.s.nStep = 0x0; \ | ||
53 | } while( 0 ) | ||
54 | |||
55 | #ifdef __cplusplus | ||
56 | } | ||
57 | #endif | ||
58 | |||
59 | #endif /* _OMX_BASE_UTILS_H_ */ | ||
60 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_BASE" | ||
18 | |||
19 | #include <string.h> | ||
20 | #include <OMX_Core.h> | ||
21 | #include <OMX_Component.h> | ||
22 | #include <omx_base.h> | ||
23 | #include <OMX_TI_Custom.h> | ||
24 | |||
25 | /** | ||
26 | * OMX BaseComponent Init | ||
27 | */ | ||
28 | OMX_ERRORTYPE OMXBase_ComponentInit(OMX_IN OMX_HANDLETYPE hComponent) | ||
29 | { | ||
30 | OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; | ||
31 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
32 | OMX_COMPONENTTYPE *pComp = NULL; | ||
33 | OMXBaseComp *pBaseComp = NULL; | ||
34 | |||
35 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
36 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
37 | pBaseComp = (OMXBaseComp*)pComp->pComponentPrivate; | ||
38 | OMX_CHECK(pBaseComp != NULL, OMX_ErrorBadParameter); | ||
39 | |||
40 | /* populate component specific function pointers */ | ||
41 | pComp->GetComponentVersion = OMXBase_GetComponentVersion; | ||
42 | pComp->SendCommand = OMXBase_SendCommand; | ||
43 | pComp->GetParameter = OMXBase_GetParameter; | ||
44 | pComp->SetParameter = OMXBase_SetParameter; | ||
45 | pComp->GetConfig = OMXBase_GetConfig; | ||
46 | pComp->SetConfig = OMXBase_SetConfig; | ||
47 | pComp->GetExtensionIndex = OMXBase_GetExtensionIndex; | ||
48 | pComp->GetState = OMXBase_GetState; | ||
49 | pComp->ComponentTunnelRequest = NULL; | ||
50 | pComp->UseBuffer = OMXBase_UseBuffer; | ||
51 | pComp->AllocateBuffer = OMXBase_AllocateBuffer; | ||
52 | pComp->FreeBuffer = OMXBase_FreeBuffer; | ||
53 | pComp->EmptyThisBuffer = OMXBase_EmptyThisBuffer; | ||
54 | pComp->FillThisBuffer = OMXBase_FillThisBuffer; | ||
55 | pComp->SetCallbacks = OMXBase_SetCallbacks; | ||
56 | pComp->ComponentDeInit = OMXBase_ComponentDeinit; | ||
57 | pComp->UseEGLImage = OMXBase_UseEGLImage; | ||
58 | pComp->ComponentRoleEnum = OMXBase_ComponentRoleEnum; | ||
59 | |||
60 | pBaseComp->fpReturnEventNotify = OMXBase_CB_ReturnEventNotify; | ||
61 | |||
62 | /* create a mutex to handle race conditions */ | ||
63 | tStatus = OSAL_CreateMutex(&(pBaseComp->pMutex)); | ||
64 | if(OSAL_ErrNone != tStatus) { | ||
65 | return OMX_ErrorInsufficientResources; | ||
66 | } | ||
67 | |||
68 | /* Allocate internal area for Base component */ | ||
69 | pBaseComp->pPvtData = (OMXBaseComp_Pvt*)OSAL_Malloc(sizeof(OMXBaseComp_Pvt)); | ||
70 | OMX_CHECK(pBaseComp->pPvtData != NULL, OMX_ErrorInsufficientResources); | ||
71 | |||
72 | OSAL_Memset(pBaseComp->pPvtData, 0, sizeof(OMXBaseComp_Pvt)); | ||
73 | eError = OMXBase_PrivateInit(hComponent); | ||
74 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
75 | |||
76 | /* Initialize ports */ | ||
77 | eError = OMXBase_InitializePorts(hComponent); | ||
78 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
79 | |||
80 | /* Component is initialized successfully, set the | ||
81 | * component to loaded state */ | ||
82 | pBaseComp->tCurState = OMX_StateLoaded; | ||
83 | pBaseComp->tNewState = OMX_StateMax; | ||
84 | |||
85 | |||
86 | EXIT: | ||
87 | /* incase of an error, deinitialize the component */ | ||
88 | if((OMX_ErrorNone != eError) && (pComp != NULL)) { | ||
89 | eTmpError = eError; | ||
90 | eError = pComp->ComponentDeInit(hComponent); | ||
91 | eError = eTmpError; | ||
92 | } | ||
93 | return (eError); | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * SetCallbacks | ||
98 | */ | ||
99 | OMX_ERRORTYPE OMXBase_SetCallbacks(OMX_HANDLETYPE hComponent, | ||
100 | OMX_CALLBACKTYPE *pCallbacks, | ||
101 | OMX_PTR pAppData) | ||
102 | { | ||
103 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
104 | OMX_COMPONENTTYPE *pComp = NULL; | ||
105 | OMXBaseComp *pBaseComp = NULL; | ||
106 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
107 | OMX_U32 i = 0; | ||
108 | |||
109 | OMX_CHECK((hComponent != NULL) && | ||
110 | (pCallbacks != NULL), OMX_ErrorBadParameter); | ||
111 | |||
112 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
113 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
114 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
115 | |||
116 | pComp->pApplicationPrivate = pAppData; | ||
117 | pBaseCompPvt->sAppCallbacks = *pCallbacks; | ||
118 | |||
119 | for( i = 0; i < pBaseComp->nNumPorts; i++ ) { | ||
120 | pBaseComp->pPorts[i]->bIsBufferAllocator = OMX_FALSE; | ||
121 | } | ||
122 | |||
123 | EXIT: | ||
124 | return (eError); | ||
125 | } | ||
126 | |||
127 | /* | ||
128 | * GetComponent Version | ||
129 | */ | ||
130 | OMX_ERRORTYPE OMXBase_GetComponentVersion(OMX_HANDLETYPE hComponent, | ||
131 | OMX_STRING pComponentName, | ||
132 | OMX_VERSIONTYPE *pComponentVersion, | ||
133 | OMX_VERSIONTYPE *pSpecVersion, | ||
134 | OMX_UUIDTYPE *pComponentUUID) | ||
135 | { | ||
136 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
137 | OMX_COMPONENTTYPE *pComp = NULL; | ||
138 | OMXBaseComp *pBaseComp = NULL; | ||
139 | (void)pComponentUUID; | ||
140 | |||
141 | OMX_CHECK((hComponent != NULL) && | ||
142 | (pComponentName != NULL) && | ||
143 | (pComponentVersion != NULL) && | ||
144 | (pSpecVersion != NULL), OMX_ErrorBadParameter); | ||
145 | |||
146 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
147 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
148 | |||
149 | /*Can't be invoked when the comp is in invalid state*/ | ||
150 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); | ||
151 | |||
152 | OSAL_Memcpy(pComponentName, pBaseComp->cComponentName, OMX_MAX_STRINGNAME_SIZE); | ||
153 | |||
154 | *pComponentVersion = pBaseComp->nComponentVersion; | ||
155 | *pSpecVersion = pComp->nVersion; | ||
156 | |||
157 | EXIT: | ||
158 | return (eError); | ||
159 | } | ||
160 | |||
161 | /* | ||
162 | * GetState | ||
163 | */ | ||
164 | OMX_ERRORTYPE OMXBase_GetState(OMX_HANDLETYPE hComponent, | ||
165 | OMX_STATETYPE *pState) | ||
166 | { | ||
167 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
168 | OMX_COMPONENTTYPE *pComp = NULL; | ||
169 | OMXBaseComp *pBaseComp = NULL; | ||
170 | |||
171 | OMX_CHECK((hComponent != NULL) && | ||
172 | (pState != NULL), OMX_ErrorBadParameter); | ||
173 | |||
174 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
175 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
176 | |||
177 | *pState = pBaseComp->tCurState; | ||
178 | |||
179 | EXIT: | ||
180 | return (eError); | ||
181 | } | ||
182 | |||
183 | /* | ||
184 | * Base Component DeInit | ||
185 | */ | ||
186 | OMX_ERRORTYPE OMXBase_ComponentDeinit(OMX_HANDLETYPE hComponent) | ||
187 | { | ||
188 | OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; | ||
189 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
190 | OMX_COMPONENTTYPE *pComp = NULL; | ||
191 | OMXBaseComp *pBaseComp = NULL; | ||
192 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
193 | OMXBase_Port *pPort = NULL; | ||
194 | OMX_U32 i = 0; | ||
195 | |||
196 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
197 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
198 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
199 | OMX_CHECK(pBaseComp != NULL, OMX_ErrorBadParameter); | ||
200 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
201 | |||
202 | OSAL_ObtainMutex(pBaseComp->pMutex, OSAL_SUSPEND); | ||
203 | |||
204 | /*If component transitioned to invalid state suddenly then dio close and | ||
205 | deinit might have not been called - in that case calle them now */ | ||
206 | if( pBaseComp->tCurState != OMX_StateLoaded ) { | ||
207 | for( i=0; i < pBaseComp->nNumPorts; i++ ) { | ||
208 | pPort = pBaseComp->pPorts[i]; | ||
209 | if( pPort != NULL ) { | ||
210 | if( pPort->hDIO != NULL ) { | ||
211 | eTmpError = OMXBase_DIO_Close(hComponent, | ||
212 | (i + pBaseComp->nMinStartPortIndex)); | ||
213 | if( eTmpError != OMX_ErrorNone ) { | ||
214 | eError = eTmpError; | ||
215 | } | ||
216 | eTmpError = OMXBase_DIO_Deinit(hComponent, | ||
217 | (i + pBaseComp->nMinStartPortIndex)); | ||
218 | if( eTmpError != OMX_ErrorNone ) { | ||
219 | eError = eTmpError; | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | /* deinitialize ports and freeup the memory */ | ||
227 | eTmpError = OMXBase_DeinitializePorts(hComponent); | ||
228 | if( eTmpError != OMX_ErrorNone ) { | ||
229 | eError = eTmpError; | ||
230 | } | ||
231 | |||
232 | OSAL_ReleaseMutex(pBaseComp->pMutex); | ||
233 | |||
234 | if (pBaseCompPvt) { | ||
235 | OMXBase_PrivateDeInit(hComponent); | ||
236 | } | ||
237 | |||
238 | tStatus = OSAL_DeleteMutex(pBaseComp->pMutex); | ||
239 | if( tStatus != OSAL_ErrNone ) { | ||
240 | eError = OMX_ErrorUndefined; | ||
241 | } | ||
242 | pBaseComp->pMutex = NULL; | ||
243 | |||
244 | OSAL_Free(pBaseCompPvt); | ||
245 | pBaseCompPvt = NULL; | ||
246 | |||
247 | EXIT: | ||
248 | return (eError); | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * OMXBase SendCommand | ||
253 | */ | ||
254 | OMX_ERRORTYPE OMXBase_SendCommand(OMX_HANDLETYPE hComponent, | ||
255 | OMX_COMMANDTYPE Cmd, | ||
256 | OMX_U32 nParam1, | ||
257 | OMX_PTR pCmdData) | ||
258 | { | ||
259 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
260 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
261 | OMX_COMPONENTTYPE *pComp = NULL; | ||
262 | OMXBaseComp *pBaseComp = NULL; | ||
263 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
264 | OMXBase_Port *pPort = NULL; | ||
265 | OMXBase_CmdParams sCmdParams, sErrorCmdParams; | ||
266 | OMX_U32 nPorts, nStartPortNumber, nIndex; | ||
267 | OMX_PTR pLocalCmdData = NULL; | ||
268 | OMX_BOOL bFreeCmdDataIfError = OMX_TRUE; | ||
269 | OMX_U32 i = 0; | ||
270 | uint32_t nActualSize = 0, nCmdCount = 0; | ||
271 | |||
272 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
273 | if( OMX_CommandMarkBuffer == Cmd ) { | ||
274 | OMX_CHECK(pCmdData != NULL, OMX_ErrorBadParameter); | ||
275 | } | ||
276 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
277 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
278 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
279 | |||
280 | nPorts = pBaseComp->nNumPorts; | ||
281 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
282 | |||
283 | /*Can't be invoked when the comp is in invalid state*/ | ||
284 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); | ||
285 | |||
286 | switch( Cmd ) { | ||
287 | case OMX_CommandStateSet : | ||
288 | /*Return error if unknown state is provided*/ | ||
289 | OMX_CHECK(((OMX_STATETYPE)nParam1 <= | ||
290 | OMX_StateWaitForResources), OMX_ErrorBadParameter); | ||
291 | |||
292 | /*Mutex protection is for multiple SendCommands on the same | ||
293 | component parallely. This can especially happen in error handling | ||
294 | scenarios. Mutex protection ensure that the NewState variable is not | ||
295 | overwritten.*/ | ||
296 | OSAL_ObtainMutex(pBaseCompPvt->pNewStateMutex, | ||
297 | OSAL_SUSPEND); | ||
298 | /*Multiple state transitions at the same time is not allowed. | ||
299 | Though it is allowed by the spec, we prohibit it in our | ||
300 | implementation*/ | ||
301 | if( OMX_StateMax != pBaseComp->tNewState ) { | ||
302 | eError = OMX_ErrorIncorrectStateTransition; | ||
303 | OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); | ||
304 | goto EXIT; | ||
305 | } | ||
306 | pBaseComp->tNewState = (OMX_STATETYPE)nParam1; | ||
307 | OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); | ||
308 | break; | ||
309 | |||
310 | case OMX_CommandPortDisable : | ||
311 | /* Index of the port to disable should be less than | ||
312 | * no of ports or equal to OMX_ALL */ | ||
313 | OMX_CHECK((nParam1 < (nStartPortNumber + nPorts)) || | ||
314 | (nParam1 == OMX_ALL), OMX_ErrorBadPortIndex); | ||
315 | if( OMX_ALL == nParam1 ) { | ||
316 | /*Dont want to return same port state error if it never enters | ||
317 | the for loop*/ | ||
318 | if( nPorts > 0 ) { | ||
319 | eError = (OMX_ERRORTYPE)OMX_ErrorNone; | ||
320 | } | ||
321 | |||
322 | for( nIndex = 0; nIndex < nPorts; nIndex++ ) { | ||
323 | pPort = pBaseComp->pPorts[nIndex]; | ||
324 | /*Atleast 1 port is enabled - dont send same port state error*/ | ||
325 | if( pPort->sPortDef.bEnabled ) { | ||
326 | pPort->sPortDef.bEnabled = OMX_FALSE; | ||
327 | pPort->bIsInTransition = OMX_TRUE; | ||
328 | eError = OMX_ErrorNone; | ||
329 | } | ||
330 | } | ||
331 | } else { | ||
332 | nIndex = nParam1 - nStartPortNumber; | ||
333 | pPort = pBaseComp->pPorts[nIndex]; | ||
334 | if( pPort->sPortDef.bEnabled ) { | ||
335 | pPort->sPortDef.bEnabled = OMX_FALSE; | ||
336 | pPort->bIsInTransition = OMX_TRUE; | ||
337 | } else { | ||
338 | eError = (OMX_ERRORTYPE)OMX_ErrorNone; | ||
339 | } | ||
340 | } | ||
341 | break; | ||
342 | |||
343 | case OMX_CommandPortEnable : | ||
344 | /* Index of the port to enable should be less than | ||
345 | * no of ports or equal to OMX_ALL */ | ||
346 | OMX_CHECK((nParam1 < (nStartPortNumber + nPorts)) || | ||
347 | (nParam1 == OMX_ALL), OMX_ErrorBadPortIndex); | ||
348 | if( OMX_ALL == nParam1 ) { | ||
349 | /*Dont want to return same port state error if it never enters | ||
350 | the for loop*/ | ||
351 | if( nPorts > 0 ) { | ||
352 | eError = (OMX_ERRORTYPE)OMX_ErrorNone; | ||
353 | } | ||
354 | |||
355 | for( nIndex = 0; nIndex < nPorts; nIndex++ ) { | ||
356 | pPort = pBaseComp->pPorts[nIndex]; | ||
357 | /*Atleast 1 port is disabled - dont send same port state error*/ | ||
358 | if( !pPort->sPortDef.bEnabled ) { | ||
359 | eError = OMX_ErrorNone; | ||
360 | pPort->sPortDef.bEnabled = OMX_TRUE; | ||
361 | pPort->bIsInTransition = OMX_TRUE; | ||
362 | } | ||
363 | } | ||
364 | } else { | ||
365 | nIndex = nParam1 - nStartPortNumber; | ||
366 | pPort = pBaseComp->pPorts[nIndex]; | ||
367 | if( !pPort->sPortDef.bEnabled ) { | ||
368 | pPort->sPortDef.bEnabled = OMX_TRUE; | ||
369 | pPort->bIsInTransition = OMX_TRUE; | ||
370 | } else { | ||
371 | eError = (OMX_ERRORTYPE)OMX_ErrorNone; | ||
372 | } | ||
373 | } | ||
374 | break; | ||
375 | |||
376 | case OMX_CommandMarkBuffer : | ||
377 | /*For mark buffer pCmdData points to a structure of type OMX_MARKTYPE. | ||
378 | This may not be valid once send commmand returns so allocate memory and | ||
379 | copy this info there. This memory will be freed up during the command | ||
380 | complete callback for mark buffer.*/ | ||
381 | OMX_CHECK((nParam1 < (nStartPortNumber + nPorts)) || | ||
382 | (nParam1 == OMX_ALL), OMX_ErrorBadPortIndex); | ||
383 | pLocalCmdData = OSAL_Malloc(sizeof(OMX_MARKTYPE)); | ||
384 | OMX_CHECK(pLocalCmdData != NULL, OMX_ErrorInsufficientResources); | ||
385 | OSAL_Memcpy(pLocalCmdData, pCmdData, sizeof(OMX_MARKTYPE)); | ||
386 | break; | ||
387 | |||
388 | case OMX_CommandFlush : | ||
389 | OMX_CHECK((nParam1 < (nStartPortNumber + nPorts)) || | ||
390 | (nParam1 == OMX_ALL), OMX_ErrorBadPortIndex); | ||
391 | break; | ||
392 | |||
393 | default : | ||
394 | OMX_CHECK(OMX_FALSE, OMX_ErrorBadParameter); | ||
395 | } | ||
396 | |||
397 | /*Return error if port enable/disable command is sent on an already | ||
398 | enabled/disabled port*/ | ||
399 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
400 | /*For mark buffer store pCmdData in a separate pipe - to be freed up during | ||
401 | command complete callback*/ | ||
402 | if( Cmd == OMX_CommandMarkBuffer ) { | ||
403 | /*If pipe is full, return error - thus a limitation that currently | ||
404 | cannot queue up more than OMXBase_MAXCMDS mark buffer commands*/ | ||
405 | tStatus = OSAL_WriteToPipe(pBaseCompPvt->pCmdDataPipe, | ||
406 | &pLocalCmdData, sizeof(OMX_PTR), OSAL_NO_SUSPEND); | ||
407 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
408 | } | ||
409 | /*Obtain mutex for writing to command pipe*/ | ||
410 | tStatus = OSAL_ObtainMutex(pBaseCompPvt->pCmdPipeMutex, OSAL_SUSPEND); | ||
411 | if((tStatus != OSAL_ErrNone) && (Cmd == OMX_CommandMarkBuffer)) { | ||
412 | bFreeCmdDataIfError = OMX_FALSE; | ||
413 | } | ||
414 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
415 | |||
416 | /* keep this info, and process later */ | ||
417 | sCmdParams.eCmd = Cmd; | ||
418 | sCmdParams.unParam = nParam1; | ||
419 | if( Cmd == OMX_CommandMarkBuffer ) { | ||
420 | sCmdParams.pCmdData = pLocalCmdData; | ||
421 | } else { | ||
422 | sCmdParams.pCmdData = pCmdData; | ||
423 | } | ||
424 | tStatus = OSAL_WriteToPipe(pBaseCompPvt->pCmdPipe, &sCmdParams, | ||
425 | sizeof(sCmdParams), OSAL_SUSPEND); | ||
426 | if( tStatus != OSAL_ErrNone ) { | ||
427 | /*Do not free pLocalCmdData in this case since it has been pushed to | ||
428 | pipe and will now be freed during deinit when pipe is deleted*/ | ||
429 | if( Cmd == OMX_CommandMarkBuffer ) { | ||
430 | bFreeCmdDataIfError = OMX_FALSE; | ||
431 | } | ||
432 | /*Release the locked mutex and exit with error*/ | ||
433 | eError = OMX_ErrorInsufficientResources; | ||
434 | tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); | ||
435 | goto EXIT; | ||
436 | } | ||
437 | /* This call invokes the process function directly incase if comp | ||
438 | * does process in client context, otherwise triggers compo thread */ | ||
439 | eError = pBaseCompPvt->fpInvokeProcessFunction(hComponent, CMDEVENT); | ||
440 | if( eError != OMX_ErrorNone ) { | ||
441 | if( Cmd == OMX_CommandMarkBuffer ) { | ||
442 | /*Do not free pLocalCmdData in this case since it has been pushed to | ||
443 | pipe and will now be freed during deinit when pipe is deleted*/ | ||
444 | bFreeCmdDataIfError = OMX_FALSE; | ||
445 | } | ||
446 | /*Get the count in cmd pipe - this is to be used for popping the | ||
447 | recently added cmd to the pipe since that is no longer valid*/ | ||
448 | tStatus = OSAL_GetPipeReadyMessageCount(pBaseCompPvt->pCmdPipe, | ||
449 | &nCmdCount); | ||
450 | if( tStatus != OSAL_ErrNone ) { | ||
451 | /*Release mutex and return error*/ | ||
452 | eError = OMX_ErrorUndefined; | ||
453 | tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); | ||
454 | goto EXIT; | ||
455 | } | ||
456 | |||
457 | for( i = 0; i < nCmdCount; i++ ) { | ||
458 | /*Clear the last command from pipe since error has occured*/ | ||
459 | tStatus = OSAL_ReadFromPipe(pBaseCompPvt->pCmdPipe, &sErrorCmdParams, | ||
460 | sizeof(sErrorCmdParams), &nActualSize, | ||
461 | OSAL_SUSPEND); | ||
462 | if( tStatus != OSAL_ErrNone ) { | ||
463 | eError = OMX_ErrorUndefined; | ||
464 | break; | ||
465 | } | ||
466 | if( OSAL_Memcmp(&sErrorCmdParams, &sCmdParams, sizeof(OMXBase_CmdParams)) == 0 ) { | ||
467 | OSAL_ErrorTrace("Found the command to discard"); | ||
468 | break; | ||
469 | } else { | ||
470 | /*This is not the command to be discarded - write it back to | ||
471 | pipe*/ | ||
472 | tStatus = OSAL_WriteToPipe(pBaseCompPvt->pCmdPipe, | ||
473 | &sErrorCmdParams, sizeof(sErrorCmdParams), | ||
474 | OSAL_SUSPEND); | ||
475 | if( tStatus != OSAL_ErrNone ) { | ||
476 | OSAL_ErrorTrace("Write to pipe failed"); | ||
477 | eError = OMX_ErrorUndefined; | ||
478 | break; | ||
479 | } | ||
480 | } | ||
481 | } | ||
482 | |||
483 | if( i == nCmdCount ) { | ||
484 | /*The command to discard was not found even after going through the | ||
485 | pipe*/ | ||
486 | OSAL_ErrorTrace("Command to be discarded not found in pipe"); | ||
487 | eError = OMX_ErrorUndefined; | ||
488 | } | ||
489 | } | ||
490 | tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); | ||
491 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
492 | |||
493 | EXIT: | ||
494 | if( eError != OMX_ErrorNone ) { | ||
495 | if( pLocalCmdData && bFreeCmdDataIfError ) { | ||
496 | OSAL_Free(pLocalCmdData); | ||
497 | pLocalCmdData = NULL; | ||
498 | } | ||
499 | } | ||
500 | return (eError); | ||
501 | } | ||
502 | |||
503 | /* | ||
504 | * OMX Base Get Parameter | ||
505 | */ | ||
506 | OMX_ERRORTYPE OMXBase_GetParameter(OMX_HANDLETYPE hComponent, | ||
507 | OMX_INDEXTYPE nParamIndex, | ||
508 | OMX_PTR pParamStruct) | ||
509 | { | ||
510 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
511 | OMX_COMPONENTTYPE *pComp = NULL; | ||
512 | OMXBaseComp *pBaseComp = NULL; | ||
513 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
514 | OMXBase_Port *pPort = NULL; | ||
515 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | ||
516 | OMX_PRIORITYMGMTTYPE *pPriorityMgmt = NULL; | ||
517 | OMX_PARAM_BUFFERSUPPLIERTYPE *pBufSupplier = NULL; | ||
518 | OMX_U32 nStartPortNumber, nPorts, nPortIndex; | ||
519 | |||
520 | |||
521 | OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), OMX_ErrorBadParameter); | ||
522 | |||
523 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
524 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
525 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
526 | |||
527 | nPorts = pBaseComp->nNumPorts; | ||
528 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
529 | |||
530 | /*Can't be invoked when the comp is in invalid state*/ | ||
531 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); | ||
532 | |||
533 | switch( nParamIndex ) { | ||
534 | case OMX_IndexParamAudioInit : | ||
535 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); | ||
536 | if( pBaseComp->pAudioPortParams == NULL ) { | ||
537 | OMX_BASE_INIT_STRUCT_PTR((OMX_PORT_PARAM_TYPE *)(pParamStruct), | ||
538 | OMX_PORT_PARAM_TYPE); | ||
539 | ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts = 0; | ||
540 | ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber = 0; | ||
541 | break; | ||
542 | } | ||
543 | *(OMX_PORT_PARAM_TYPE *)pParamStruct = *(pBaseComp->pAudioPortParams); | ||
544 | break; | ||
545 | |||
546 | case OMX_IndexParamImageInit : | ||
547 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); | ||
548 | if( pBaseComp->pImagePortParams == NULL ) { | ||
549 | OMX_BASE_INIT_STRUCT_PTR((OMX_PORT_PARAM_TYPE *)(pParamStruct), | ||
550 | OMX_PORT_PARAM_TYPE); | ||
551 | ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts = 0; | ||
552 | ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber = 0; | ||
553 | break; | ||
554 | } | ||
555 | *(OMX_PORT_PARAM_TYPE *)pParamStruct = *(pBaseComp->pImagePortParams); | ||
556 | break; | ||
557 | |||
558 | case OMX_IndexParamVideoInit : | ||
559 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); | ||
560 | if( pBaseComp->pVideoPortParams == NULL ) { | ||
561 | OMX_BASE_INIT_STRUCT_PTR((OMX_PORT_PARAM_TYPE *)(pParamStruct), | ||
562 | OMX_PORT_PARAM_TYPE); | ||
563 | ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts = 0; | ||
564 | ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber = 0; | ||
565 | break; | ||
566 | } | ||
567 | *(OMX_PORT_PARAM_TYPE *)pParamStruct = | ||
568 | *(pBaseComp->pVideoPortParams); | ||
569 | break; | ||
570 | |||
571 | case OMX_IndexParamOtherInit : | ||
572 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); | ||
573 | if( pBaseComp->pOtherPortParams == NULL ) { | ||
574 | OMX_BASE_INIT_STRUCT_PTR((OMX_PORT_PARAM_TYPE *)(pParamStruct), | ||
575 | OMX_PORT_PARAM_TYPE); | ||
576 | ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts = 0; | ||
577 | ((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber = 0; | ||
578 | break; | ||
579 | } | ||
580 | *(OMX_PORT_PARAM_TYPE *)pParamStruct = *(pBaseComp->pOtherPortParams); | ||
581 | break; | ||
582 | |||
583 | case OMX_IndexParamPortDefinition : | ||
584 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, | ||
585 | eError); | ||
586 | pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; | ||
587 | nPortIndex = pPortDef->nPortIndex - nStartPortNumber; | ||
588 | /* check for valid port index */ | ||
589 | OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex); | ||
590 | *pPortDef = pBaseComp->pPorts[nPortIndex]->sPortDef; | ||
591 | |||
592 | break; | ||
593 | |||
594 | case OMX_IndexParamCompBufferSupplier : | ||
595 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_BUFFERSUPPLIERTYPE, eError); | ||
596 | pBufSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE *)pParamStruct; | ||
597 | nPortIndex = pBufSupplier->nPortIndex - nStartPortNumber; | ||
598 | /* check for valid port index */ | ||
599 | OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex); | ||
600 | pPort = pBaseComp->pPorts[nPortIndex]; | ||
601 | pBufSupplier->eBufferSupplier = 0x0; | ||
602 | break; | ||
603 | |||
604 | case OMX_IndexParamPriorityMgmt : | ||
605 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PRIORITYMGMTTYPE, eError); | ||
606 | pPriorityMgmt = (OMX_PRIORITYMGMTTYPE *)pParamStruct; | ||
607 | break; | ||
608 | |||
609 | default : | ||
610 | OSAL_ErrorTrace("Unknown Index received "); | ||
611 | eError = OMX_ErrorUnsupportedIndex; | ||
612 | break; | ||
613 | } | ||
614 | |||
615 | EXIT: | ||
616 | return (eError); | ||
617 | } | ||
618 | |||
619 | /* | ||
620 | * OMX Base SetParameter | ||
621 | */ | ||
622 | OMX_ERRORTYPE OMXBase_SetParameter(OMX_HANDLETYPE hComponent, | ||
623 | OMX_INDEXTYPE nIndex, | ||
624 | OMX_PTR pParamStruct) | ||
625 | { | ||
626 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
627 | OMX_COMPONENTTYPE *pComp = NULL; | ||
628 | OMXBaseComp *pBaseComp = NULL; | ||
629 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
630 | OMXBase_Port *pPort = NULL; | ||
631 | OMX_PRIORITYMGMTTYPE *pPriorityMgmt = NULL; | ||
632 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | ||
633 | OMX_PARAM_PORTDEFINITIONTYPE *pLocalPortDef; | ||
634 | OMX_PARAM_BUFFERSUPPLIERTYPE *pBufSupplier = NULL; | ||
635 | OMX_U32 nStartPortNumber, nPorts, nPortIndex; | ||
636 | OMX_PARAM_BUFFERSUPPLIERTYPE sTunBufSupplier; | ||
637 | OMX_TI_PARAMUSENATIVEBUFFER *pParamNativeBuffer = NULL; | ||
638 | |||
639 | OMX_CHECK((hComponent != NULL) && | ||
640 | (pParamStruct != NULL), OMX_ErrorBadParameter); | ||
641 | |||
642 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
643 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
644 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
645 | nPorts = pBaseComp->nNumPorts; | ||
646 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
647 | |||
648 | /*Can't be invoked when the comp is in invalid state*/ | ||
649 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, | ||
650 | OMX_ErrorInvalidState); | ||
651 | /* This method is not allowed when the component is not in the loaded | ||
652 | * state or the the port is not disabled */ | ||
653 | if((OMX_IndexParamPriorityMgmt == nIndex | ||
654 | || OMX_IndexParamAudioInit == nIndex | ||
655 | || OMX_IndexParamVideoInit == nIndex | ||
656 | || OMX_IndexParamImageInit == nIndex | ||
657 | || OMX_IndexParamOtherInit == nIndex) | ||
658 | && (pBaseComp->tCurState != OMX_StateLoaded)) { | ||
659 | eError = OMX_ErrorIncorrectStateOperation; | ||
660 | goto EXIT; | ||
661 | } | ||
662 | |||
663 | switch( (int) nIndex ) { | ||
664 | case OMX_IndexParamPriorityMgmt : | ||
665 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PRIORITYMGMTTYPE, eError); | ||
666 | pPriorityMgmt = (OMX_PRIORITYMGMTTYPE *)pParamStruct; | ||
667 | break; | ||
668 | |||
669 | case OMX_IndexParamPortDefinition : | ||
670 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, | ||
671 | eError); | ||
672 | pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; | ||
673 | |||
674 | nPortIndex = pPortDef->nPortIndex - nStartPortNumber; | ||
675 | /* check for valid port index */ | ||
676 | OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex); | ||
677 | pPort = pBaseComp->pPorts[nPortIndex]; | ||
678 | /* successfully only when the comp is in loaded or disabled port */ | ||
679 | OMX_CHECK((pBaseComp->tCurState == OMX_StateLoaded) || | ||
680 | (pPort->sPortDef.bEnabled == OMX_FALSE), | ||
681 | OMX_ErrorIncorrectStateOperation); | ||
682 | |||
683 | pLocalPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; | ||
684 | /*Copying only the modifiabke fields. Rest are all read only fields*/ | ||
685 | pBaseComp->pPorts[nPortIndex]->sPortDef.nBufferCountActual = | ||
686 | pLocalPortDef->nBufferCountActual; | ||
687 | pBaseComp->pPorts[nPortIndex]->sPortDef.format = pLocalPortDef->format; | ||
688 | break; | ||
689 | |||
690 | /*These are compulsory parameters hence being supported by base*/ | ||
691 | case OMX_IndexParamAudioInit : | ||
692 | case OMX_IndexParamVideoInit : | ||
693 | case OMX_IndexParamImageInit : | ||
694 | case OMX_IndexParamOtherInit : | ||
695 | /*All fields of OMX_PORT_PARAM_TYPE are read only so SetParam will just | ||
696 | return and not overwrite anything*/ | ||
697 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PORT_PARAM_TYPE, eError); | ||
698 | break; | ||
699 | |||
700 | case OMX_TI_IndexUseNativeBuffers: | ||
701 | pParamNativeBuffer = (OMX_TI_PARAMUSENATIVEBUFFER* )pParamStruct; | ||
702 | if(pParamNativeBuffer->bEnable == OMX_TRUE) { | ||
703 | pBaseComp->pPorts[pParamNativeBuffer->nPortIndex - nStartPortNumber]->sProps.eBufMemoryType = MEM_GRALLOC; | ||
704 | } else { | ||
705 | pBaseComp->pPorts[pParamNativeBuffer->nPortIndex - nStartPortNumber]->sProps.eBufMemoryType = MEM_CARVEOUT; | ||
706 | } | ||
707 | break; | ||
708 | |||
709 | default : | ||
710 | eError = OMX_ErrorUnsupportedIndex; | ||
711 | break; | ||
712 | } | ||
713 | |||
714 | EXIT: | ||
715 | return (eError); | ||
716 | } | ||
717 | |||
718 | /* | ||
719 | * OMX Base AllocatBuffer | ||
720 | */ | ||
721 | OMX_ERRORTYPE OMXBase_AllocateBuffer(OMX_HANDLETYPE hComponent, | ||
722 | OMX_BUFFERHEADERTYPE * *ppBufferHdr, | ||
723 | OMX_U32 nPortIndex, | ||
724 | OMX_PTR pAppPrivate, | ||
725 | OMX_U32 nSizeBytes) | ||
726 | { | ||
727 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
728 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
729 | OMX_COMPONENTTYPE *pComp = NULL; | ||
730 | OMXBaseComp *pBaseComp = NULL; | ||
731 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
732 | OMXBase_Port *pPort = NULL; | ||
733 | OMX_DIO_CreateParams sDIOCreateParams; | ||
734 | OMX_DIO_OpenParams sDIOOpenParams; | ||
735 | OMX_U32 nStartPortNumber = 0, nPorts = 0; | ||
736 | |||
737 | OMX_CHECK((hComponent != NULL) && (nSizeBytes > 0), OMX_ErrorBadParameter); | ||
738 | |||
739 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
740 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
741 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
742 | |||
743 | OSAL_ObtainMutex(pBaseCompPvt->pPortDisableMutex, OSAL_SUSPEND); | ||
744 | |||
745 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
746 | nPorts = pBaseComp->nNumPorts; | ||
747 | OMX_CHECK(nPortIndex >= nStartPortNumber && nPortIndex < nPorts, | ||
748 | OMX_ErrorBadPortIndex); | ||
749 | /*Can't be invoked when the comp is in invalid state*/ | ||
750 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, | ||
751 | OMX_ErrorInvalidState); | ||
752 | |||
753 | pPort = pBaseComp->pPorts[nPortIndex - nStartPortNumber]; | ||
754 | |||
755 | /*Buffer size should be >= the minimum buffer size specified in | ||
756 | port definition*/ | ||
757 | OMX_CHECK(nSizeBytes >= pPort->sPortDef.nBufferSize, | ||
758 | OMX_ErrorBadParameter); | ||
759 | if((pBaseComp->tCurState == OMX_StateLoaded || | ||
760 | pBaseComp->tCurState == OMX_StateWaitForResources) && | ||
761 | (pBaseComp->tNewState == OMX_StateIdle) && | ||
762 | (pPort->sPortDef.bEnabled)) { | ||
763 | /*Allowed during loaded/waitforresources --> idle transition if port is | ||
764 | enabled*/ | ||
765 | } else if((pPort->bIsInTransition) && | ||
766 | (pBaseComp->tCurState != OMX_StateLoaded) && | ||
767 | (pBaseComp->tCurState != OMX_StateWaitForResources)) { | ||
768 | /*Allowed when port is transitioning to enabled if current state is not | ||
769 | loaded/waitforresources*/ | ||
770 | } else { | ||
771 | eError = OMX_ErrorIncorrectStateOperation; | ||
772 | goto EXIT; | ||
773 | } | ||
774 | /*Port should not be already populated*/ | ||
775 | OMX_CHECK(pPort->sPortDef.bPopulated == OMX_FALSE, | ||
776 | OMX_ErrorBadParameter); | ||
777 | if( pPort->nBufferCnt == 0 ) { | ||
778 | /* Initialize DIO and open as a supplier */ | ||
779 | pPort->bIsBufferAllocator = OMX_TRUE; | ||
780 | sDIOCreateParams.hComponent = hComponent; | ||
781 | sDIOCreateParams.nPortIndex = pPort->sPortDef.nPortIndex; | ||
782 | sDIOCreateParams.pAppCallbacks = &(pBaseCompPvt->sAppCallbacks); | ||
783 | if( pPort->sPortDef.eDir == OMX_DirOutput ) { | ||
784 | sDIOOpenParams.nMode = OMX_DIO_WRITER; | ||
785 | } else { | ||
786 | sDIOOpenParams.nMode = OMX_DIO_READER; | ||
787 | } | ||
788 | |||
789 | sDIOOpenParams.nBufSize = nSizeBytes; | ||
790 | eError = OMXBase_DIO_Init(hComponent, nPortIndex, "OMX.DIO.NONTUNNEL", | ||
791 | &sDIOCreateParams); | ||
792 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
793 | eError = OMXBase_DIO_Open(hComponent, nPortIndex, &sDIOOpenParams); | ||
794 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
795 | } | ||
796 | /*update buffer header from buffer list */ | ||
797 | *ppBufferHdr = pPort->pBufferlist[pPort->nBufferCnt]; | ||
798 | if( pPort->sPortDef.eDir == OMX_DirInput ) { | ||
799 | (*ppBufferHdr)->nInputPortIndex = pPort->sPortDef.nPortIndex; | ||
800 | (*ppBufferHdr)->nOutputPortIndex = OMX_NOPORT; | ||
801 | } else if( pPort->sPortDef.eDir == OMX_DirOutput ) { | ||
802 | (*ppBufferHdr)->nOutputPortIndex = pPort->sPortDef.nPortIndex; | ||
803 | (*ppBufferHdr)->nInputPortIndex = OMX_NOPORT; | ||
804 | } | ||
805 | (*ppBufferHdr)->pAppPrivate = pAppPrivate; | ||
806 | (*ppBufferHdr)->nAllocLen = nSizeBytes; | ||
807 | |||
808 | pPort->nBufferCnt++; | ||
809 | if( pPort->sPortDef.nBufferCountActual == pPort->nBufferCnt ) { | ||
810 | pPort->sPortDef.bPopulated = OMX_TRUE; | ||
811 | tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, BUF_ALLOC_EVENT, | ||
812 | OSAL_EVENT_OR); | ||
813 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
814 | } | ||
815 | |||
816 | EXIT: | ||
817 | if ((hComponent != NULL) && (nSizeBytes > 0)) { | ||
818 | OSAL_ReleaseMutex(pBaseCompPvt->pPortDisableMutex); | ||
819 | } | ||
820 | return (eError); | ||
821 | } | ||
822 | |||
823 | /* | ||
824 | * OMX Base UseBuffer | ||
825 | */ | ||
826 | OMX_ERRORTYPE OMXBase_UseBuffer(OMX_HANDLETYPE hComponent, | ||
827 | OMX_BUFFERHEADERTYPE * *ppBufferHdr, | ||
828 | OMX_U32 nPortIndex, | ||
829 | OMX_PTR pAppPrivate, | ||
830 | OMX_U32 nSizeBytes, | ||
831 | OMX_U8 *pBuffer) | ||
832 | { | ||
833 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
834 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
835 | OMX_COMPONENTTYPE *pComp = NULL; | ||
836 | OMXBaseComp *pBaseComp = NULL; | ||
837 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
838 | OMXBase_Port *pPort = NULL; | ||
839 | OMX_DIO_CreateParams sDIOCreateParams; | ||
840 | OMX_DIO_OpenParams sDIOOpenParams; | ||
841 | OMX_U32 nStartPortNumber = 0, nPorts = 0; | ||
842 | |||
843 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
844 | |||
845 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
846 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
847 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
848 | |||
849 | OSAL_ObtainMutex(pBaseCompPvt->pPortDisableMutex, OSAL_SUSPEND); | ||
850 | |||
851 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
852 | nPorts = pBaseComp->nNumPorts; | ||
853 | OMX_CHECK(nPortIndex >= nStartPortNumber && nPortIndex < nPorts, | ||
854 | OMX_ErrorBadPortIndex); | ||
855 | /*Can't be invoked when the comp is in invalid state*/ | ||
856 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, | ||
857 | OMX_ErrorInvalidState); | ||
858 | |||
859 | pPort = pBaseComp->pPorts[nPortIndex - nStartPortNumber]; | ||
860 | |||
861 | if((pBaseComp->tCurState == OMX_StateLoaded || | ||
862 | pBaseComp->tCurState == OMX_StateWaitForResources) && | ||
863 | (pBaseComp->tNewState == OMX_StateIdle) && | ||
864 | (pPort->sPortDef.bEnabled)) { | ||
865 | /*Allowed during loaded/waitforresources --> idle transition if port is | ||
866 | enabled*/ | ||
867 | } else if((pPort->bIsInTransition) && | ||
868 | (pBaseComp->tCurState != OMX_StateLoaded) && | ||
869 | (pBaseComp->tCurState != OMX_StateWaitForResources)) { | ||
870 | /*Allowed when port is transitioning to enabled if current state is not | ||
871 | loaded/waitforresources*/ | ||
872 | } else { | ||
873 | eError = OMX_ErrorIncorrectStateOperation; | ||
874 | goto EXIT; | ||
875 | } | ||
876 | OMX_CHECK(pPort->sPortDef.bPopulated == OMX_FALSE, | ||
877 | OMX_ErrorBadParameter); | ||
878 | |||
879 | if( pPort->nBufferCnt == 0 ) { | ||
880 | /* Initialize DIO if not initialized and open as a non supplier */ | ||
881 | pPort->bIsBufferAllocator = OMX_FALSE; | ||
882 | if( pPort->hDIO == NULL) { | ||
883 | sDIOCreateParams.hComponent = hComponent; | ||
884 | sDIOCreateParams.nPortIndex = pPort->sPortDef.nPortIndex; | ||
885 | sDIOCreateParams.pAppCallbacks = &(pBaseCompPvt->sAppCallbacks); | ||
886 | |||
887 | if( pPort->sPortDef.eDir == OMX_DirOutput ) { | ||
888 | sDIOOpenParams.nMode = OMX_DIO_WRITER; | ||
889 | } else { | ||
890 | sDIOOpenParams.nMode = OMX_DIO_READER; | ||
891 | } | ||
892 | |||
893 | sDIOOpenParams.nBufSize = nSizeBytes; | ||
894 | eError = OMXBase_DIO_Init(hComponent, nPortIndex, | ||
895 | "OMX.DIO.NONTUNNEL", &sDIOCreateParams); | ||
896 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
897 | eError = OMXBase_DIO_Open(hComponent, nPortIndex, &sDIOOpenParams); | ||
898 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
899 | } | ||
900 | } | ||
901 | /*update buffer header from buffer list */ | ||
902 | pPort->pBufferlist[pPort->nBufferCnt]->pBuffer = pBuffer; | ||
903 | *ppBufferHdr = pPort->pBufferlist[pPort->nBufferCnt]; | ||
904 | if( pPort->sPortDef.eDir == OMX_DirInput ) { | ||
905 | (*ppBufferHdr)->nInputPortIndex = pPort->sPortDef.nPortIndex; | ||
906 | (*ppBufferHdr)->nOutputPortIndex = OMX_NOPORT; | ||
907 | } else if( pPort->sPortDef.eDir == OMX_DirOutput ) { | ||
908 | (*ppBufferHdr)->nOutputPortIndex = pPort->sPortDef.nPortIndex; | ||
909 | (*ppBufferHdr)->nInputPortIndex = OMX_NOPORT; | ||
910 | } | ||
911 | (*ppBufferHdr)->pAppPrivate = pAppPrivate; | ||
912 | (*ppBufferHdr)->nAllocLen = nSizeBytes; | ||
913 | |||
914 | if (pBaseComp->fpXlateBuffHandle != NULL) { | ||
915 | eError = pBaseComp->fpXlateBuffHandle(hComponent, (OMX_PTR)(*ppBufferHdr), OMX_TRUE); | ||
916 | } | ||
917 | |||
918 | pPort->nBufferCnt++; | ||
919 | if( pPort->sPortDef.nBufferCountActual == pPort->nBufferCnt ) { | ||
920 | pPort->sPortDef.bPopulated = OMX_TRUE; | ||
921 | tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, BUF_ALLOC_EVENT, | ||
922 | OSAL_EVENT_OR); | ||
923 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
924 | } | ||
925 | EXIT: | ||
926 | if (hComponent != NULL) { | ||
927 | OSAL_ReleaseMutex(pBaseCompPvt->pPortDisableMutex); | ||
928 | } | ||
929 | return (eError); | ||
930 | } | ||
931 | |||
932 | /* | ||
933 | * OMX Base FreeBuffer | ||
934 | */ | ||
935 | OMX_ERRORTYPE OMXBase_FreeBuffer(OMX_HANDLETYPE hComponent, | ||
936 | OMX_U32 nPortIndex, | ||
937 | OMX_BUFFERHEADERTYPE *pBuffHeader) | ||
938 | { | ||
939 | OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; | ||
940 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
941 | OMX_COMPONENTTYPE *pComp = NULL; | ||
942 | OMXBaseComp *pBaseComp = NULL; | ||
943 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
944 | OMXBase_Port *pPort = NULL; | ||
945 | OMX_U32 nStartPortNumber = 0, nPorts = 0; | ||
946 | |||
947 | OMX_CHECK((hComponent != NULL) && | ||
948 | (pBuffHeader != NULL), OMX_ErrorBadParameter); | ||
949 | |||
950 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
951 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
952 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
953 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
954 | nPorts = pBaseComp->nNumPorts; | ||
955 | OMX_CHECK(nPortIndex >= nStartPortNumber && nPortIndex < nPorts, | ||
956 | OMX_ErrorBadPortIndex); | ||
957 | |||
958 | pPort = pBaseComp->pPorts[nPortIndex - nStartPortNumber]; | ||
959 | |||
960 | OMX_BASE_CHK_VERSION(pBuffHeader, OMX_BUFFERHEADERTYPE, eError); | ||
961 | /*Free buffer should not be called on a port after all buffers have been | ||
962 | freed*/ | ||
963 | OMX_CHECK(pPort->nBufferCnt != 0, OMX_ErrorBadParameter); | ||
964 | |||
965 | /* unregister the buffer with decoder for non-allocator port*/ | ||
966 | if (!pPort->bIsBufferAllocator && pBaseComp->fpXlateBuffHandle != NULL) { | ||
967 | eError = pBaseComp->fpXlateBuffHandle(hComponent, (OMX_PTR)(pBuffHeader), OMX_FALSE); | ||
968 | } | ||
969 | |||
970 | /* Just decrement the buffer count and unpopulate the port, | ||
971 | * buffer header pool is freed up once all the buffers are received */ | ||
972 | pPort->nBufferCnt--; | ||
973 | pPort->sPortDef.bPopulated = OMX_FALSE; | ||
974 | if( pBaseComp->tCurState == OMX_StateIdle && | ||
975 | pBaseComp->tNewState == OMX_StateLoaded && pPort->sPortDef.bEnabled ) { | ||
976 | /*Allowed on idle --> loaded transition if port is enabled*/ | ||
977 | } else if((pPort->bIsInTransition) && | ||
978 | (pBaseComp->tCurState != OMX_StateLoaded) && | ||
979 | (pBaseComp->tCurState != OMX_StateWaitForResources)) { | ||
980 | /*Allowed during port disable if current state is not | ||
981 | loaded/waitforresources*/ | ||
982 | } else { | ||
983 | eError = pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
984 | pComp->pApplicationPrivate, | ||
985 | OMX_EventError, (OMX_U32)OMX_ErrorPortUnpopulated, | ||
986 | nPortIndex, " PortUnpopulated "); | ||
987 | /*Ideally callback should never return error*/ | ||
988 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
989 | } | ||
990 | if( pPort->nBufferCnt == 0 ) { | ||
991 | tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, BUF_FREE_EVENT, | ||
992 | OSAL_EVENT_OR); | ||
993 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
994 | } | ||
995 | |||
996 | EXIT: | ||
997 | if((eTmpError != OMX_ErrorNone) && (eError == OMX_ErrorNone)) { | ||
998 | /*An error occured earlier but we still continued cleanup to avoid leaks. | ||
999 | Setting the return value to the error code now*/ | ||
1000 | eError = eTmpError; | ||
1001 | } | ||
1002 | return (eError); | ||
1003 | } | ||
1004 | |||
1005 | /* | ||
1006 | * Empty This Buffer | ||
1007 | */ | ||
1008 | OMX_ERRORTYPE OMXBase_EmptyThisBuffer(OMX_HANDLETYPE hComponent, | ||
1009 | OMX_BUFFERHEADERTYPE *pBuffer) | ||
1010 | { | ||
1011 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1012 | OMX_COMPONENTTYPE *pComp = NULL; | ||
1013 | OMXBaseComp *pBaseComp = NULL; | ||
1014 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
1015 | OMXBase_Port *pPort = NULL; | ||
1016 | OMX_U32 nPorts, nStartPortNumber; | ||
1017 | |||
1018 | OMX_CHECK((hComponent != NULL) && | ||
1019 | (pBuffer != NULL), OMX_ErrorBadParameter); | ||
1020 | |||
1021 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1022 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1023 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1024 | nPorts = pBaseComp->nNumPorts; | ||
1025 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
1026 | |||
1027 | /*Can't be invoked when the comp is in invalid state*/ | ||
1028 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); | ||
1029 | /* check for valid port index */ | ||
1030 | OMX_CHECK(pBuffer->nInputPortIndex < (nPorts + nStartPortNumber), OMX_ErrorBadPortIndex); | ||
1031 | |||
1032 | pPort = pBaseComp->pPorts[pBuffer->nInputPortIndex - nStartPortNumber]; | ||
1033 | if( pPort->sPortDef.eDir != OMX_DirInput ) { | ||
1034 | eError = OMX_ErrorIncorrectStateOperation; | ||
1035 | goto EXIT; | ||
1036 | } | ||
1037 | |||
1038 | /* This method is allowed only when the comp is in or a transition | ||
1039 | * to executing or pause state */ | ||
1040 | OMX_CHECK((pBaseComp->tCurState == OMX_StateIdle && | ||
1041 | pBaseComp->tNewState == OMX_StateExecuting) || | ||
1042 | (pBaseComp->tCurState == OMX_StateExecuting || | ||
1043 | pBaseComp->tCurState == OMX_StatePause), | ||
1044 | OMX_ErrorIncorrectStateOperation); | ||
1045 | |||
1046 | /*Following two checks are based on the 1.1.2 AppNote*/ | ||
1047 | /*Supplier ports can accept buffers even if current state is disabled | ||
1048 | if they are transitioning from port enable to disable*/ | ||
1049 | if( pPort->sPortDef.bEnabled != OMX_TRUE ) { | ||
1050 | if((!pPort->bIsInTransition) || (!pPort->bIsBufferAllocator)) { | ||
1051 | eError = OMX_ErrorIncorrectStateOperation; | ||
1052 | goto EXIT; | ||
1053 | } | ||
1054 | } | ||
1055 | /*Non-supplier ports can't accept buffers when transitioning to Idle | ||
1056 | or when port is being transitioned to disabled*/ | ||
1057 | if( !pPort->bIsBufferAllocator) { | ||
1058 | if((pBaseComp->tNewState == OMX_StateIdle) || (pPort->bIsInTransition)) { | ||
1059 | eError = OMX_ErrorIncorrectStateOperation; | ||
1060 | goto EXIT; | ||
1061 | } | ||
1062 | } | ||
1063 | eError = OMXBase_DIO_Queue(hComponent, pBuffer->nInputPortIndex, pBuffer); | ||
1064 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1065 | ((OMXBase_BufHdrPvtData *)(pBuffer->pPlatformPrivate))->bufSt = OWNED_BY_US; | ||
1066 | |||
1067 | /*If another buffer comes after eos then reset the variable that causes | ||
1068 | watermark to become meaningless on this port*/ | ||
1069 | if( pPort->bEosRecd == OMX_TRUE ) { | ||
1070 | pPort->bEosRecd = OMX_FALSE; | ||
1071 | } | ||
1072 | /*If EOS buffer or CodecConfig buffer then force notify to derived component*/ | ||
1073 | if( pBuffer->nFlags & OMX_BUFFERFLAG_EOS ) { | ||
1074 | pPort->bEosRecd = OMX_TRUE; | ||
1075 | } | ||
1076 | eError = pBaseCompPvt->fpInvokeProcessFunction(hComponent, DATAEVENT); | ||
1077 | |||
1078 | EXIT: | ||
1079 | return (eError); | ||
1080 | } | ||
1081 | |||
1082 | /* | ||
1083 | * OMX Base FillThisBuffer | ||
1084 | */ | ||
1085 | OMX_ERRORTYPE OMXBase_FillThisBuffer(OMX_HANDLETYPE hComponent, | ||
1086 | OMX_BUFFERHEADERTYPE *pBuffer) | ||
1087 | { | ||
1088 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1089 | OMX_COMPONENTTYPE *pComp = NULL; | ||
1090 | OMXBaseComp *pBaseComp = NULL; | ||
1091 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
1092 | OMXBase_Port *pPort = NULL; | ||
1093 | OMX_U32 nPorts, nStartPortNumber; | ||
1094 | |||
1095 | OMX_CHECK((hComponent != NULL) && (pBuffer != NULL), OMX_ErrorBadParameter); | ||
1096 | OMX_CHECK(pBuffer->pBuffer != NULL, OMX_ErrorBadParameter); | ||
1097 | |||
1098 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1099 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1100 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1101 | nPorts = pBaseComp->nNumPorts; | ||
1102 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
1103 | |||
1104 | /*Can't be invoked when the comp is in invalid state*/ | ||
1105 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, | ||
1106 | OMX_ErrorInvalidState); | ||
1107 | |||
1108 | /* check for valid port index */ | ||
1109 | OMX_CHECK(pBuffer->nOutputPortIndex < (nPorts + | ||
1110 | nStartPortNumber), OMX_ErrorBadPortIndex); | ||
1111 | |||
1112 | pPort = pBaseComp->pPorts[pBuffer->nOutputPortIndex - nStartPortNumber]; | ||
1113 | if( pPort->sPortDef.eDir != OMX_DirOutput ) { | ||
1114 | eError = OMX_ErrorIncorrectStateOperation; | ||
1115 | goto EXIT; | ||
1116 | } | ||
1117 | |||
1118 | /* This method is allowed only when the comp is in or a transition | ||
1119 | * to executing or pause state */ | ||
1120 | OMX_CHECK((pBaseComp->tCurState == OMX_StateIdle && | ||
1121 | pBaseComp->tNewState == OMX_StateExecuting) || | ||
1122 | (pBaseComp->tCurState == OMX_StateExecuting || | ||
1123 | pBaseComp->tCurState == OMX_StatePause), | ||
1124 | OMX_ErrorIncorrectStateOperation); | ||
1125 | /*Following two checks are based on the 1.1.2 AppNote*/ | ||
1126 | /*Supplier ports can accept buffers even if current state is disabled | ||
1127 | if they are transitioning from port enable to disable*/ | ||
1128 | if( pPort->sPortDef.bEnabled != OMX_TRUE ) { | ||
1129 | if((!pPort->bIsInTransition) || (!pPort->bIsBufferAllocator)) { | ||
1130 | eError = OMX_ErrorIncorrectStateOperation; | ||
1131 | goto EXIT; | ||
1132 | } | ||
1133 | } | ||
1134 | /*Non-supplier ports can't accept buffers when transitioning to Idle | ||
1135 | or when port is being transitioned to disabled*/ | ||
1136 | if( !pPort->bIsBufferAllocator) { | ||
1137 | if((pBaseComp->tNewState == OMX_StateIdle) || | ||
1138 | (pPort->bIsInTransition)) { | ||
1139 | eError = OMX_ErrorIncorrectStateOperation; | ||
1140 | goto EXIT; | ||
1141 | } | ||
1142 | } | ||
1143 | eError = OMXBase_DIO_Queue(hComponent, pBuffer->nOutputPortIndex, pBuffer); | ||
1144 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1145 | ((OMXBase_BufHdrPvtData *)(pBuffer->pPlatformPrivate))->bufSt = OWNED_BY_US; | ||
1146 | eError = pBaseCompPvt->fpInvokeProcessFunction(hComponent, DATAEVENT); | ||
1147 | |||
1148 | EXIT: | ||
1149 | return (eError); | ||
1150 | } | ||
1151 | |||
1152 | /* | ||
1153 | * OMX Base SetConfig | ||
1154 | */ | ||
1155 | OMX_ERRORTYPE OMXBase_SetConfig(OMX_HANDLETYPE hComponent, | ||
1156 | OMX_INDEXTYPE nIndex, | ||
1157 | OMX_PTR pComponentConfigStructure) | ||
1158 | { | ||
1159 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1160 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
1161 | OMX_COMPONENTTYPE *pComp = NULL; | ||
1162 | OMXBaseComp *pBaseComp = NULL; | ||
1163 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
1164 | OMXBase_Port *pPort = NULL; | ||
1165 | OMX_U32 nStartPortNumber, nPortIndex, nPorts; | ||
1166 | |||
1167 | OMX_CHECK((hComponent != NULL) && | ||
1168 | (pComponentConfigStructure != NULL), OMX_ErrorBadParameter); | ||
1169 | |||
1170 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1171 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1172 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1173 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
1174 | nPorts = pBaseComp->nNumPorts; | ||
1175 | |||
1176 | /*Can't be invoked when the comp is in invalid state*/ | ||
1177 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, | ||
1178 | OMX_ErrorInvalidState); | ||
1179 | |||
1180 | switch( nIndex ) { | ||
1181 | default : | ||
1182 | eError = OMX_ErrorUnsupportedIndex; | ||
1183 | break; | ||
1184 | } | ||
1185 | |||
1186 | EXIT: | ||
1187 | return (eError); | ||
1188 | } | ||
1189 | |||
1190 | /* | ||
1191 | * OMX Base GetConfig | ||
1192 | */ | ||
1193 | OMX_ERRORTYPE OMXBase_GetConfig(OMX_HANDLETYPE hComponent, | ||
1194 | OMX_INDEXTYPE nIndex, | ||
1195 | OMX_PTR pComponentConfigStructure) | ||
1196 | { | ||
1197 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1198 | OMX_COMPONENTTYPE *pComp = NULL; | ||
1199 | OMXBaseComp *pBaseComp = NULL; | ||
1200 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
1201 | OMXBase_Port *pPort = NULL; | ||
1202 | OMX_U32 nStartPortNumber, nPortIndex, nPorts; | ||
1203 | |||
1204 | OMX_CHECK((hComponent != NULL) && | ||
1205 | (pComponentConfigStructure != NULL), OMX_ErrorBadParameter); | ||
1206 | |||
1207 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1208 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1209 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1210 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
1211 | nPorts = pBaseComp->nNumPorts; | ||
1212 | |||
1213 | /*Can't be invoked when the comp is in invalid state*/ | ||
1214 | OMX_CHECK(OMX_StateInvalid != pBaseComp->tCurState, OMX_ErrorInvalidState); | ||
1215 | |||
1216 | switch( nIndex ) { | ||
1217 | default : | ||
1218 | eError = OMX_ErrorUnsupportedIndex; | ||
1219 | break; | ||
1220 | } | ||
1221 | |||
1222 | EXIT: | ||
1223 | return (eError); | ||
1224 | } | ||
1225 | |||
1226 | /* | ||
1227 | * OMX Base UseEGLImage | ||
1228 | */ | ||
1229 | OMX_ERRORTYPE OMXBase_UseEGLImage(OMX_HANDLETYPE hComponent, | ||
1230 | OMX_BUFFERHEADERTYPE * *ppBufferHdr, | ||
1231 | OMX_U32 nPortIndex, | ||
1232 | OMX_PTR pAppPrivate, | ||
1233 | void *eglImage) | ||
1234 | { | ||
1235 | (void)hComponent, ppBufferHdr, nPortIndex, pAppPrivate, eglImage; | ||
1236 | return (OMX_ErrorNotImplemented); | ||
1237 | } | ||
1238 | |||
1239 | /* | ||
1240 | * OMX Base GetExtentionIndex | ||
1241 | */ | ||
1242 | OMX_ERRORTYPE OMXBase_GetExtensionIndex(OMX_HANDLETYPE hComponent, | ||
1243 | OMX_STRING cParameterName, | ||
1244 | OMX_INDEXTYPE *pIndexType) | ||
1245 | { | ||
1246 | (void)hComponent, cParameterName, pIndexType; | ||
1247 | return (OMX_ErrorNotImplemented); | ||
1248 | } | ||
1249 | |||
1250 | /* | ||
1251 | * OMX Base ComponentRoleEnum | ||
1252 | */ | ||
1253 | OMX_ERRORTYPE OMXBase_ComponentRoleEnum(OMX_HANDLETYPE hComponent, | ||
1254 | OMX_U8 *cRole, | ||
1255 | OMX_U32 nIndex) | ||
1256 | { | ||
1257 | (void)hComponent, cRole, nIndex; | ||
1258 | return (OMX_ErrorNotImplemented); | ||
1259 | } | ||
1260 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_BASE_CALLBACKS" | ||
18 | |||
19 | #include <OMX_Core.h> | ||
20 | #include <omx_base.h> | ||
21 | |||
22 | /* | ||
23 | * OMX Base callback ReturnEventNotify | ||
24 | */ | ||
25 | OMX_ERRORTYPE OMXBase_CB_ReturnEventNotify(OMX_HANDLETYPE hComponent, | ||
26 | OMX_EVENTTYPE eEvent, | ||
27 | OMX_U32 nData1, OMX_U32 nData2, | ||
28 | OMX_PTR pEventData) | ||
29 | { | ||
30 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
31 | OMX_COMPONENTTYPE *pComp = NULL; | ||
32 | OMXBaseComp *pBaseComp = NULL; | ||
33 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
34 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
35 | uint32_t nActualSize = 0; | ||
36 | OMX_PTR pCmdData = NULL; | ||
37 | |||
38 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
39 | |||
40 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
41 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
42 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
43 | |||
44 | switch( eEvent ) { | ||
45 | case OMX_EventCmdComplete : | ||
46 | if((OMX_COMMANDTYPE)nData1 == OMX_CommandStateSet ) { | ||
47 | OSAL_SetEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
48 | OMXBase_CmdStateSet, OSAL_EVENT_OR); | ||
49 | } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandPortEnable ) { | ||
50 | OSAL_SetEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
51 | OMXBase_CmdPortEnable, OSAL_EVENT_OR); | ||
52 | } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandPortDisable ) { | ||
53 | OSAL_SetEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
54 | OMXBase_CmdPortDisable, OSAL_EVENT_OR); | ||
55 | } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandFlush ) { | ||
56 | OSAL_SetEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
57 | OMXBase_CmdFlush, OSAL_EVENT_OR); | ||
58 | } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandMarkBuffer ) { | ||
59 | /*The derived component has completed the mark buffer command so | ||
60 | the memory allocated for pCmdData is no longer needed - it can | ||
61 | be freed up*/ | ||
62 | tStatus = OSAL_ReadFromPipe(pBaseCompPvt->pCmdDataPipe, | ||
63 | &pCmdData, sizeof(OMX_PTR), &nActualSize, | ||
64 | OSAL_NO_SUSPEND); | ||
65 | /*Read from pipe should return immediately with valid value - if | ||
66 | it does not, return error callback to the client*/ | ||
67 | if( OSAL_ErrNone != tStatus ) { | ||
68 | OSAL_ErrorTrace("pCmdData not available to freed up at mark \ | ||
69 | buffer command completion. Returning error event."); | ||
70 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
71 | pComp->pApplicationPrivate, OMX_EventError, | ||
72 | (OMX_U32)OMX_ErrorInsufficientResources, 0, NULL); | ||
73 | goto EXIT; | ||
74 | } | ||
75 | OSAL_Free(pCmdData); | ||
76 | /*For mark buffer cmd complete, directly send callback to the | ||
77 | client. This callback is not being handled in | ||
78 | OMXBase_EventNotifyToClient since this can happen much later | ||
79 | than the time when the mark comand was received*/ | ||
80 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
81 | pComp->pApplicationPrivate, eEvent, nData1, nData2, | ||
82 | pEventData); | ||
83 | } | ||
84 | break; | ||
85 | |||
86 | case OMX_EventError : | ||
87 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
88 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
89 | break; | ||
90 | |||
91 | case OMX_EventMark : | ||
92 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
93 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
94 | break; | ||
95 | |||
96 | case OMX_EventPortSettingsChanged : | ||
97 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
98 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
99 | break; | ||
100 | |||
101 | case OMX_EventBufferFlag : | ||
102 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
103 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
104 | break; | ||
105 | |||
106 | case OMX_EventResourcesAcquired : | ||
107 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
108 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
109 | break; | ||
110 | |||
111 | case OMX_EventComponentResumed : | ||
112 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
113 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
114 | break; | ||
115 | |||
116 | case OMX_EventDynamicResourcesAvailable : | ||
117 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
118 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
119 | break; | ||
120 | |||
121 | case OMX_EventPortFormatDetected : | ||
122 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
123 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
124 | break; | ||
125 | |||
126 | default : | ||
127 | OSAL_ErrorTrace("Unknown event received - still making callback"); | ||
128 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
129 | pComp->pApplicationPrivate, eEvent, nData1, nData2, pEventData); | ||
130 | break; | ||
131 | } | ||
132 | |||
133 | EXIT: | ||
134 | return (eError); | ||
135 | } | ||
136 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_BASE_INTERNAL" | ||
18 | |||
19 | #include <string.h> | ||
20 | |||
21 | #include <OMX_Core.h> | ||
22 | #include <OMX_Component.h> | ||
23 | #include <omx_base.h> | ||
24 | #include <omx_base_dio_plugin.h> | ||
25 | #include <osal_semaphores.h> | ||
26 | |||
27 | #define OMXBase_TASKDEL_TRIES 1000 | ||
28 | #define OMXBase_TASKDEL_SLEEP 2 | ||
29 | #define BUFFER_ALLOC_FREE_TIMEOUT 900 //900ms | ||
30 | |||
31 | #define OMX_BASE_HANDLE_IDLE_TO_LOADED_TRANSITION() do { \ | ||
32 | for( i=0; i < pBaseComp->nNumPorts; i++ ) \ | ||
33 | { \ | ||
34 | pPort = pBaseComp->pPorts[i]; \ | ||
35 | if( pPort->pBufAllocFreeEvent ) \ | ||
36 | { \ | ||
37 | tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, \ | ||
38 | BUF_FAIL_EVENT, OSAL_EVENT_OR); \ | ||
39 | if( tStatus != OSAL_ErrNone ) { \ | ||
40 | eError = OMX_ErrorUndefined; } \ | ||
41 | } \ | ||
42 | } \ | ||
43 | retEvents = 0; \ | ||
44 | tStatus = OSAL_RetrieveEvent( \ | ||
45 | pBaseCompPvt->pErrorCmdcompleteEvent, \ | ||
46 | ERROR_EVENT, OSAL_EVENT_OR_CONSUME, &retEvents, \ | ||
47 | STATE_TRANSITION_LONG_TIMEOUT); \ | ||
48 | OMX_CHECK(tStatus == OSAL_ErrNone, \ | ||
49 | OMX_ErrorUndefined); \ | ||
50 | } while( 0 ) | ||
51 | |||
52 | |||
53 | /* | ||
54 | * OMX Base Private Init | ||
55 | */ | ||
56 | OMX_ERRORTYPE OMXBase_PrivateInit(OMX_HANDLETYPE hComponent) | ||
57 | { | ||
58 | OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; | ||
59 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
60 | OMX_COMPONENTTYPE *pComp = NULL; | ||
61 | OMXBaseComp *pBaseComp = NULL; | ||
62 | |||
63 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
64 | |||
65 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
66 | pBaseComp = (OMXBaseComp*)pComp->pComponentPrivate; | ||
67 | OMX_CHECK(pBaseComp != NULL, OMX_ErrorBadParameter); | ||
68 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
69 | /*Create the new state mutex*/ | ||
70 | tStatus = OSAL_CreateMutex(&(pBaseCompPvt->pNewStateMutex)); | ||
71 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
72 | |||
73 | /* create a fixed size command pipe to queueup commands */ | ||
74 | tStatus = OSAL_CreatePipe(&(pBaseCompPvt->pCmdPipe), | ||
75 | OMXBase_MAXCMDS * sizeof(OMXBase_CmdParams), | ||
76 | sizeof(OMXBase_CmdParams), 1); | ||
77 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
78 | |||
79 | |||
80 | /* create a fixed size pipe to queueup command data pointers */ | ||
81 | tStatus = OSAL_CreatePipe(&(pBaseCompPvt->pCmdDataPipe), | ||
82 | OMXBase_MAXCMDS * sizeof(OMX_PTR), | ||
83 | sizeof(OMX_PTR), 1); | ||
84 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
85 | |||
86 | /*create an Event for Command completion to be set by Dervived Component */ | ||
87 | tStatus = OSAL_CreateEvent(&(pBaseCompPvt->pCmdCompleteEvent)); | ||
88 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
89 | |||
90 | /*create an Event for state transition notifications for complete tear down of compoenent */ | ||
91 | tStatus = OSAL_CreateEvent(&(pBaseCompPvt->pErrorCmdcompleteEvent)); | ||
92 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
93 | |||
94 | /*Create mutex for cmd pipe*/ | ||
95 | tStatus = OSAL_CreateMutex(&(pBaseCompPvt->pCmdPipeMutex)); | ||
96 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
97 | |||
98 | pBaseCompPvt->fpInvokeProcessFunction = OMXBase_ProcessEvents; | ||
99 | |||
100 | tStatus = OSAL_CreateEvent(&(pBaseCompPvt->pTriggerEvent)); | ||
101 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
102 | |||
103 | /*Create mutex for port disable*/ | ||
104 | tStatus = OSAL_CreateMutex(&(pBaseCompPvt->pPortDisableMutex)); | ||
105 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
106 | |||
107 | OSAL_Memcpy(pBaseCompPvt->cTaskName, pBaseComp->cComponentName, strlen(pBaseComp->cComponentName)); | ||
108 | pBaseCompPvt->nStackSize = OMX_BASE_THREAD_STACKSIZE; | ||
109 | pBaseCompPvt->nPrioirty = OMX_BASE_THREAD_PRIORITY; | ||
110 | |||
111 | tStatus = OSAL_CreateTask(&pBaseCompPvt->pThreadId, | ||
112 | (OSAL_TaskProc)OMXBase_CompThreadEntry, 0, | ||
113 | (void *)hComponent, | ||
114 | pBaseCompPvt->nStackSize, | ||
115 | pBaseCompPvt->nPrioirty, | ||
116 | (OMX_S8 *)pBaseCompPvt->cTaskName); | ||
117 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
118 | |||
119 | pBaseCompPvt->fpInvokeProcessFunction = OMXBase_ProcessTriggerEvent; | ||
120 | |||
121 | /* Set hooks from Derived to Base communicattion */ | ||
122 | pBaseCompPvt->fpDioGetCount = OMXBase_DIO_GetCount; | ||
123 | pBaseCompPvt->fpDioQueue = OMXBase_DIO_Queue; | ||
124 | pBaseCompPvt->fpDioDequeue = OMXBase_DIO_Dequeue; | ||
125 | pBaseCompPvt->fpDioSend = OMXBase_DIO_Send; | ||
126 | pBaseCompPvt->fpDioCancel = OMXBase_DIO_Cancel; | ||
127 | pBaseCompPvt->fpDioControl = OMXBase_DIO_Control; | ||
128 | |||
129 | EXIT: | ||
130 | return eError; | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * OMX Base Private DeInit | ||
135 | */ | ||
136 | |||
137 | OMX_ERRORTYPE OMXBase_PrivateDeInit(OMX_HANDLETYPE hComponent) | ||
138 | { | ||
139 | OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; | ||
140 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
141 | OMX_COMPONENTTYPE *pComp = NULL; | ||
142 | OMXBaseComp *pBaseComp = NULL; | ||
143 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
144 | OMX_U32 i = 0, nTries = 0; | ||
145 | uint32_t nCount = 0; | ||
146 | OMX_PTR pData = NULL; | ||
147 | uint32_t nActualSize = 0; | ||
148 | |||
149 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
150 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
151 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
152 | OMX_CHECK(pBaseComp != NULL, OMX_ErrorBadParameter); | ||
153 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
154 | |||
155 | /* set an ENDEVENT before destroying thread */ | ||
156 | pBaseCompPvt->fpInvokeProcessFunction(hComponent, ENDEVENT); | ||
157 | tStatus = OSAL_DeleteTask(pBaseCompPvt->pThreadId); | ||
158 | |||
159 | while( tStatus == OSAL_ErrNotReady && | ||
160 | nTries < OMXBase_TASKDEL_TRIES ) { | ||
161 | //Wait for some time and try again | ||
162 | OSAL_SleepTask(OMXBase_TASKDEL_SLEEP); | ||
163 | nTries++; | ||
164 | tStatus = OSAL_DeleteTask(pBaseCompPvt->pThreadId); | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | * Obtain the mutex after deleting the task. The task may be | ||
169 | * currently executing and may need access to the mutex to | ||
170 | * properly exit | ||
171 | */ | ||
172 | OSAL_ObtainMutex(pBaseCompPvt->pNewStateMutex, OSAL_SUSPEND); | ||
173 | |||
174 | if( tStatus != OSAL_ErrNone ) { | ||
175 | eError = OMX_ErrorTimeout; | ||
176 | OSAL_ErrorTrace("Error while deleting task"); | ||
177 | } | ||
178 | if( pBaseCompPvt->pTriggerEvent ) { | ||
179 | tStatus = OSAL_DeleteEvent(pBaseCompPvt->pTriggerEvent); | ||
180 | if( tStatus != OSAL_ErrNone ) { | ||
181 | eError = OMX_ErrorUndefined; | ||
182 | } | ||
183 | pBaseCompPvt->pTriggerEvent = NULL; | ||
184 | } | ||
185 | |||
186 | if( pBaseCompPvt->pCmdCompleteEvent ) { | ||
187 | tStatus = OSAL_DeleteEvent(pBaseCompPvt->pCmdCompleteEvent); | ||
188 | if( tStatus != OSAL_ErrNone ) { | ||
189 | eError = OMX_ErrorUndefined; | ||
190 | } | ||
191 | pBaseCompPvt->pCmdCompleteEvent = NULL; | ||
192 | } | ||
193 | if( pBaseCompPvt->pErrorCmdcompleteEvent ) { | ||
194 | tStatus = OSAL_DeleteEvent(pBaseCompPvt->pErrorCmdcompleteEvent); | ||
195 | if( tStatus != OSAL_ErrNone ) { | ||
196 | eError = OMX_ErrorUndefined; | ||
197 | } | ||
198 | pBaseCompPvt->pErrorCmdcompleteEvent = NULL; | ||
199 | } | ||
200 | if( pBaseCompPvt->pCmdPipe ) { | ||
201 | tStatus = OSAL_DeletePipe(pBaseCompPvt->pCmdPipe); | ||
202 | if( tStatus != OSAL_ErrNone ) { | ||
203 | eError = OMX_ErrorUndefined; | ||
204 | } | ||
205 | pBaseCompPvt->pCmdPipe = NULL; | ||
206 | } | ||
207 | if( pBaseCompPvt->pCmdDataPipe ) { | ||
208 | /*If pipe still has some data then empty the data and free the memory*/ | ||
209 | tStatus = OSAL_GetPipeReadyMessageCount(pBaseCompPvt->pCmdDataPipe, | ||
210 | &nCount); | ||
211 | if( tStatus != OSAL_ErrNone ) { | ||
212 | eError = OMX_ErrorUndefined; | ||
213 | } else { | ||
214 | while( nCount > 0 ) { | ||
215 | tStatus = OSAL_ReadFromPipe(pBaseCompPvt->pCmdDataPipe, | ||
216 | pData, sizeof(OMX_PTR), &nActualSize, OSAL_NO_SUSPEND); | ||
217 | if( tStatus != OSAL_ErrNone ) { | ||
218 | eError = OMX_ErrorUndefined; | ||
219 | break; | ||
220 | } | ||
221 | OSAL_Free(pData); | ||
222 | nCount--; | ||
223 | } | ||
224 | } | ||
225 | tStatus = OSAL_DeletePipe(pBaseCompPvt->pCmdDataPipe); | ||
226 | if( tStatus != OSAL_ErrNone ) { | ||
227 | eError = OMX_ErrorUndefined; | ||
228 | } | ||
229 | pBaseCompPvt->pCmdDataPipe = NULL; | ||
230 | } | ||
231 | if( pBaseCompPvt->pCmdPipeMutex ) { | ||
232 | tStatus = OSAL_DeleteMutex(pBaseCompPvt->pCmdPipeMutex); | ||
233 | if( tStatus != OSAL_ErrNone ) { | ||
234 | eError = OMX_ErrorUndefined; | ||
235 | } | ||
236 | pBaseCompPvt->pCmdPipeMutex = NULL; | ||
237 | } | ||
238 | if (pBaseCompPvt->pPortDisableMutex) { | ||
239 | tStatus = OSAL_DeleteMutex(pBaseCompPvt->pPortDisableMutex); | ||
240 | if( tStatus != OSAL_ErrNone ) { | ||
241 | eError = OMX_ErrorUndefined; | ||
242 | } | ||
243 | pBaseCompPvt->pPortDisableMutex = NULL; | ||
244 | } | ||
245 | |||
246 | OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); | ||
247 | |||
248 | if( pBaseCompPvt->pNewStateMutex ) { | ||
249 | tStatus = OSAL_DeleteMutex(pBaseCompPvt->pNewStateMutex); | ||
250 | if( tStatus != OSAL_ErrNone ) { | ||
251 | eError = OMX_ErrorUndefined; | ||
252 | } | ||
253 | pBaseCompPvt->pNewStateMutex = NULL; | ||
254 | } | ||
255 | |||
256 | EXIT: | ||
257 | return (eError); | ||
258 | } | ||
259 | |||
260 | /* | ||
261 | * OMX Base InitializePorts | ||
262 | */ | ||
263 | OMX_ERRORTYPE OMXBase_InitializePorts(OMX_HANDLETYPE hComponent) | ||
264 | { | ||
265 | OMX_COMPONENTTYPE *pComp = NULL; | ||
266 | OMXBaseComp *pBaseComp = NULL; | ||
267 | OMX_ERRORTYPE eError = OMX_ErrorNone, eTmpError = OMX_ErrorNone; | ||
268 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
269 | OMX_U32 i = 0; | ||
270 | |||
271 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
272 | |||
273 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
274 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
275 | |||
276 | pBaseComp->pPorts = (OMXBase_Port **)OSAL_Malloc(sizeof(OMXBase_Port *) * | ||
277 | pBaseComp->nNumPorts); | ||
278 | OMX_CHECK(pBaseComp->pPorts != NULL, OMX_ErrorInsufficientResources); | ||
279 | OSAL_Memset(pBaseComp->pPorts, 0, sizeof(OMXBase_Port *) * | ||
280 | pBaseComp->nNumPorts); | ||
281 | |||
282 | for( i = 0; i < pBaseComp->nNumPorts; i++ ) { | ||
283 | pBaseComp->pPorts[i] = (OMXBase_Port *)OSAL_Malloc(sizeof(OMXBase_Port)); | ||
284 | OMX_CHECK(pBaseComp->pPorts[i] != NULL, OMX_ErrorInsufficientResources); | ||
285 | OSAL_Memset(pBaseComp->pPorts[i], 0x0, sizeof(OMXBase_Port)); | ||
286 | |||
287 | OMX_BASE_INIT_STRUCT_PTR(&(pBaseComp->pPorts[i]->sPortDef), | ||
288 | OMX_PARAM_PORTDEFINITIONTYPE); | ||
289 | pBaseComp->pPorts[i]->sPortDef.nPortIndex = i; | ||
290 | |||
291 | tStatus = OSAL_CreateEvent(&(pBaseComp->pPorts[i]->pBufAllocFreeEvent)); | ||
292 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
293 | tStatus = OSAL_CreateSemaphore(&(pBaseComp->pPorts[i]->pDioOpenCloseSem), 0); | ||
294 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
295 | } | ||
296 | |||
297 | EXIT: | ||
298 | if( OMX_ErrorNone != eError ) { | ||
299 | eTmpError = eError; | ||
300 | eError = OMXBase_DeinitializePorts(hComponent); | ||
301 | eError = eTmpError; | ||
302 | } | ||
303 | return (eError); | ||
304 | } | ||
305 | |||
306 | /* | ||
307 | * OMX Base DeInitialize Ports | ||
308 | */ | ||
309 | OMX_ERRORTYPE OMXBase_DeinitializePorts(OMX_HANDLETYPE hComponent) | ||
310 | { | ||
311 | OMX_COMPONENTTYPE *pComp = NULL; | ||
312 | OMXBaseComp *pBaseComp = NULL; | ||
313 | OMXBase_Port *pPort = NULL; | ||
314 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
315 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
316 | OMX_U32 i = 0; | ||
317 | |||
318 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
319 | |||
320 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
321 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
322 | OMX_CHECK(pBaseComp != NULL, eError); | ||
323 | |||
324 | for( i=0; i < pBaseComp->nNumPorts; i++ ) { | ||
325 | if( !(pBaseComp->pPorts)) { | ||
326 | break; | ||
327 | } | ||
328 | pPort = pBaseComp->pPorts[i]; | ||
329 | if( pPort == NULL ) { | ||
330 | continue; | ||
331 | } | ||
332 | if( pPort->pDioOpenCloseSem ) { | ||
333 | tStatus = OSAL_DeleteSemaphore(pPort->pDioOpenCloseSem); | ||
334 | if( tStatus != OSAL_ErrNone ) { | ||
335 | eError = OMX_ErrorUndefined; | ||
336 | } | ||
337 | } | ||
338 | /*If any tasks are waiting on this event then send fail event to | ||
339 | indicate that component is being unloaded*/ | ||
340 | if( pPort->pBufAllocFreeEvent ) { | ||
341 | tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, | ||
342 | BUF_FAIL_EVENT, OSAL_EVENT_OR); | ||
343 | if( tStatus != OSAL_ErrNone ) { | ||
344 | eError = OMX_ErrorUndefined; | ||
345 | } | ||
346 | tStatus = OSAL_DeleteEvent(pPort->pBufAllocFreeEvent); | ||
347 | if( tStatus != OSAL_ErrNone ) { | ||
348 | eError = OMX_ErrorUndefined; | ||
349 | } | ||
350 | } | ||
351 | OSAL_Free(pPort); | ||
352 | pPort = NULL; | ||
353 | } | ||
354 | |||
355 | if( pBaseComp->pPorts ) { | ||
356 | OSAL_Free(pBaseComp->pPorts); | ||
357 | pBaseComp->pPorts = NULL; | ||
358 | } | ||
359 | |||
360 | EXIT: | ||
361 | return (eError); | ||
362 | } | ||
363 | |||
364 | |||
365 | /* | ||
366 | * OMX Base SetDefault Properties | ||
367 | */ | ||
368 | OMX_ERRORTYPE OMXBase_SetDefaultProperties(OMX_HANDLETYPE hComponent) | ||
369 | { | ||
370 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
371 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
372 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
373 | OMX_U32 nIndx = 0; | ||
374 | |||
375 | for( nIndx = 0; nIndx < (pBaseComp->nNumPorts); nIndx++ ) { | ||
376 | pBaseComp->pPorts[nIndx]->sProps.nWatermark = 1; | ||
377 | /*Frame mode is the default mode*/ | ||
378 | pBaseComp->pPorts[nIndx]->sProps.eDataAccessMode = MemAccess_8Bit; | ||
379 | |||
380 | /*Buffer allocation type is set to default*/ | ||
381 | pBaseComp->pPorts[nIndx]->sProps.eBufMemoryType = MEM_CARVEOUT; | ||
382 | /*Number of component buffers set to 1*/ | ||
383 | pBaseComp->pPorts[nIndx]->sProps.nNumComponentBuffers = 1; | ||
384 | /*No bufefr params by default. To be used in case of 2D buffers*/ | ||
385 | // pBaseComp->pPortProperties[nIndx]->pBufParams = NULL; | ||
386 | pBaseComp->pPorts[nIndx]->sProps.nTimeoutForDequeue = OSAL_SUSPEND; | ||
387 | } | ||
388 | |||
389 | pBaseComp->bNotifyForAnyPort = OMX_TRUE; | ||
390 | |||
391 | return (eError); | ||
392 | } | ||
393 | |||
394 | |||
395 | /* | ||
396 | * OMX Base ThreadEntry | ||
397 | */ | ||
398 | void OMXBase_CompThreadEntry(void *arg) | ||
399 | { | ||
400 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
401 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
402 | OMXBaseComp *pBaseComp = NULL; | ||
403 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
404 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)arg; | ||
405 | uint32_t retrievedEvents = 0; | ||
406 | |||
407 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
408 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
409 | |||
410 | while( 1 ) { | ||
411 | /* wait for Any of the event/s to process */ | ||
412 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pTriggerEvent, | ||
413 | (CMDEVENT | DATAEVENT | ENDEVENT), | ||
414 | OSAL_EVENT_OR_CONSUME, | ||
415 | &retrievedEvents, OSAL_SUSPEND); | ||
416 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorInsufficientResources); | ||
417 | /* terminate the process when it acquires an ENDEVENT */ | ||
418 | if( retrievedEvents & ENDEVENT ) { | ||
419 | break; | ||
420 | } | ||
421 | /* Process Event that has retrieved */ | ||
422 | if( retrievedEvents & CMDEVENT ) { | ||
423 | while( OSAL_IsPipeReady(pBaseCompPvt->pCmdPipe) == | ||
424 | OSAL_ErrNone ) { | ||
425 | eError = OMXBase_ProcessEvents(pComp, retrievedEvents); | ||
426 | /*Callback for error will be sent in the above function*/ | ||
427 | eError = OMX_ErrorNone; | ||
428 | } | ||
429 | retrievedEvents &= ~CMDEVENT; | ||
430 | } | ||
431 | if( retrievedEvents & DATAEVENT ) { | ||
432 | eError = OMXBase_ProcessEvents(pComp, retrievedEvents); | ||
433 | /*Callback for error will be sent in the above function*/ | ||
434 | eError = OMX_ErrorNone; | ||
435 | } | ||
436 | } | ||
437 | |||
438 | EXIT: | ||
439 | if( OMX_ErrorNone != eError ) { | ||
440 | pBaseCompPvt->sAppCallbacks.EventHandler((OMX_HANDLETYPE)pComp, | ||
441 | pComp->pApplicationPrivate, | ||
442 | OMX_EventError, eError, | ||
443 | 0, NULL); | ||
444 | } | ||
445 | } | ||
446 | |||
447 | |||
448 | /* | ||
449 | * OMX Base Disable Port | ||
450 | */ | ||
451 | OMX_ERRORTYPE OMXBase_DisablePort(OMX_HANDLETYPE hComponent, | ||
452 | OMX_U32 nParam) | ||
453 | { | ||
454 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
455 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
456 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
457 | OMXBase_Port *pPort = NULL; | ||
458 | OMX_U32 nStartPortNum; | ||
459 | |||
460 | nStartPortNum = pBaseComp->nMinStartPortIndex; | ||
461 | |||
462 | pPort = pBaseComp->pPorts[nParam - nStartPortNum]; | ||
463 | /* If comp is in loaded state, then there wont be any buffers to free up */ | ||
464 | if((pBaseComp->tCurState == OMX_StateLoaded) | ||
465 | || (pBaseComp->tCurState == OMX_StateWaitForResources)) { | ||
466 | goto EXIT; | ||
467 | } | ||
468 | eError = OMXBase_DIO_Control(hComponent, nParam, | ||
469 | OMX_DIO_CtrlCmd_Stop, NULL); | ||
470 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
471 | |||
472 | EXIT: | ||
473 | return (eError); | ||
474 | |||
475 | } | ||
476 | |||
477 | /* | ||
478 | * OMX Base EnablePort | ||
479 | */ | ||
480 | OMX_ERRORTYPE OMXBase_EnablePort(OMX_HANDLETYPE hComponent, | ||
481 | OMX_U32 nParam) | ||
482 | { | ||
483 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
484 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
485 | OMXBaseComp *pBaseComp = (OMXBaseComp *) pComp->pComponentPrivate; | ||
486 | OMXBase_Port *pPort = NULL; | ||
487 | OMX_U32 nStartPortNum = 0; | ||
488 | OMX_DIO_OpenParams sDIOParams; | ||
489 | |||
490 | nStartPortNum = pBaseComp->nMinStartPortIndex; | ||
491 | |||
492 | pPort = pBaseComp->pPorts[nParam - nStartPortNum]; | ||
493 | if( pBaseComp->tCurState != OMX_StateLoaded && | ||
494 | pBaseComp->tCurState != OMX_StateWaitForResources ) { | ||
495 | if( pPort->sPortDef.eDir == OMX_DirOutput ) { | ||
496 | sDIOParams.nMode = OMX_DIO_WRITER; | ||
497 | } else { | ||
498 | sDIOParams.nMode = OMX_DIO_READER; | ||
499 | } | ||
500 | } | ||
501 | |||
502 | EXIT: | ||
503 | return (eError); | ||
504 | } | ||
505 | |||
506 | /* | ||
507 | * OMX Base Flush Buffers | ||
508 | */ | ||
509 | OMX_ERRORTYPE OMXBase_FlushBuffers(OMX_HANDLETYPE hComponent, | ||
510 | OMX_U32 nParam) | ||
511 | { | ||
512 | return(OMXBase_DIO_Control(hComponent, nParam, OMX_DIO_CtrlCmd_Flush, | ||
513 | NULL)); | ||
514 | } | ||
515 | |||
516 | |||
517 | /* | ||
518 | * OMX Base Handle Transition | ||
519 | */ | ||
520 | OMX_ERRORTYPE OMXBase_HandleStateTransition(OMX_HANDLETYPE hComponent, | ||
521 | OMX_U32 nParam) | ||
522 | { | ||
523 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
524 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
525 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
526 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
527 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
528 | OMXBase_Port *pPort = NULL; | ||
529 | OMX_U32 i = 0, nStartPortNum = 0, nPorts = 0; | ||
530 | uint32_t retEvents = 0; | ||
531 | OMX_DIO_OpenParams sDIOParams; | ||
532 | |||
533 | nPorts = pBaseComp->nNumPorts; | ||
534 | nStartPortNum = pBaseComp->nMinStartPortIndex; | ||
535 | |||
536 | /* currnet and new state should not be same */ | ||
537 | OMX_CHECK(pBaseComp->tCurState != pBaseComp->tNewState, OMX_ErrorSameState); | ||
538 | /* Transition to invaild state by IL client is disallowed */ | ||
539 | if( pBaseComp->tNewState == OMX_StateInvalid ) { | ||
540 | /* Notify to Derived Component */ | ||
541 | pBaseComp->fpCommandNotify(hComponent, OMX_CommandStateSet, nParam, NULL); | ||
542 | /*Derived component has returned*/ | ||
543 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
544 | OMXBase_CmdStateSet, OSAL_EVENT_OR_CONSUME, | ||
545 | &retEvents, OSAL_SUSPEND); | ||
546 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorInsufficientResources); | ||
547 | |||
548 | /* | ||
549 | For this case we wont go through OMXBase_EventNotifyToClient function | ||
550 | The state will be set here and error callback will be made by | ||
551 | OMXBase_ProcessEvents function | ||
552 | */ | ||
553 | pBaseComp->tCurState = pBaseComp->tNewState; | ||
554 | eError = OMX_ErrorInvalidState; | ||
555 | goto EXIT; | ||
556 | } | ||
557 | |||
558 | switch( pBaseComp->tCurState ) { | ||
559 | case OMX_StateLoaded : | ||
560 | if( pBaseComp->tNewState == OMX_StateIdle ) { | ||
561 | /* Notify to Derived Component */ | ||
562 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
563 | OMX_CommandStateSet, nParam, NULL); | ||
564 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
565 | tStatus = OSAL_RetrieveEvent( | ||
566 | pBaseCompPvt->pCmdCompleteEvent, | ||
567 | OMXBase_CmdStateSet, OSAL_EVENT_OR_CONSUME, | ||
568 | &retEvents, OSAL_SUSPEND); | ||
569 | OMX_CHECK(tStatus == OSAL_ErrNone, | ||
570 | OMX_ErrorInsufficientResources); | ||
571 | |||
572 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
573 | pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; | ||
574 | /*If port is disabled then nothing needs to be done*/ | ||
575 | if( pPort->sPortDef.bEnabled == OMX_FALSE ) { | ||
576 | continue; | ||
577 | } | ||
578 | if( pPort->sPortDef.eDir == OMX_DirOutput ) { | ||
579 | sDIOParams.nMode = OMX_DIO_WRITER; | ||
580 | } else { | ||
581 | sDIOParams.nMode = OMX_DIO_READER; | ||
582 | } | ||
583 | } | ||
584 | } else if( pBaseComp->tNewState == OMX_StateWaitForResources ) { | ||
585 | /* Notify to Derived Component */ | ||
586 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
587 | OMX_CommandStateSet, nParam, NULL); | ||
588 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
589 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
590 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
591 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
592 | } else { | ||
593 | eError = OMX_ErrorIncorrectStateTransition; | ||
594 | goto EXIT; | ||
595 | } | ||
596 | break; | ||
597 | |||
598 | case OMX_StateIdle : | ||
599 | if( pBaseComp->tNewState == OMX_StateLoaded ) { | ||
600 | /* Notify to Derived Component */ | ||
601 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
602 | OMX_CommandStateSet, nParam, NULL); | ||
603 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
604 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
605 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
606 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
607 | } else if( pBaseComp->tNewState == OMX_StateExecuting ) { | ||
608 | /* Notify to Derived Component */ | ||
609 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
610 | OMX_CommandStateSet, nParam, NULL); | ||
611 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
612 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
613 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
614 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
615 | } else if( pBaseComp->tNewState == OMX_StatePause ) { | ||
616 | /* Notify to Derived Component */ | ||
617 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
618 | OMX_CommandStateSet, nParam, NULL); | ||
619 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
620 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
621 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
622 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
623 | } else { | ||
624 | eError = OMX_ErrorIncorrectStateTransition; | ||
625 | goto EXIT; | ||
626 | } | ||
627 | break; | ||
628 | |||
629 | case OMX_StateExecuting : | ||
630 | if( pBaseComp->tNewState == OMX_StateIdle ) { | ||
631 | /* Notify to Derived Component */ | ||
632 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
633 | OMX_CommandStateSet, nParam, NULL); | ||
634 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
635 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
636 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
637 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
638 | |||
639 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
640 | pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; | ||
641 | if( pPort->hDIO != NULL ) { | ||
642 | eError = OMXBase_DIO_Control(hComponent, i, | ||
643 | OMX_DIO_CtrlCmd_Stop, NULL); | ||
644 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
645 | } | ||
646 | } | ||
647 | } else if( pBaseComp->tNewState == OMX_StatePause ) { | ||
648 | /* Notify to Derived Component */ | ||
649 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
650 | OMX_CommandStateSet, nParam, NULL); | ||
651 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
652 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
653 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
654 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
655 | } else { | ||
656 | eError = OMX_ErrorIncorrectStateTransition; | ||
657 | goto EXIT; | ||
658 | } | ||
659 | break; | ||
660 | |||
661 | case OMX_StatePause : | ||
662 | if( pBaseComp->tNewState == OMX_StateExecuting ) { | ||
663 | /* Notify to Derived Component */ | ||
664 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
665 | OMX_CommandStateSet, nParam, NULL); | ||
666 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
667 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
668 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
669 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
670 | |||
671 | /*Pause to Executing so start processing buffers*/ | ||
672 | pBaseCompPvt->fpInvokeProcessFunction(pComp, DATAEVENT); | ||
673 | } else if( pBaseComp->tNewState == OMX_StateIdle ) { | ||
674 | /* Notify to Derived Component */ | ||
675 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
676 | OMX_CommandStateSet, nParam, NULL); | ||
677 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
678 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
679 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
680 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
681 | |||
682 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
683 | pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; | ||
684 | if( pPort->hDIO != NULL ) { | ||
685 | eError = OMXBase_DIO_Control(hComponent, i, | ||
686 | OMX_DIO_CtrlCmd_Stop, NULL); | ||
687 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
688 | } | ||
689 | } | ||
690 | } else { | ||
691 | eError = OMX_ErrorIncorrectStateTransition; | ||
692 | goto EXIT; | ||
693 | } | ||
694 | break; | ||
695 | |||
696 | case OMX_StateWaitForResources : | ||
697 | if( pBaseComp->tNewState == OMX_StateLoaded ) { | ||
698 | /* Notify to Derived Component */ | ||
699 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
700 | OMX_CommandStateSet, nParam, NULL); | ||
701 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
702 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
703 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
704 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
705 | } else if( pBaseComp->tNewState == OMX_StateIdle ) { | ||
706 | /* Notify to Derived Component */ | ||
707 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
708 | OMX_CommandStateSet, nParam, NULL); | ||
709 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
710 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, OMXBase_CmdStateSet, | ||
711 | OSAL_EVENT_OR_CONSUME, &retEvents, OSAL_SUSPEND); | ||
712 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
713 | |||
714 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
715 | pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; | ||
716 | /*If port is disabled then nothing needs to be done*/ | ||
717 | if( pPort->sPortDef.bEnabled == OMX_FALSE ) { | ||
718 | continue; | ||
719 | } | ||
720 | if( pPort->sPortDef.eDir == OMX_DirOutput ) { | ||
721 | sDIOParams.nMode = OMX_DIO_WRITER; | ||
722 | } else { | ||
723 | sDIOParams.nMode = OMX_DIO_READER; | ||
724 | } | ||
725 | } | ||
726 | } else { | ||
727 | eError = OMX_ErrorIncorrectStateTransition; | ||
728 | goto EXIT; | ||
729 | } | ||
730 | break; | ||
731 | |||
732 | default : | ||
733 | OSAL_ErrorTrace(" unknown command "); | ||
734 | break; | ||
735 | } | ||
736 | |||
737 | EXIT: | ||
738 | if( eError != OMX_ErrorNone ) { | ||
739 | /* Since no state transition is in progress put the new state again to OMX_StateMax */ | ||
740 | pBaseComp->tNewState = OMX_StateMax; | ||
741 | } | ||
742 | return (eError); | ||
743 | } | ||
744 | |||
745 | /* | ||
746 | * OMX Base Event Notufy to Client | ||
747 | */ | ||
748 | OMX_ERRORTYPE OMXBase_EventNotifyToClient(OMX_HANDLETYPE hComponent, | ||
749 | OMX_COMMANDTYPE Cmd, | ||
750 | OMX_U32 nParam, | ||
751 | OMX_PTR pCmdData) | ||
752 | { | ||
753 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
754 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
755 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
756 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
757 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
758 | OMXBase_Port *pPort = NULL; | ||
759 | uint32_t retEvents = 0; | ||
760 | OMX_U32 i, nStartPortNum, nPorts; | ||
761 | OMX_BOOL bStartFlag = OMX_FALSE; | ||
762 | (void)pCmdData; | ||
763 | |||
764 | nPorts = pBaseComp->nNumPorts; | ||
765 | nStartPortNum = pBaseComp->nMinStartPortIndex; | ||
766 | |||
767 | switch( Cmd ) { | ||
768 | case OMX_CommandStateSet : | ||
769 | if(((pBaseComp->tCurState == OMX_StateLoaded || | ||
770 | pBaseComp->tCurState == OMX_StateWaitForResources) && | ||
771 | pBaseComp->tNewState == OMX_StateIdle) || | ||
772 | (pBaseComp->tCurState == OMX_StateIdle && | ||
773 | pBaseComp->tNewState == OMX_StateLoaded)) { | ||
774 | /* Incase of loaded to idle and idle to loaded state transition, comp | ||
775 | * should wait for buffers to be allocated/freed for enabled ports */ | ||
776 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
777 | pPort = pBaseComp->pPorts[i - nStartPortNum]; | ||
778 | if( pPort->sPortDef.bEnabled == OMX_TRUE ) { | ||
779 | retEvents = 0; | ||
780 | tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, | ||
781 | (BUF_ALLOC_EVENT | BUF_FREE_EVENT | | ||
782 | BUF_FAIL_EVENT), | ||
783 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
784 | BUFFER_ALLOC_FREE_TIMEOUT); | ||
785 | |||
786 | if (tStatus == OSAL_ErrTimeOut) { | ||
787 | tStatus = OSAL_ErrNone; | ||
788 | retEvents = BUF_FAIL_EVENT; | ||
789 | } | ||
790 | |||
791 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
792 | if( retEvents & BUF_FAIL_EVENT ) { | ||
793 | /*Fail event so free up all DIO resources and move | ||
794 | back to loaded state*/ | ||
795 | OMXBase_HandleFailEvent(hComponent, Cmd, nParam); | ||
796 | if( pBaseComp->tCurState == OMX_StateIdle && | ||
797 | pBaseComp->tNewState == OMX_StateLoaded ) { | ||
798 | eError = OMX_ErrorPortUnresponsiveDuringDeallocation; | ||
799 | } else { | ||
800 | eError = OMX_ErrorPortUnresponsiveDuringAllocation; | ||
801 | } | ||
802 | goto EXIT; | ||
803 | } | ||
804 | /* free up the pool incase if idle to loaded */ | ||
805 | if( pBaseComp->tCurState == OMX_StateIdle && | ||
806 | pBaseComp->tNewState == OMX_StateLoaded ) { | ||
807 | eError = OMXBase_DIO_Close(hComponent, i); | ||
808 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
809 | eError = OMXBase_DIO_Deinit(hComponent, i); | ||
810 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
811 | } | ||
812 | } | ||
813 | } | ||
814 | } else if( pBaseComp->tCurState == OMX_StateIdle && | ||
815 | (pBaseComp->tNewState == OMX_StatePause || | ||
816 | pBaseComp->tNewState == OMX_StateExecuting)) { | ||
817 | bStartFlag = OMX_TRUE; | ||
818 | } | ||
819 | OSAL_ObtainMutex(pBaseCompPvt->pNewStateMutex, OSAL_SUSPEND); | ||
820 | |||
821 | pBaseComp->tCurState = pBaseComp->tNewState; | ||
822 | pBaseComp->tNewState = OMX_StateMax; | ||
823 | /* Notify Completion to the Client */ | ||
824 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
825 | pComp->pApplicationPrivate, | ||
826 | OMX_EventCmdComplete, OMX_CommandStateSet, | ||
827 | nParam, NULL); | ||
828 | if( bStartFlag ) { | ||
829 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
830 | pPort = (OMXBase_Port *)pBaseComp->pPorts[i - nStartPortNum]; | ||
831 | if( pPort->hDIO != NULL ) { | ||
832 | eError = OMXBase_DIO_Control(hComponent, i, | ||
833 | OMX_DIO_CtrlCmd_Start, NULL); | ||
834 | if( OMX_ErrorNone != eError ) { | ||
835 | OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); | ||
836 | goto EXIT; | ||
837 | } | ||
838 | } | ||
839 | } | ||
840 | } | ||
841 | OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); | ||
842 | break; | ||
843 | |||
844 | case OMX_CommandPortEnable : | ||
845 | if( OMX_ALL == nParam ) { | ||
846 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
847 | pPort = pBaseComp->pPorts[i - nStartPortNum]; | ||
848 | if( pBaseComp->tCurState != OMX_StateLoaded ) { | ||
849 | retEvents = 0; | ||
850 | tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, | ||
851 | (BUF_ALLOC_EVENT | BUF_FAIL_EVENT), | ||
852 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
853 | BUFFER_ALLOC_FREE_TIMEOUT); | ||
854 | if (tStatus == OSAL_ErrTimeOut) { | ||
855 | tStatus = OSAL_ErrNone; | ||
856 | retEvents = BUF_FAIL_EVENT; | ||
857 | } | ||
858 | |||
859 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
860 | if( retEvents & BUF_FAIL_EVENT ) { | ||
861 | /*Fail event so free up all DIO resources and move | ||
862 | back to port in disabled state*/ | ||
863 | OMXBase_HandleFailEvent(hComponent, Cmd, nParam); | ||
864 | eError = OMX_ErrorPortUnresponsiveDuringAllocation; | ||
865 | |||
866 | for( i = 0; i < pBaseComp->nNumPorts; i++ ) { | ||
867 | pPort = pBaseComp->pPorts[i]; | ||
868 | pPort->bIsInTransition = OMX_FALSE; | ||
869 | pPort->sPortDef.bEnabled = OMX_FALSE; | ||
870 | } | ||
871 | goto EXIT; | ||
872 | } | ||
873 | } | ||
874 | pPort->bIsInTransition = OMX_FALSE; | ||
875 | /* Notify Completion to the Client */ | ||
876 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
877 | pComp->pApplicationPrivate, | ||
878 | OMX_EventCmdComplete, OMX_CommandPortEnable, | ||
879 | i, NULL); | ||
880 | /*If current state is executing, start buffer transfer*/ | ||
881 | if( pBaseComp->tCurState == OMX_StateExecuting ) { | ||
882 | eError = OMXBase_DIO_Control(hComponent, i, | ||
883 | OMX_DIO_CtrlCmd_Start, NULL); | ||
884 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
885 | } | ||
886 | } | ||
887 | } else { | ||
888 | pPort = pBaseComp->pPorts[nParam - nStartPortNum]; | ||
889 | if( pBaseComp->tCurState != OMX_StateLoaded ) { | ||
890 | retEvents = 0; | ||
891 | tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, | ||
892 | (BUF_ALLOC_EVENT | BUF_FAIL_EVENT), | ||
893 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
894 | BUFFER_ALLOC_FREE_TIMEOUT); | ||
895 | if (tStatus == OSAL_ErrTimeOut) { | ||
896 | tStatus = OSAL_ErrNone; | ||
897 | retEvents = BUF_FAIL_EVENT; | ||
898 | } | ||
899 | |||
900 | OMX_CHECK(tStatus == OSAL_ErrNone, | ||
901 | tStatus != OSAL_ErrTimeOut ? | ||
902 | OMX_ErrorUndefined : OMX_ErrorPortUnresponsiveDuringAllocation); | ||
903 | |||
904 | if( retEvents & BUF_FAIL_EVENT ) { | ||
905 | /*Fail event so free up all DIO resources and move | ||
906 | back to port in disabled state*/ | ||
907 | OMXBase_HandleFailEvent(hComponent, Cmd, nParam); | ||
908 | eError = OMX_ErrorPortUnresponsiveDuringAllocation; | ||
909 | pPort->bIsInTransition = OMX_FALSE; | ||
910 | pPort->sPortDef.bEnabled = OMX_FALSE; | ||
911 | goto EXIT; | ||
912 | } | ||
913 | } | ||
914 | pPort->bIsInTransition = OMX_FALSE; | ||
915 | |||
916 | /* Notify Completion to the Client */ | ||
917 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
918 | pComp->pApplicationPrivate, | ||
919 | OMX_EventCmdComplete, OMX_CommandPortEnable, | ||
920 | nParam, NULL); | ||
921 | /*If current state is executing, start buffer transfer*/ | ||
922 | if( pBaseComp->tCurState == OMX_StateExecuting ) { | ||
923 | eError = OMXBase_DIO_Control(hComponent, nParam, | ||
924 | OMX_DIO_CtrlCmd_Start, NULL); | ||
925 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
926 | } | ||
927 | } | ||
928 | break; | ||
929 | |||
930 | case OMX_CommandPortDisable : | ||
931 | if( OMX_ALL == nParam ) { | ||
932 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
933 | pPort = pBaseComp->pPorts[i - nStartPortNum]; | ||
934 | if( pBaseComp->tCurState != OMX_StateLoaded ) { | ||
935 | retEvents = 0; | ||
936 | tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, | ||
937 | (BUF_FREE_EVENT | BUF_FAIL_EVENT), | ||
938 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
939 | BUFFER_ALLOC_FREE_TIMEOUT); | ||
940 | |||
941 | if (tStatus == OSAL_ErrTimeOut) { | ||
942 | tStatus = OSAL_ErrNone; | ||
943 | retEvents = BUF_FAIL_EVENT; | ||
944 | } | ||
945 | |||
946 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
947 | if( retEvents & BUF_FAIL_EVENT ) { | ||
948 | /*Fail event so free up all DIO resources and move | ||
949 | port to disabled state*/ | ||
950 | OMXBase_HandleFailEvent(hComponent, Cmd, nParam); | ||
951 | eError = OMX_ErrorPortUnresponsiveDuringDeallocation; | ||
952 | |||
953 | for( i = 0; i < pBaseComp->nNumPorts; i++ ) { | ||
954 | pPort = pBaseComp->pPorts[i]; | ||
955 | pPort->bIsInTransition = OMX_FALSE; | ||
956 | } | ||
957 | goto EXIT; | ||
958 | } | ||
959 | eError = OMXBase_DIO_Close(hComponent, i); | ||
960 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
961 | eError = OMXBase_DIO_Deinit(hComponent, i); | ||
962 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
963 | } | ||
964 | pPort->bIsInTransition = OMX_FALSE; | ||
965 | /* Notify Completion to the Client */ | ||
966 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
967 | pComp->pApplicationPrivate, | ||
968 | OMX_EventCmdComplete, OMX_CommandPortDisable, | ||
969 | i, NULL); | ||
970 | } | ||
971 | } else { | ||
972 | pPort = pBaseComp->pPorts[nParam - nStartPortNum]; | ||
973 | if( pBaseComp->tCurState != OMX_StateLoaded ) { | ||
974 | retEvents = 0; | ||
975 | tStatus = OSAL_RetrieveEvent(pPort->pBufAllocFreeEvent, | ||
976 | (BUF_FREE_EVENT | BUF_FAIL_EVENT), | ||
977 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
978 | BUFFER_ALLOC_FREE_TIMEOUT); | ||
979 | |||
980 | if (tStatus == OSAL_ErrTimeOut) { | ||
981 | tStatus = OSAL_ErrNone; | ||
982 | retEvents = BUF_FAIL_EVENT; | ||
983 | } | ||
984 | |||
985 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
986 | if( retEvents & BUF_FAIL_EVENT ) { | ||
987 | /*Fail event so free up all DIO resources and move | ||
988 | back to port in disabled state*/ | ||
989 | OMXBase_HandleFailEvent(hComponent, Cmd, nParam); | ||
990 | eError = OMX_ErrorPortUnresponsiveDuringDeallocation; | ||
991 | pPort->bIsInTransition = OMX_FALSE; | ||
992 | goto EXIT; | ||
993 | } | ||
994 | eError = OMXBase_DIO_Close(hComponent, nParam); | ||
995 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
996 | eError = OMXBase_DIO_Deinit(hComponent, nParam); | ||
997 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
998 | } | ||
999 | pPort->bIsInTransition = OMX_FALSE; | ||
1000 | /* Notify Completion to the Client */ | ||
1001 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
1002 | pComp->pApplicationPrivate, | ||
1003 | OMX_EventCmdComplete, OMX_CommandPortDisable, | ||
1004 | nParam, NULL); | ||
1005 | } | ||
1006 | break; | ||
1007 | |||
1008 | case OMX_CommandFlush : | ||
1009 | if( nParam == OMX_ALL ) { | ||
1010 | for( i = nStartPortNum; i < (nStartPortNum + nPorts); i++ ) { | ||
1011 | pPort = pBaseComp->pPorts[i - nStartPortNum]; | ||
1012 | /* Notify Completion to the Client */ | ||
1013 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
1014 | pComp->pApplicationPrivate, | ||
1015 | OMX_EventCmdComplete, OMX_CommandFlush, | ||
1016 | i, NULL); | ||
1017 | } | ||
1018 | } else { | ||
1019 | /* Notify Completion to the Client */ | ||
1020 | pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
1021 | pComp->pApplicationPrivate, | ||
1022 | OMX_EventCmdComplete, OMX_CommandFlush, | ||
1023 | nParam, NULL); | ||
1024 | } | ||
1025 | break; | ||
1026 | |||
1027 | case OMX_CommandMarkBuffer : | ||
1028 | |||
1029 | break; | ||
1030 | |||
1031 | default : | ||
1032 | OSAL_ErrorTrace("InValid command"); | ||
1033 | } | ||
1034 | |||
1035 | EXIT: | ||
1036 | return (eError); | ||
1037 | } | ||
1038 | |||
1039 | /* | ||
1040 | * OMX Base IsCmdPending | ||
1041 | */ | ||
1042 | OMX_BOOL OMXBase_IsCmdPending (OMX_HANDLETYPE hComponent) | ||
1043 | { | ||
1044 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1045 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1046 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1047 | OMX_BOOL bRetVal = OMX_FALSE; | ||
1048 | |||
1049 | if( OSAL_IsPipeReady(pBaseCompPvt->pCmdPipe) == OSAL_ErrNone ) { | ||
1050 | /*Set data event so that derived component can get data notification | ||
1051 | after it processes the pending command*/ | ||
1052 | pBaseCompPvt->bForceNotifyOnce = OMX_TRUE; | ||
1053 | pBaseCompPvt->fpInvokeProcessFunction(hComponent, DATAEVENT); | ||
1054 | bRetVal = OMX_TRUE; | ||
1055 | } | ||
1056 | |||
1057 | return (bRetVal); | ||
1058 | } | ||
1059 | |||
1060 | |||
1061 | /* | ||
1062 | * OMX Base Is DIO Ready | ||
1063 | */ | ||
1064 | OMX_BOOL OMXBase_IsDioReady(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex) | ||
1065 | { | ||
1066 | OMX_BOOL bRet = OMX_TRUE; | ||
1067 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1068 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1069 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
1070 | OMXBase_Port *pPort = NULL; | ||
1071 | OMX_U32 nStartPortNumber = 0; | ||
1072 | |||
1073 | if( pBaseComp == NULL ) { | ||
1074 | OSAL_ErrorTrace("Pvt structure is NULL - DIO cannot be used"); | ||
1075 | bRet = OMX_FALSE; | ||
1076 | goto EXIT; | ||
1077 | } | ||
1078 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1079 | if( pBaseCompPvt == NULL ) { | ||
1080 | OSAL_ErrorTrace("Base internal structure is NULL - DIO cannot be used"); | ||
1081 | bRet = OMX_FALSE; | ||
1082 | goto EXIT; | ||
1083 | } | ||
1084 | if( pBaseComp->pPorts == NULL ) { | ||
1085 | OSAL_ErrorTrace("No port has been initialized - DIO cannot be used"); | ||
1086 | bRet = OMX_FALSE; | ||
1087 | goto EXIT; | ||
1088 | } | ||
1089 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
1090 | pPort = (OMXBase_Port *) | ||
1091 | pBaseComp->pPorts[nPortIndex - nStartPortNumber]; | ||
1092 | if( pPort == NULL ) { | ||
1093 | OSAL_ErrorTrace("This port is not initialized - DIO cannot be used"); | ||
1094 | bRet = OMX_FALSE; | ||
1095 | goto EXIT; | ||
1096 | } | ||
1097 | if( pPort->hDIO == NULL ) { | ||
1098 | OSAL_ErrorTrace("DIO handle is NULL - DIO cannot be used"); | ||
1099 | bRet = OMX_FALSE; | ||
1100 | goto EXIT; | ||
1101 | } | ||
1102 | if( !(((OMX_DIO_Object *)pPort->hDIO)->bOpened)) { | ||
1103 | OSAL_ErrorTrace("DIO has not yet been opened"); | ||
1104 | bRet = OMX_FALSE; | ||
1105 | goto EXIT; | ||
1106 | } | ||
1107 | |||
1108 | EXIT: | ||
1109 | return (bRet); | ||
1110 | } | ||
1111 | |||
1112 | /* | ||
1113 | * OMX Base Get UV Buffer shared fd | ||
1114 | */ | ||
1115 | OMX_ERRORTYPE OMXBase_GetUVBuffer(OMX_HANDLETYPE hComponent, | ||
1116 | OMX_U32 nPortIndex, | ||
1117 | OMX_PTR pBufHdr, OMX_PTR *pUVBuffer) | ||
1118 | { | ||
1119 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1120 | (void)hComponent, nPortIndex; | ||
1121 | |||
1122 | OMX_CHECK(pBufHdr != NULL, OMX_ErrorBadParameter); | ||
1123 | OMX_CHECK(((OMX_BUFFERHEADERTYPE *)pBufHdr)->pPlatformPrivate != | ||
1124 | NULL, OMX_ErrorBadParameter); | ||
1125 | |||
1126 | *pUVBuffer = (void*)((OMXBase_BufHdrPvtData *)((OMX_BUFFERHEADERTYPE *)pBufHdr)-> | ||
1127 | pPlatformPrivate)->sMemHdr[1].dma_buf_fd; | ||
1128 | |||
1129 | EXIT: | ||
1130 | return (eError); | ||
1131 | } | ||
1132 | |||
1133 | |||
1134 | /* | ||
1135 | * OMXBase Error Handling for WaitForResource State | ||
1136 | */ | ||
1137 | OMX_ERRORTYPE OMXBase_Error_HandleWFRState(OMX_HANDLETYPE hComponent) | ||
1138 | { | ||
1139 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1140 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
1141 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1142 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1143 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1144 | uint32_t retEvents = 0; | ||
1145 | |||
1146 | eError = OMXBase_SendCommand(hComponent, OMX_CommandStateSet, OMX_StateLoaded, NULL); | ||
1147 | |||
1148 | //Wait for WaitForResources state transition to complete. | ||
1149 | retEvents = 0; | ||
1150 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1151 | (STATE_LOADED_EVENT), | ||
1152 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1153 | STATE_TRANSITION_LONG_TIMEOUT); | ||
1154 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
1155 | |||
1156 | EXIT: | ||
1157 | return (eError); | ||
1158 | } | ||
1159 | |||
1160 | /* | ||
1161 | * OMX Base Error handling for Idle State | ||
1162 | */ | ||
1163 | OMX_ERRORTYPE OMXBase_Error_HandleIdleState(OMX_HANDLETYPE hComponent) | ||
1164 | { | ||
1165 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1166 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
1167 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1168 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1169 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1170 | OMXBase_Port *pPort = NULL; | ||
1171 | OMX_U32 i = 0, j = 0; | ||
1172 | uint32_t retEvents = 0; | ||
1173 | |||
1174 | eError = OMXBase_SendCommand(hComponent, OMX_CommandStateSet, OMX_StateLoaded, NULL); | ||
1175 | |||
1176 | //Send free buffers to complete the Idle transition. | ||
1177 | for( i=0; i < pBaseComp->nNumPorts; i++ ) { | ||
1178 | pPort = pBaseComp->pPorts[i]; | ||
1179 | if( pPort->sPortDef.bEnabled == OMX_TRUE ) { | ||
1180 | for( j=0; j < pPort->sPortDef.nBufferCountActual; j++ ) { | ||
1181 | OMXBase_FreeBuffer(hComponent, | ||
1182 | i + pBaseComp->nMinStartPortIndex, | ||
1183 | pPort->pBufferlist[j]); | ||
1184 | } | ||
1185 | } | ||
1186 | } | ||
1187 | |||
1188 | //Wait for Idle state transition to complete. | ||
1189 | retEvents = 0; | ||
1190 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1191 | (STATE_LOADED_EVENT), | ||
1192 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1193 | STATE_TRANSITION_LONG_TIMEOUT); | ||
1194 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorUndefined); | ||
1195 | |||
1196 | EXIT: | ||
1197 | return (eError); | ||
1198 | } | ||
1199 | |||
1200 | /* | ||
1201 | * OMX Base UtilCleanup On Error | ||
1202 | */ | ||
1203 | OMX_ERRORTYPE OMXBase_UtilCleanupIfError(OMX_HANDLETYPE hComponent) | ||
1204 | { | ||
1205 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1206 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
1207 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1208 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1209 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1210 | OMXBase_Port *pPort = NULL; | ||
1211 | OMX_U32 i = 0; | ||
1212 | uint32_t retEvents = 0; | ||
1213 | OMX_BOOL bPortTransitioning = OMX_FALSE; | ||
1214 | |||
1215 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1216 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1217 | |||
1218 | if((pBaseComp->tCurState == OMX_StateLoaded) && (pBaseComp->tNewState == OMX_StateMax)) { | ||
1219 | for( i=0; i < pBaseComp->nNumPorts; i++ ) { | ||
1220 | pPort = pBaseComp->pPorts[i]; | ||
1221 | if( pPort->bIsInTransition) { | ||
1222 | bPortTransitioning = OMX_TRUE; | ||
1223 | break; | ||
1224 | } | ||
1225 | } | ||
1226 | |||
1227 | if( bPortTransitioning == OMX_FALSE ) { | ||
1228 | goto EXIT; | ||
1229 | } | ||
1230 | } | ||
1231 | pBaseCompPvt->sAppCallbacks.EventHandler = OMXBase_Error_EventHandler; | ||
1232 | pBaseCompPvt->sAppCallbacks.EmptyBufferDone = OMXBase_Error_EmptyBufferDone; | ||
1233 | pBaseCompPvt->sAppCallbacks.FillBufferDone = OMXBase_Error_FillBufferDone; | ||
1234 | |||
1235 | if((pBaseComp->tCurState == OMX_StateWaitForResources) && (pBaseComp->tNewState == OMX_StateMax)) { | ||
1236 | for( i=0; i < pBaseComp->nNumPorts; i++ ) { | ||
1237 | pPort = pBaseComp->pPorts[i]; | ||
1238 | if( pPort->bIsInTransition) { | ||
1239 | bPortTransitioning = OMX_TRUE; | ||
1240 | break; | ||
1241 | } | ||
1242 | } | ||
1243 | |||
1244 | if( bPortTransitioning == OMX_FALSE ) { | ||
1245 | OSAL_ErrorTrace("Free Handle called in WaitForResources state, attempting a transition to LOADED state"); | ||
1246 | eError = OMXBase_Error_HandleWFRState(pComp); | ||
1247 | if( eError != OMX_ErrorNone ) { | ||
1248 | OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); | ||
1249 | } else { | ||
1250 | OSAL_ErrorTrace("Cleanup from WaitForResources state is successful"); | ||
1251 | } | ||
1252 | goto EXIT; | ||
1253 | } | ||
1254 | } | ||
1255 | //Wait for timeout to let any pending send commands complete. | ||
1256 | retEvents = 0; | ||
1257 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1258 | (STATE_LOADED_EVENT | STATE_IDLE_EVENT | ||
1259 | | STATE_EXEC_EVENT | STATE_PAUSE_EVENT | ||
1260 | | ERROR_EVENT), | ||
1261 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1262 | STATE_TRANSITION_TIMEOUT); | ||
1263 | if( tStatus != OSAL_ErrNone && tStatus != OSAL_ErrTimeOut ) { | ||
1264 | eError = OMX_ErrorUndefined; | ||
1265 | OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); | ||
1266 | } | ||
1267 | //Clear any port disable/enable events which are pending. | ||
1268 | retEvents = 0; | ||
1269 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1270 | (PORT_ENABLE_EVENT | PORT_DISABLE_EVENT), | ||
1271 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1272 | OSAL_NO_SUSPEND); | ||
1273 | if( tStatus != OSAL_ErrNone && tStatus != OSAL_ErrTimeOut ) { | ||
1274 | eError = OMX_ErrorUndefined; | ||
1275 | OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); | ||
1276 | } | ||
1277 | |||
1278 | //This is for the condition if freehandle is being sent while port enable/disable is ongoing. | ||
1279 | for( i=0; i < pBaseComp->nNumPorts; i++ ) { | ||
1280 | pPort = pBaseComp->pPorts[i]; | ||
1281 | if( pPort->bIsInTransition) { | ||
1282 | tStatus = OSAL_SetEvent(pPort->pBufAllocFreeEvent, | ||
1283 | BUF_FAIL_EVENT, OSAL_EVENT_OR); | ||
1284 | if( tStatus != OSAL_ErrNone ) { | ||
1285 | eError = OMX_ErrorUndefined; | ||
1286 | } | ||
1287 | //Wait for port to transition to disable. | ||
1288 | retEvents = 0; | ||
1289 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1290 | ERROR_EVENT, OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1291 | STATE_TRANSITION_TIMEOUT); | ||
1292 | if( tStatus != OSAL_ErrNone ) { | ||
1293 | eError = OMX_ErrorUndefined; | ||
1294 | OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); | ||
1295 | } | ||
1296 | if( pPort->bIsInTransition) { | ||
1297 | pPort->bIsInTransition = OMX_FALSE; | ||
1298 | } | ||
1299 | } | ||
1300 | } | ||
1301 | |||
1302 | if( pBaseComp->tCurState == OMX_StateLoaded && pBaseComp->tNewState == OMX_StateMax ) { | ||
1303 | goto EXIT; | ||
1304 | } | ||
1305 | |||
1306 | switch( pBaseComp->tCurState ) { | ||
1307 | case OMX_StateLoaded : | ||
1308 | OMX_BASE_HANDLE_IDLE_TO_LOADED_TRANSITION(); | ||
1309 | break; | ||
1310 | |||
1311 | case OMX_StateWaitForResources : | ||
1312 | // Since BUFFER FAIL done in cleanup utility happened successfully, all that is required is switch to LOADED state. | ||
1313 | if( pBaseComp->tCurState == OMX_StateWaitForResources && pBaseComp->tNewState == OMX_StateMax ) { | ||
1314 | eError = OMXBase_Error_HandleWFRState(hComponent); | ||
1315 | } else { | ||
1316 | OSAL_ErrorTrace("Error occured. Cleanup might not be complete"); | ||
1317 | } | ||
1318 | break; | ||
1319 | |||
1320 | case OMX_StateIdle : | ||
1321 | if( pBaseComp->tCurState == OMX_StateIdle && pBaseComp->tNewState == OMX_StateMax ) { | ||
1322 | eError = OMXBase_Error_HandleIdleState(hComponent); | ||
1323 | } else { // This is to handle scenerio if there is a crash in Idle to Loaded transition | ||
1324 | OMX_BASE_HANDLE_IDLE_TO_LOADED_TRANSITION(); | ||
1325 | } | ||
1326 | break; | ||
1327 | |||
1328 | case OMX_StateExecuting : | ||
1329 | // Move the component to Idle State. | ||
1330 | OMXBase_SendCommand(hComponent, OMX_CommandStateSet, OMX_StateIdle, NULL); | ||
1331 | retEvents = 0; | ||
1332 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1333 | STATE_IDLE_EVENT, | ||
1334 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1335 | STATE_TRANSITION_LONG_TIMEOUT); | ||
1336 | if( tStatus != OSAL_ErrNone ) { | ||
1337 | eError = OMX_ErrorUndefined; | ||
1338 | OSAL_ErrorTrace("I am here b'cs of TIMEOUT in ER"); | ||
1339 | } | ||
1340 | eError = OMXBase_Error_HandleIdleState(hComponent); | ||
1341 | break; | ||
1342 | |||
1343 | case OMX_StatePause : | ||
1344 | // Move the component to Idle State. | ||
1345 | OMXBase_SendCommand(hComponent, OMX_CommandStateSet, OMX_StateIdle, NULL); | ||
1346 | retEvents = 0; | ||
1347 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1348 | (STATE_IDLE_EVENT), | ||
1349 | OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1350 | STATE_TRANSITION_LONG_TIMEOUT); | ||
1351 | if( tStatus != OSAL_ErrNone ) { | ||
1352 | eError = OMX_ErrorUndefined; | ||
1353 | OSAL_ErrorTrace("I am here b'cs of TIMEOUT in ER"); | ||
1354 | } | ||
1355 | eError = OMXBase_Error_HandleIdleState(hComponent); | ||
1356 | break; | ||
1357 | |||
1358 | default : | ||
1359 | OSAL_ErrorTrace("Invalid state requested"); | ||
1360 | } | ||
1361 | |||
1362 | EXIT: | ||
1363 | return (eError); | ||
1364 | } | ||
1365 | |||
1366 | /* | ||
1367 | * OMX Base Error handling for Empty Buffer Done | ||
1368 | */ | ||
1369 | OMX_ERRORTYPE OMXBase_Error_EmptyBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, | ||
1370 | OMX_BUFFERHEADERTYPE *pBuffer) | ||
1371 | { | ||
1372 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1373 | (void)hComponent, pAppData, pBuffer; | ||
1374 | |||
1375 | return (eError); | ||
1376 | } | ||
1377 | |||
1378 | /* | ||
1379 | * OMX Base Error Handling for FillBufferDone | ||
1380 | */ | ||
1381 | OMX_ERRORTYPE OMXBase_Error_FillBufferDone(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, | ||
1382 | OMX_BUFFERHEADERTYPE *pBuffer) | ||
1383 | { | ||
1384 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1385 | (void)hComponent, pAppData, pBuffer; | ||
1386 | |||
1387 | return (eError); | ||
1388 | } | ||
1389 | |||
1390 | /* | ||
1391 | * OMX Base Error Handling for EventHandler | ||
1392 | */ | ||
1393 | OMX_ERRORTYPE OMXBase_Error_EventHandler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, | ||
1394 | OMX_EVENTTYPE eEvent, OMX_U32 nData1, | ||
1395 | OMX_U32 nData2, OMX_PTR pEventData) | ||
1396 | { | ||
1397 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1398 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
1399 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1400 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1401 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1402 | (void)pAppData, pEventData; | ||
1403 | |||
1404 | if( eEvent == OMX_EventCmdComplete ) { | ||
1405 | if((OMX_COMMANDTYPE)nData1 == OMX_CommandPortEnable ) { | ||
1406 | tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1407 | PORT_ENABLE_EVENT, OSAL_EVENT_OR); | ||
1408 | if( tStatus != OSAL_ErrNone ) { | ||
1409 | eError = OMX_ErrorUndefined; | ||
1410 | } | ||
1411 | } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandPortEnable ) { | ||
1412 | tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1413 | PORT_DISABLE_EVENT, OSAL_EVENT_OR); | ||
1414 | if( tStatus != OSAL_ErrNone ) { | ||
1415 | eError = OMX_ErrorUndefined; | ||
1416 | } | ||
1417 | } else if((OMX_COMMANDTYPE)nData1 == OMX_CommandStateSet ) { | ||
1418 | switch((OMX_STATETYPE) nData2 ) { | ||
1419 | case OMX_StateLoaded : | ||
1420 | tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1421 | STATE_LOADED_EVENT, OSAL_EVENT_OR); | ||
1422 | if( tStatus != OSAL_ErrNone ) { | ||
1423 | eError = OMX_ErrorUndefined; | ||
1424 | } | ||
1425 | break; | ||
1426 | |||
1427 | case OMX_StateIdle : | ||
1428 | tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1429 | STATE_IDLE_EVENT, OSAL_EVENT_OR); | ||
1430 | if( tStatus != OSAL_ErrNone ) { | ||
1431 | eError = OMX_ErrorUndefined; | ||
1432 | } | ||
1433 | break; | ||
1434 | |||
1435 | case OMX_StateExecuting : | ||
1436 | tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1437 | STATE_EXEC_EVENT, OSAL_EVENT_OR); | ||
1438 | if( tStatus != OSAL_ErrNone ) { | ||
1439 | eError = OMX_ErrorUndefined; | ||
1440 | } | ||
1441 | break; | ||
1442 | |||
1443 | case OMX_StatePause : | ||
1444 | tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1445 | STATE_PAUSE_EVENT, OSAL_EVENT_OR); | ||
1446 | if( tStatus != OSAL_ErrNone ) { | ||
1447 | eError = OMX_ErrorUndefined; | ||
1448 | } | ||
1449 | break; | ||
1450 | |||
1451 | default: | ||
1452 | OSAL_ErrorTrace("Invalid command"); | ||
1453 | } | ||
1454 | } | ||
1455 | } else if( eEvent == OMX_EventError ) { | ||
1456 | if(((OMX_ERRORTYPE)nData1 == OMX_ErrorPortUnresponsiveDuringDeallocation) || | ||
1457 | ((OMX_ERRORTYPE)nData1 == OMX_ErrorPortUnresponsiveDuringAllocation)) { | ||
1458 | tStatus = OSAL_SetEvent(pBaseCompPvt->pErrorCmdcompleteEvent, | ||
1459 | ERROR_EVENT, OSAL_EVENT_OR); | ||
1460 | } | ||
1461 | } | ||
1462 | return (eError); | ||
1463 | } | ||
1464 | |||
1465 | /* | ||
1466 | * OMX Base Handle Fail Event | ||
1467 | */ | ||
1468 | void OMXBase_HandleFailEvent(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE eCmd, | ||
1469 | OMX_U32 nPortIndex) | ||
1470 | { | ||
1471 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1472 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
1473 | OMXBaseComp_Pvt *pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
1474 | OMXBase_Port *pPort = NULL; | ||
1475 | OSAL_ERROR retval = OSAL_ErrNone; | ||
1476 | OMX_U32 i = 0; | ||
1477 | uint32_t retEvents = 0; | ||
1478 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1479 | |||
1480 | switch( eCmd ) { | ||
1481 | case OMX_CommandStateSet : | ||
1482 | OSAL_ObtainMutex(pBaseCompPvt->pNewStateMutex, OSAL_SUSPEND); | ||
1483 | if(((pBaseComp->tCurState == OMX_StateLoaded || | ||
1484 | pBaseComp->tCurState == OMX_StateWaitForResources) && | ||
1485 | pBaseComp->tNewState == OMX_StateIdle) || | ||
1486 | (pBaseComp->tCurState == OMX_StateIdle && | ||
1487 | pBaseComp->tNewState == OMX_StateLoaded)) { | ||
1488 | /*Failure in L --> I transition. First step is to tell the derived component | ||
1489 | to revert back to loaded state*/ | ||
1490 | if(((pBaseComp->tCurState == OMX_StateLoaded) || | ||
1491 | (pBaseComp->tCurState == OMX_StateWaitForResources)) && | ||
1492 | (pBaseComp->tNewState == OMX_StateIdle)) { | ||
1493 | /*Force setting states*/ | ||
1494 | pBaseComp->tCurState = OMX_StateIdle; | ||
1495 | pBaseComp->tNewState = OMX_StateLoaded; | ||
1496 | /*Return error values dont matter here since this is cleanup*/ | ||
1497 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
1498 | OMX_CommandStateSet, OMX_StateLoaded, NULL); | ||
1499 | if( eError == OMX_ErrorNone ) { | ||
1500 | OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
1501 | OMXBase_CmdStateSet, OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1502 | OSAL_SUSPEND); | ||
1503 | } | ||
1504 | } | ||
1505 | |||
1506 | /*If DIO for any port is open close those*/ | ||
1507 | for( i = 0; i < pBaseComp->nNumPorts; i++ ) { | ||
1508 | pPort = pBaseComp->pPorts[i]; | ||
1509 | if( pPort != NULL ) { | ||
1510 | if( pPort->hDIO != NULL ) { | ||
1511 | OMXBase_DIO_Close(hComponent, | ||
1512 | (i + pBaseComp->nMinStartPortIndex)); | ||
1513 | |||
1514 | OMXBase_DIO_Deinit(hComponent, | ||
1515 | (i + pBaseComp->nMinStartPortIndex)); | ||
1516 | } | ||
1517 | } | ||
1518 | } | ||
1519 | /*Force setting states*/ | ||
1520 | pBaseComp->tCurState = OMX_StateLoaded; | ||
1521 | pBaseComp->tNewState = OMX_StateMax; | ||
1522 | } | ||
1523 | OSAL_ReleaseMutex(pBaseCompPvt->pNewStateMutex); | ||
1524 | break; | ||
1525 | |||
1526 | case OMX_CommandPortEnable : | ||
1527 | /*Tell derived comp to move back to disabled state*/ | ||
1528 | pBaseComp->fpCommandNotify(hComponent, | ||
1529 | OMX_CommandPortDisable, nPortIndex, NULL); | ||
1530 | |||
1531 | OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
1532 | OMXBase_CmdPortDisable, OSAL_EVENT_OR_CONSUME, &retEvents, | ||
1533 | OSAL_SUSPEND); | ||
1534 | if( nPortIndex == OMX_ALL ) { | ||
1535 | for( i = 0; i < pBaseComp->nNumPorts; i++ ) { | ||
1536 | pPort = pBaseComp->pPorts[i]; | ||
1537 | pPort->bIsInTransition = OMX_FALSE; | ||
1538 | } | ||
1539 | } else { | ||
1540 | pPort = pBaseComp->pPorts[ | ||
1541 | nPortIndex - pBaseComp->nMinStartPortIndex]; | ||
1542 | pPort->bIsInTransition = OMX_FALSE; | ||
1543 | } | ||
1544 | /*NO break to OMX_CommandPortEnable case :::Intention is to have a fall through logic to the port disable*/ | ||
1545 | |||
1546 | case OMX_CommandPortDisable : | ||
1547 | /*Close DIO on the relevant ports for both enable as well as disable | ||
1548 | commands*/ | ||
1549 | OSAL_ObtainMutex(pBaseCompPvt->pPortDisableMutex, OSAL_SUSPEND); | ||
1550 | if( nPortIndex == OMX_ALL ) { | ||
1551 | for( i = 0; i < pBaseComp->nNumPorts; i++ ) { | ||
1552 | pPort = pBaseComp->pPorts[i]; | ||
1553 | if( pPort != NULL ) { | ||
1554 | if( pPort->hDIO != NULL ) { | ||
1555 | OMXBase_DIO_Close(hComponent, (i + pBaseComp->nMinStartPortIndex)); | ||
1556 | |||
1557 | OMXBase_DIO_Deinit(hComponent, (i + pBaseComp->nMinStartPortIndex)); | ||
1558 | } | ||
1559 | } | ||
1560 | } | ||
1561 | } else { | ||
1562 | pPort = pBaseComp->pPorts[nPortIndex - pBaseComp->nMinStartPortIndex]; | ||
1563 | if( pPort != NULL ) { | ||
1564 | if( pPort->hDIO != NULL ) { | ||
1565 | OMXBase_DIO_Close(hComponent, nPortIndex); | ||
1566 | OMXBase_DIO_Deinit(hComponent, nPortIndex); | ||
1567 | } | ||
1568 | } | ||
1569 | } | ||
1570 | OSAL_ReleaseMutex(pBaseCompPvt->pPortDisableMutex); | ||
1571 | break; | ||
1572 | |||
1573 | default : | ||
1574 | OSAL_ErrorTrace("Invalid Command"); | ||
1575 | } | ||
1576 | |||
1577 | return; | ||
1578 | } | ||
1579 | |||
1580 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_BASE_PROCESS" | ||
18 | |||
19 | #include <OMX_Core.h> | ||
20 | #include <OMX_Component.h> | ||
21 | #include <omx_base.h> | ||
22 | #include <OMX_TI_Custom.h> | ||
23 | |||
24 | static OMX_ERRORTYPE OMXBase_ProcessDataEvent(OMX_HANDLETYPE hComponent); | ||
25 | |||
26 | static OMX_ERRORTYPE OMXBase_ProcessCmdEvent(OMX_HANDLETYPE hComponent, | ||
27 | OMX_COMMANDTYPE Cmd, | ||
28 | OMX_U32 nParam, | ||
29 | OMX_PTR pCmdData); | ||
30 | |||
31 | |||
32 | /* | ||
33 | * OMX Base ProcessTrigger Event | ||
34 | */ | ||
35 | OMX_ERRORTYPE OMXBase_ProcessTriggerEvent(OMX_HANDLETYPE hComponent, | ||
36 | OMX_U32 EventToSet) | ||
37 | { | ||
38 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
39 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
40 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
41 | OMXBaseComp *pBaseComp = NULL; | ||
42 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
43 | OMXBase_Port *pPort = NULL; | ||
44 | OMX_U32 i, nStartPort, nCount = 0; | ||
45 | OMX_BOOL bNotify = OMX_TRUE; | ||
46 | |||
47 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
48 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
49 | nStartPort = pBaseComp->nMinStartPortIndex; | ||
50 | if( EventToSet == DATAEVENT ) { | ||
51 | /*This var mey be accessed by multiple threads but it need not be mutex | ||
52 | protected*/ | ||
53 | if( pBaseCompPvt->bForceNotifyOnce ) { | ||
54 | pBaseCompPvt->bForceNotifyOnce = OMX_FALSE; | ||
55 | bNotify = OMX_TRUE; | ||
56 | goto EXIT; | ||
57 | } | ||
58 | |||
59 | for( i = 0; i < (pBaseComp->nNumPorts); i++ ) { | ||
60 | pPort = pBaseComp->pPorts[i]; | ||
61 | /*If port is disabled then move on*/ | ||
62 | if( !pPort->sPortDef.bEnabled ) { | ||
63 | continue; | ||
64 | } | ||
65 | /*If EOS has been recd. on any one port then always send notification*/ | ||
66 | if( pPort->sPortDef.eDir == OMX_DirInput && pPort->bEosRecd ) { | ||
67 | bNotify = OMX_TRUE; | ||
68 | goto EXIT; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | if( pBaseComp->bNotifyForAnyPort == OMX_TRUE ) { | ||
73 | bNotify = OMX_FALSE; | ||
74 | for( i = 0; i < (pBaseComp->nNumPorts); i++ ) { | ||
75 | pPort = pBaseComp->pPorts[i]; | ||
76 | /*If port is disabled then move on*/ | ||
77 | if( !pPort->sPortDef.bEnabled || | ||
78 | pPort->bIsInTransition) { | ||
79 | continue; | ||
80 | } | ||
81 | eError = pBaseCompPvt->fpDioGetCount(hComponent, nStartPort + i, | ||
82 | &nCount); | ||
83 | OMX_CHECK((eError == OMX_ErrorNone || eError == | ||
84 | (OMX_ERRORTYPE)OMX_TI_WarningEosReceived), eError); | ||
85 | /*Resetting to ErrorNone in case EOS warning is recd.*/ | ||
86 | eError = OMX_ErrorNone; | ||
87 | if((nCount >= pBaseComp->pPorts[i]->sProps.nWatermark)) { | ||
88 | bNotify = OMX_TRUE; | ||
89 | break; | ||
90 | } | ||
91 | } | ||
92 | } else { | ||
93 | for( i = 0; i < (pBaseComp->nNumPorts); i++ ) { | ||
94 | pPort = pBaseComp->pPorts[i]; | ||
95 | /*If port is disabled then move on*/ | ||
96 | if( !pPort->sPortDef.bEnabled || | ||
97 | pPort->bIsInTransition) { | ||
98 | continue; | ||
99 | } | ||
100 | eError = pBaseCompPvt->fpDioGetCount(hComponent, nStartPort + i, | ||
101 | &nCount); | ||
102 | OMX_CHECK((eError == OMX_ErrorNone || eError == | ||
103 | (OMX_ERRORTYPE)OMX_TI_WarningEosReceived), eError); | ||
104 | /*Resetting to ErrorNone in case EOS warning is recd.*/ | ||
105 | eError = OMX_ErrorNone; | ||
106 | if((nCount < pBaseComp->pPorts[i]->sProps.nWatermark)) { | ||
107 | bNotify = OMX_FALSE; | ||
108 | break; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | |||
114 | EXIT: | ||
115 | if( bNotify == OMX_TRUE && eError == OMX_ErrorNone ) { | ||
116 | tStatus = OSAL_SetEvent(pBaseCompPvt->pTriggerEvent, EventToSet, | ||
117 | OSAL_EVENT_OR); | ||
118 | if( tStatus != OSAL_ErrNone ) { | ||
119 | eError = OMX_ErrorUndefined; | ||
120 | } | ||
121 | } | ||
122 | return (eError); | ||
123 | } | ||
124 | |||
125 | /* | ||
126 | * OMX Base ProcessDataNotify | ||
127 | */ | ||
128 | OMX_ERRORTYPE OMXBase_ProcessDataNotify(OMX_HANDLETYPE hComponent) | ||
129 | { | ||
130 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
131 | OMXBaseComp *pBaseComp = NULL; | ||
132 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
133 | |||
134 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
135 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
136 | pBaseCompPvt->bForceNotifyOnce = OMX_FALSE; | ||
137 | return (OMXBase_ProcessTriggerEvent(hComponent, DATAEVENT)); | ||
138 | } | ||
139 | |||
140 | /* | ||
141 | * OMXBase Process Events | ||
142 | */ | ||
143 | OMX_ERRORTYPE OMXBase_ProcessEvents(OMX_HANDLETYPE hComponent, | ||
144 | OMX_U32 retEvent) | ||
145 | { | ||
146 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
147 | OMX_ERRORTYPE eErrorAux = OMX_ErrorNone; | ||
148 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
149 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
150 | OMXBaseComp *pBaseComp = NULL; | ||
151 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
152 | OMXBase_CmdParams sCmdParams; | ||
153 | uint32_t actualSize = 0; | ||
154 | OMX_BOOL bHandleFailEvent = OMX_FALSE; | ||
155 | |||
156 | |||
157 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
158 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
159 | if( retEvent & CMDEVENT ) { | ||
160 | tStatus = OSAL_ObtainMutex(pBaseCompPvt->pCmdPipeMutex, | ||
161 | OSAL_SUSPEND); | ||
162 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
163 | /* process command event */ | ||
164 | tStatus = OSAL_IsPipeReady(pBaseCompPvt->pCmdPipe); | ||
165 | if( tStatus != OSAL_ErrNone ) { | ||
166 | /*No command in pipe - return*/ | ||
167 | tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); | ||
168 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
169 | goto EXIT; | ||
170 | } | ||
171 | tStatus = OSAL_ReadFromPipe(pBaseCompPvt->pCmdPipe, &sCmdParams, | ||
172 | sizeof(OMXBase_CmdParams), &actualSize, OSAL_NO_SUSPEND); | ||
173 | if( OSAL_ErrNone != tStatus ) { | ||
174 | eError = OMX_ErrorUndefined; | ||
175 | } | ||
176 | tStatus = OSAL_ReleaseMutex(pBaseCompPvt->pCmdPipeMutex); | ||
177 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
178 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
179 | |||
180 | eError = OMXBase_ProcessCmdEvent(hComponent, sCmdParams.eCmd, | ||
181 | sCmdParams.unParam, sCmdParams.pCmdData); | ||
182 | if( OMX_ErrorNone != eError ) { | ||
183 | bHandleFailEvent = OMX_TRUE; | ||
184 | goto EXIT; | ||
185 | } | ||
186 | } else if( retEvent & DATAEVENT ) { | ||
187 | /* process data Event */ | ||
188 | eError = OMXBase_ProcessDataEvent(hComponent); | ||
189 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
190 | } | ||
191 | EXIT: | ||
192 | if( OMX_ErrorNone != eError ) { | ||
193 | if(eError != OMX_ErrorDynamicResourcesUnavailable) { | ||
194 | eErrorAux = pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
195 | pComp->pApplicationPrivate, | ||
196 | OMX_EventError, eError, | ||
197 | OMX_StateInvalid, NULL); | ||
198 | } else { | ||
199 | eErrorAux = pBaseCompPvt->sAppCallbacks.EventHandler(hComponent, | ||
200 | pComp->pApplicationPrivate, | ||
201 | OMX_EventError, eError, | ||
202 | OMX_StateLoaded, NULL); | ||
203 | } | ||
204 | /*Component can do nothing if callback returns error*/ | ||
205 | /*Just calling OMXBase_HandleFailEvent for SetState since it was the | ||
206 | * the intention. When Allocation fails while Dynamic Resources Allocation | ||
207 | * we are experiencing hang waiting forever for PortDisable event completion | ||
208 | * after attempted an unsuccessful PortEnable. | ||
209 | */ | ||
210 | if( bHandleFailEvent && (eError != OMX_ErrorDynamicResourcesUnavailable) ) { | ||
211 | OMXBase_HandleFailEvent(hComponent, sCmdParams.eCmd, sCmdParams.unParam); | ||
212 | } | ||
213 | } | ||
214 | if( (OMX_ErrorNone != eError) && (eError != OMX_ErrorDynamicResourcesUnavailable) ) { | ||
215 | return (eError); //return actual error if any | ||
216 | } | ||
217 | |||
218 | return (eErrorAux); | ||
219 | } | ||
220 | |||
221 | /* | ||
222 | * OMX Base Process Command Event | ||
223 | */ | ||
224 | static OMX_ERRORTYPE OMXBase_ProcessCmdEvent(OMX_HANDLETYPE hComponent, | ||
225 | OMX_COMMANDTYPE Cmd, | ||
226 | OMX_U32 nParam, | ||
227 | OMX_PTR pCmdData) | ||
228 | { | ||
229 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
230 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
231 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
232 | OMXBaseComp *pBaseComp = NULL; | ||
233 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
234 | OMX_U32 i, nPorts, nStartPortNum; | ||
235 | uint32_t retEvents = 0; | ||
236 | |||
237 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
238 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
239 | nPorts = pBaseComp->nNumPorts; | ||
240 | nStartPortNum = pBaseComp->nMinStartPortIndex; | ||
241 | |||
242 | switch( Cmd ) { | ||
243 | case OMX_CommandStateSet : | ||
244 | eError = OMXBase_HandleStateTransition(hComponent, nParam); | ||
245 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
246 | break; | ||
247 | |||
248 | case OMX_CommandPortDisable : | ||
249 | /* Notify to Derived Component here so that derived component | ||
250 | receives correct param - ALL or specific port no. */ | ||
251 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
252 | OMX_CommandPortDisable, nParam, pCmdData); | ||
253 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
254 | |||
255 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
256 | OMXBase_CmdPortDisable, OSAL_EVENT_OR_CONSUME, | ||
257 | &retEvents, OSAL_SUSPEND); | ||
258 | OMX_CHECK(OSAL_ErrNone == tStatus, | ||
259 | OMX_ErrorInsufficientResources); | ||
260 | if( nParam == OMX_ALL ) { | ||
261 | for( i = nStartPortNum; i < nPorts; i++ ) { | ||
262 | eError = OMXBase_DisablePort(hComponent, i); | ||
263 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
264 | } | ||
265 | } else { | ||
266 | eError = OMXBase_DisablePort(hComponent, nParam); | ||
267 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
268 | } | ||
269 | break; | ||
270 | |||
271 | case OMX_CommandPortEnable : | ||
272 | /* Notify to Derived Component here so that derived component | ||
273 | receives correct param - ALL or specific port no. */ | ||
274 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
275 | OMX_CommandPortEnable, nParam, pCmdData); | ||
276 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
277 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
278 | OMXBase_CmdPortEnable, OSAL_EVENT_OR_CONSUME, | ||
279 | &retEvents, OSAL_SUSPEND); | ||
280 | OMX_CHECK(OSAL_ErrNone == tStatus, | ||
281 | OMX_ErrorInsufficientResources); | ||
282 | if( nParam == OMX_ALL ) { | ||
283 | for( i = nStartPortNum; i < nPorts; i++ ) { | ||
284 | eError = OMXBase_EnablePort(hComponent, i); | ||
285 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
286 | } | ||
287 | } else { | ||
288 | eError = OMXBase_EnablePort(hComponent, nParam); | ||
289 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
290 | } | ||
291 | break; | ||
292 | |||
293 | case OMX_CommandFlush : | ||
294 | if( pBaseComp->tCurState == OMX_StateLoaded || | ||
295 | pBaseComp->tCurState == OMX_StateWaitForResources ) { | ||
296 | } else if((nParam != OMX_ALL) && (pBaseComp->pPorts | ||
297 | [nParam - nStartPortNum]->sPortDef.bEnabled == OMX_FALSE)) { | ||
298 | /*Nothing to be done for disabled port, just exit*/ | ||
299 | } else { | ||
300 | /* Notify to Derived Component here so that derived component | ||
301 | receives correct param - ALL or specific port no. */ | ||
302 | eError = pBaseComp->fpCommandNotify(hComponent, | ||
303 | OMX_CommandFlush, nParam, pCmdData); | ||
304 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
305 | tStatus = OSAL_RetrieveEvent(pBaseCompPvt->pCmdCompleteEvent, | ||
306 | OMXBase_CmdFlush, OSAL_EVENT_OR_CONSUME, | ||
307 | &retEvents, OSAL_SUSPEND); | ||
308 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
309 | if( nParam == OMX_ALL ) { | ||
310 | for( i = nStartPortNum; i < nPorts; i++ ) { | ||
311 | eError = OMXBase_FlushBuffers(hComponent, i); | ||
312 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
313 | } | ||
314 | } else { | ||
315 | eError = OMXBase_FlushBuffers(hComponent, nParam); | ||
316 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
317 | } | ||
318 | } | ||
319 | break; | ||
320 | |||
321 | case OMX_CommandMarkBuffer : | ||
322 | eError = pBaseComp->fpCommandNotify(hComponent, Cmd, | ||
323 | nParam, pCmdData); | ||
324 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
325 | break; | ||
326 | |||
327 | default : | ||
328 | OSAL_ErrorTrace(" unknown command received "); | ||
329 | break; | ||
330 | } | ||
331 | |||
332 | eError = OMXBase_EventNotifyToClient(hComponent, Cmd, nParam, pCmdData); | ||
333 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
334 | |||
335 | EXIT: | ||
336 | return (eError); | ||
337 | } | ||
338 | |||
339 | /* | ||
340 | * OMX Base Process Data Event | ||
341 | */ | ||
342 | static OMX_ERRORTYPE OMXBase_ProcessDataEvent(OMX_HANDLETYPE hComponent) | ||
343 | { | ||
344 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
345 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
346 | OMXBaseComp *pBaseComp = NULL; | ||
347 | |||
348 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
349 | eError = pBaseComp->fpDataNotify(hComponent); | ||
350 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
351 | |||
352 | EXIT: | ||
353 | return (eError); | ||
354 | } | ||
355 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_BASE_DIO_PLUGIN_H | ||
18 | #define _OMX_BASE_DIO_PLUGIN_H | ||
19 | |||
20 | #ifdef _cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <OMX_Core.h> | ||
25 | #include <OMX_Component.h> | ||
26 | |||
27 | #define OMX_BASE_MAXNAMELEN OMX_MAX_STRINGNAME_SIZE | ||
28 | |||
29 | /* The OMX_DIO_OpenMode enumeration is used to | ||
30 | * sepcify the open mode type i.e reader or writer | ||
31 | */ | ||
32 | typedef enum OMX_DIO_OpenMode { | ||
33 | OMX_DIO_READER = 0x0, | ||
34 | OMX_DIO_WRITER = 0x1 | ||
35 | }OMX_DIO_OpenMode; | ||
36 | |||
37 | /** OMX_DIO_CreateParams : | ||
38 | * This structure contains the parameters required to | ||
39 | * create DIO object | ||
40 | * | ||
41 | * @param cChannelName : channel name | ||
42 | * @param hComponent : Handle of Component | ||
43 | * @param nPortIndex : Index of the port | ||
44 | * @param pAppCallbacks : Application callbacks | ||
45 | */ | ||
46 | typedef struct OMX_DIO_CreateParams { | ||
47 | char cChannelName[OMX_BASE_MAXNAMELEN]; | ||
48 | OMX_HANDLETYPE hComponent; | ||
49 | OMX_U8 nPortIndex; | ||
50 | OMX_CALLBACKTYPE *pAppCallbacks; | ||
51 | }OMX_DIO_CreateParams; | ||
52 | |||
53 | |||
54 | /** OMX_DIO_OpenParams : | ||
55 | * This structure contains the open parameters for DIO object | ||
56 | * @param nMode : open mode reader or writer | ||
57 | * @param bCacheFlag : cache access flag - true if buffer is accessed via | ||
58 | * processor/cache | ||
59 | * @param nBufSize : used by non-tunnel open as allocate buffer call | ||
60 | * can specify a different size | ||
61 | */ | ||
62 | typedef struct OMX_DIO_OpenParams { | ||
63 | OMX_U32 nMode; | ||
64 | OMX_BOOL bCacheFlag; | ||
65 | OMX_U32 nBufSize; | ||
66 | }OMX_DIO_OpenParams; | ||
67 | |||
68 | typedef OMX_ERRORTYPE (*OMX_DIO_Init)(OMX_IN OMX_HANDLETYPE hComponent, | ||
69 | OMX_IN OMX_PTR pCreateParams); | ||
70 | |||
71 | /* OMX_DIO_Register : | ||
72 | * This structure contains the params used to register the DIO object | ||
73 | * @param pChannelName : Channel Name | ||
74 | * @param pInitialize : DIO instace initialization function | ||
75 | */ | ||
76 | typedef struct OMX_DIO_Register { | ||
77 | const char *cChannelType; | ||
78 | OMX_DIO_Init pInitialize; | ||
79 | }OMX_DIO_Register; | ||
80 | |||
81 | extern OMX_DIO_Register OMX_DIO_Registered[2]; | ||
82 | /* | ||
83 | * The OMX_DIO_CtrlCmd_TYPE : This enumeration is used to | ||
84 | * specify the action in the | ||
85 | * OMX_DIO_Control Macro. | ||
86 | * | ||
87 | * @ param OMX_DIO_CtrlCmd_Flush : Flush the buffers on this port. | ||
88 | * This command is used only by | ||
89 | * omx_base for now. | ||
90 | * @ param OMX_DIO_CtrlCmd_Start : Start buffer processing on this | ||
91 | * port. This command is used only by | ||
92 | * omx_base for now. | ||
93 | * @ param OMX_DIO_CtrlCmd_Stop : Stop buffer processing on this | ||
94 | * port. This command is used only by | ||
95 | * omx_base for now. | ||
96 | * @ param OMX_DIO_CtrlCmd_GetCtrlAttribute : To get the attribute pending | ||
97 | * on this port. A pointer to structure | ||
98 | * of type | ||
99 | * OMXBase_CodecConfig is | ||
100 | * passed as the parameter to the | ||
101 | * control command. This should be used | ||
102 | * if dio_dequeue returns | ||
103 | * OMX_WarningAttributePending | ||
104 | * indicating that an attribute buffer | ||
105 | * is pending. | ||
106 | * @ param OMX_DIO_CtrlCmd_SetCtrlAttribute : To send some attribute on | ||
107 | * this port. A pointer to structure of | ||
108 | * type OMXBase_CodecConfig | ||
109 | * is passed as the parameter to the | ||
110 | * control command. | ||
111 | * @ param OMX_DIO_CtrlCmd_ExtnStart : If some specific DIO | ||
112 | * implementation wants to have control | ||
113 | * commands specific for that DIO then | ||
114 | * these extended commands can be added | ||
115 | * after this. | ||
116 | */ | ||
117 | typedef enum OMX_DIO_CtrlCmdType { | ||
118 | OMX_DIO_CtrlCmd_Flush = 0x1, | ||
119 | OMX_DIO_CtrlCmd_Start = 0x2, | ||
120 | OMX_DIO_CtrlCmd_Stop = 0x3, | ||
121 | OMX_DIO_CtrlCmd_GetCtrlAttribute = 0x4, | ||
122 | OMX_DIO_CtrlCmd_SetCtrlAttribute = 0x5, | ||
123 | OMX_DIO_CtrlCmd_ExtnStart = 0xA | ||
124 | }OMX_DIO_CtrlCmdType; | ||
125 | |||
126 | |||
127 | /** OMX_DIO_Object : | ||
128 | * This structure contains the params and interface to access the DIO object | ||
129 | * | ||
130 | * @param pContext : pointer to the DIO private data area | ||
131 | * @param (*open) : DIO object open Implementation | ||
132 | * @param (*close) : DIO object close Implementation | ||
133 | * @param (*queue) : DIO object queue Implementation | ||
134 | * @param (*dequeue) : DIO object dequeu Implementation | ||
135 | * @param (*send) : DIO object send Implementation | ||
136 | * @param (*cancel) : DIO object cancel Implementation | ||
137 | * @param (*control) : DIO object control Implementation | ||
138 | * @param (*getcount) : DIO object getcount Implementation | ||
139 | * @param (*deinit) : DIO object deinit Implementation | ||
140 | * @param bOpened : Indicates whether DIO has been opened on this port | ||
141 | */ | ||
142 | typedef struct OMX_DIO_Object { | ||
143 | |||
144 | OMX_PTR pContext; | ||
145 | |||
146 | OMX_ERRORTYPE (*open)(OMX_HANDLETYPE handle, | ||
147 | OMX_DIO_OpenParams *pParams); | ||
148 | |||
149 | OMX_ERRORTYPE (*close)(OMX_HANDLETYPE handle); | ||
150 | |||
151 | OMX_ERRORTYPE (*queue)(OMX_HANDLETYPE handle, | ||
152 | OMX_PTR pBuffHeader); | ||
153 | |||
154 | OMX_ERRORTYPE (*dequeue)(OMX_HANDLETYPE handle, | ||
155 | OMX_PTR *pBuffHeader); | ||
156 | |||
157 | OMX_ERRORTYPE (*send)(OMX_HANDLETYPE handle, | ||
158 | OMX_PTR pBuffHeader); | ||
159 | |||
160 | OMX_ERRORTYPE (*cancel)(OMX_HANDLETYPE handle, | ||
161 | OMX_PTR pBuffHeader); | ||
162 | |||
163 | OMX_ERRORTYPE (*control)(OMX_HANDLETYPE handle, | ||
164 | OMX_DIO_CtrlCmdType nCmdType, | ||
165 | OMX_PTR pParams); | ||
166 | |||
167 | OMX_ERRORTYPE (*getcount)(OMX_HANDLETYPE handle, | ||
168 | OMX_U32 *pCount); | ||
169 | |||
170 | OMX_ERRORTYPE (*deinit)(OMX_HANDLETYPE handle); | ||
171 | |||
172 | OMX_BOOL bOpened; | ||
173 | |||
174 | }OMX_DIO_Object; | ||
175 | |||
176 | #ifdef __cplusplus | ||
177 | } | ||
178 | #endif | ||
179 | |||
180 | #endif | ||
181 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | #define LOG_TAG "OMX_BASE_DIO" | ||
17 | |||
18 | #include <string.h> | ||
19 | #include <omx_base.h> | ||
20 | |||
21 | static OMX_PTR OMXBase_DIO_GetPort(OMX_HANDLETYPE hComponent, | ||
22 | OMX_U32 nPortIndex); | ||
23 | /* | ||
24 | * OMXBase DIO Init | ||
25 | */ | ||
26 | OMX_ERRORTYPE OMXBase_DIO_Init (OMX_HANDLETYPE hComponent, | ||
27 | OMX_U32 nPortIndex, | ||
28 | OMX_STRING cChannelType, | ||
29 | OMX_PTR pCreateParams) | ||
30 | { | ||
31 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
32 | OMX_DIO_Object *hDIO = NULL; | ||
33 | OMXBase_Port *pPort = NULL; | ||
34 | OMX_BOOL bFound = OMX_FALSE; | ||
35 | OMX_U32 i = 0; | ||
36 | |||
37 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
38 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
39 | |||
40 | OMX_CHECK(NULL != cChannelType, OMX_ErrorBadParameter); | ||
41 | |||
42 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
43 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
44 | |||
45 | while( NULL != OMX_DIO_Registered[i].cChannelType ) { | ||
46 | if( strcmp(cChannelType, OMX_DIO_Registered[i].cChannelType) == 0 ) { | ||
47 | bFound = OMX_TRUE; | ||
48 | break; | ||
49 | } | ||
50 | i++; | ||
51 | } | ||
52 | |||
53 | if( bFound ) { | ||
54 | hDIO = (OMX_DIO_Object *) OSAL_Malloc(sizeof(OMX_DIO_Object)); | ||
55 | OMX_CHECK(NULL != hDIO, OMX_ErrorInsufficientResources); | ||
56 | OSAL_Memset(hDIO, 0x0, sizeof(OMX_DIO_Object)); | ||
57 | |||
58 | /* Initialize the DIO object depending on the ChannelType */ | ||
59 | eError = OMX_DIO_Registered[i].pInitialize(hDIO, pCreateParams); | ||
60 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
61 | |||
62 | /* Assign DIO handle to port */ | ||
63 | pPort->hDIO = hDIO; | ||
64 | } else { | ||
65 | OMX_CHECK(OMX_FALSE, OMX_ErrorUndefined); | ||
66 | } | ||
67 | |||
68 | EXIT: | ||
69 | return (eError); | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * OMXBase DIO DeInit | ||
74 | */ | ||
75 | OMX_ERRORTYPE OMXBase_DIO_Deinit (OMX_HANDLETYPE hComponent, | ||
76 | OMX_U32 nPortIndex) | ||
77 | { | ||
78 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
79 | OMX_DIO_Object *hDIO = NULL; | ||
80 | OMXBase_Port *pPort = NULL; | ||
81 | |||
82 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
83 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
84 | |||
85 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
86 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
87 | |||
88 | eError = hDIO->deinit(hDIO); | ||
89 | |||
90 | OSAL_Free(pPort->hDIO); | ||
91 | pPort->hDIO = NULL; | ||
92 | |||
93 | EXIT: | ||
94 | return (eError); | ||
95 | } | ||
96 | |||
97 | /* | ||
98 | * OMXBase DIO Open | ||
99 | */ | ||
100 | OMX_ERRORTYPE OMXBase_DIO_Open (OMX_HANDLETYPE hComponent, | ||
101 | OMX_U32 nPortIndex, | ||
102 | OMX_PTR pOpenParams) | ||
103 | { | ||
104 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
105 | OMX_DIO_Object *hDIO = NULL; | ||
106 | OMXBase_Port *pPort = NULL; | ||
107 | |||
108 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
109 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
110 | |||
111 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
112 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
113 | |||
114 | eError = hDIO->open(hDIO, (OMX_DIO_OpenParams *)pOpenParams); | ||
115 | |||
116 | EXIT: | ||
117 | if( eError == OMX_ErrorNone ) { | ||
118 | hDIO->bOpened = OMX_TRUE; | ||
119 | } | ||
120 | return (eError); | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | * OMX Base DIO close | ||
125 | */ | ||
126 | OMX_ERRORTYPE OMXBase_DIO_Close (OMX_HANDLETYPE hComponent, | ||
127 | OMX_U32 nPortIndex) | ||
128 | { | ||
129 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
130 | OMX_DIO_Object *hDIO = NULL; | ||
131 | OMXBase_Port *pPort = NULL; | ||
132 | |||
133 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
134 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
135 | |||
136 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
137 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
138 | |||
139 | hDIO->bOpened = OMX_FALSE; | ||
140 | eError = hDIO->close(hDIO); | ||
141 | |||
142 | EXIT: | ||
143 | return (eError); | ||
144 | } | ||
145 | |||
146 | /* | ||
147 | * OMX Base DIO Queue | ||
148 | */ | ||
149 | OMX_ERRORTYPE OMXBase_DIO_Queue (OMX_HANDLETYPE hComponent, | ||
150 | OMX_U32 nPortIndex, | ||
151 | OMX_PTR pBuffHeader) | ||
152 | { | ||
153 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
154 | OMX_DIO_Object *hDIO = NULL; | ||
155 | OMXBase_Port *pPort = NULL; | ||
156 | |||
157 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
158 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
159 | |||
160 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
161 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
162 | |||
163 | eError = hDIO->queue(hDIO, pBuffHeader); | ||
164 | |||
165 | EXIT: | ||
166 | return (eError); | ||
167 | } | ||
168 | |||
169 | /* | ||
170 | * OMXBase DIO Dequeue | ||
171 | */ | ||
172 | OMX_ERRORTYPE OMXBase_DIO_Dequeue (OMX_HANDLETYPE hComponent, | ||
173 | OMX_U32 nPortIndex, | ||
174 | OMX_PTR *pBuffHeader) | ||
175 | { | ||
176 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
177 | OMX_DIO_Object *hDIO = NULL; | ||
178 | OMXBase_Port *pPort = NULL; | ||
179 | |||
180 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
181 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
182 | |||
183 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
184 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
185 | |||
186 | eError = hDIO->dequeue(hDIO, pBuffHeader); | ||
187 | |||
188 | EXIT: | ||
189 | return (eError); | ||
190 | } | ||
191 | |||
192 | /* | ||
193 | * OMXBase DIO Send | ||
194 | */ | ||
195 | OMX_ERRORTYPE OMXBase_DIO_Send (OMX_HANDLETYPE hComponent, | ||
196 | OMX_U32 nPortIndex, | ||
197 | OMX_PTR pBuffHeader) | ||
198 | { | ||
199 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
200 | OMX_DIO_Object *hDIO = NULL; | ||
201 | OMXBase_Port *pPort = NULL; | ||
202 | |||
203 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
204 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
205 | |||
206 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
207 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
208 | |||
209 | eError = hDIO->send(hDIO, pBuffHeader); | ||
210 | |||
211 | EXIT: | ||
212 | return (eError); | ||
213 | } | ||
214 | |||
215 | /* | ||
216 | * OMXBase DIO Cancel | ||
217 | */ | ||
218 | OMX_ERRORTYPE OMXBase_DIO_Cancel (OMX_HANDLETYPE hComponent, | ||
219 | OMX_U32 nPortIndex, | ||
220 | OMX_PTR pBuffHeader) | ||
221 | { | ||
222 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
223 | OMX_DIO_Object *hDIO = NULL; | ||
224 | OMXBase_Port *pPort = NULL; | ||
225 | |||
226 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
227 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
228 | |||
229 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
230 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
231 | |||
232 | eError = hDIO->cancel(hDIO, pBuffHeader); | ||
233 | |||
234 | EXIT: | ||
235 | return (eError); | ||
236 | } | ||
237 | |||
238 | /* | ||
239 | * OMXBase DIO Control | ||
240 | */ | ||
241 | OMX_ERRORTYPE OMXBase_DIO_Control (OMX_HANDLETYPE hComponent, | ||
242 | OMX_U32 nPortIndex, | ||
243 | OMX_DIO_CtrlCmdType nCmdType, | ||
244 | OMX_PTR pParams) | ||
245 | { | ||
246 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
247 | OMX_DIO_Object *hDIO = NULL; | ||
248 | OMXBase_Port *pPort = NULL; | ||
249 | |||
250 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
251 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
252 | |||
253 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
254 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
255 | |||
256 | eError = hDIO->control(hDIO, nCmdType, pParams); | ||
257 | |||
258 | EXIT: | ||
259 | return (eError); | ||
260 | } | ||
261 | |||
262 | /* | ||
263 | * OMX Base DIO GetCount | ||
264 | */ | ||
265 | OMX_ERRORTYPE OMXBase_DIO_GetCount (OMX_HANDLETYPE hComponent, | ||
266 | OMX_U32 nPortIndex, | ||
267 | OMX_U32 *pCount) | ||
268 | { | ||
269 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
270 | OMX_DIO_Object *hDIO = NULL; | ||
271 | OMXBase_Port *pPort = NULL; | ||
272 | |||
273 | /*Resetting count to 0 initially*/ | ||
274 | *pCount = 0; | ||
275 | pPort = OMXBase_DIO_GetPort(hComponent, nPortIndex); | ||
276 | OMX_CHECK(pPort != NULL, OMX_ErrorBadParameter); | ||
277 | |||
278 | hDIO = (OMX_DIO_Object *)pPort->hDIO; | ||
279 | OMX_CHECK(hDIO != NULL, OMX_ErrorBadParameter); | ||
280 | |||
281 | eError = hDIO->getcount(hDIO, pCount); | ||
282 | |||
283 | EXIT: | ||
284 | return (eError); | ||
285 | } | ||
286 | |||
287 | |||
288 | /* | ||
289 | * OMX Base DIO GetPort from the PortIndex | ||
290 | */ | ||
291 | static OMX_PTR OMXBase_DIO_GetPort(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex) | ||
292 | { | ||
293 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
294 | OMXBaseComp *pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
295 | OMXBase_Port *pPort = NULL; | ||
296 | OMX_U32 nStartPortNumber = 0; | ||
297 | |||
298 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
299 | if( pBaseComp->pPorts == NULL ) { | ||
300 | pPort = NULL; | ||
301 | goto EXIT; | ||
302 | } | ||
303 | pPort = (OMXBase_Port *)pBaseComp->pPorts[nPortIndex - nStartPortNumber]; | ||
304 | |||
305 | EXIT: | ||
306 | return (pPort); | ||
307 | } | ||
308 | |||
309 | |||
310 | |||
311 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_BASE_DIO_NONTUNNEL" | ||
18 | |||
19 | #include <omx_base.h> | ||
20 | #include <memplugin.h> | ||
21 | #include <OMX_TI_Custom.h> | ||
22 | |||
23 | typedef struct DIO_NonTunnel_Attrs { | ||
24 | OMX_DIO_CreateParams sCreateParams; | ||
25 | OMX_U32 nFlags; | ||
26 | OMX_PTR pPipeHandle; | ||
27 | OMX_PTR pHdrPool; | ||
28 | OMX_PTR pPlatformPrivatePool; | ||
29 | }DIO_NonTunnel_Attrs; | ||
30 | |||
31 | |||
32 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Open (OMX_HANDLETYPE handle, | ||
33 | OMX_DIO_OpenParams *pParams); | ||
34 | |||
35 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Close (OMX_HANDLETYPE handle); | ||
36 | |||
37 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Queue (OMX_HANDLETYPE handle, | ||
38 | OMX_PTR pBuffHeader); | ||
39 | |||
40 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Dequeue (OMX_HANDLETYPE handle, | ||
41 | OMX_PTR *pBuffHeader); | ||
42 | |||
43 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Send (OMX_HANDLETYPE handle, | ||
44 | OMX_PTR pBuffHeader); | ||
45 | |||
46 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Cancel (OMX_HANDLETYPE handle, | ||
47 | OMX_PTR pBuffHeader); | ||
48 | |||
49 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Control (OMX_HANDLETYPE handle, | ||
50 | OMX_DIO_CtrlCmdType nCmdType, | ||
51 | OMX_PTR pParams); | ||
52 | |||
53 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Getcount (OMX_HANDLETYPE handle, | ||
54 | OMX_U32 *pCount); | ||
55 | |||
56 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Deinit (OMX_HANDLETYPE handle); | ||
57 | |||
58 | /* | ||
59 | * _DIO_GetPort from Port Index | ||
60 | */ | ||
61 | static OMX_PTR _DIO_GetPort(OMX_HANDLETYPE handle, OMX_U32 nPortIndex) | ||
62 | { | ||
63 | OMX_COMPONENTTYPE *pComp; | ||
64 | OMXBaseComp *pBaseComp; | ||
65 | OMXBase_Port *pPort = NULL; | ||
66 | OMX_U32 nStartPortNumber = 0; | ||
67 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
68 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
69 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
70 | |||
71 | pComp = (OMX_COMPONENTTYPE *)(pContext->sCreateParams.hComponent); | ||
72 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
73 | |||
74 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
75 | if( pBaseComp->pPorts == NULL ) { | ||
76 | pPort = NULL; | ||
77 | goto EXIT; | ||
78 | } | ||
79 | |||
80 | pPort = (OMXBase_Port *)pBaseComp->pPorts[nPortIndex - nStartPortNumber]; | ||
81 | |||
82 | EXIT: | ||
83 | return (pPort); | ||
84 | } | ||
85 | |||
86 | /* | ||
87 | * DIO NoneTunnel Init | ||
88 | */ | ||
89 | OMX_ERRORTYPE OMX_DIO_NonTunnel_Init(OMX_HANDLETYPE handle, | ||
90 | OMX_PTR pCreateParams) | ||
91 | { | ||
92 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
93 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
94 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
95 | |||
96 | OMX_COMPONENTTYPE *pComp = (OMX_COMPONENTTYPE *)(((OMX_DIO_CreateParams *)(pCreateParams))->hComponent); | ||
97 | OMXBaseComp *pBaseComPvt = (OMXBaseComp *)pComp->pComponentPrivate; | ||
98 | |||
99 | /* creating memory for DIO object private area */ | ||
100 | hDIO->pContext = OSAL_Malloc(sizeof(DIO_NonTunnel_Attrs)); | ||
101 | OMX_CHECK(NULL != hDIO->pContext, OMX_ErrorInsufficientResources); | ||
102 | |||
103 | OSAL_Memset(hDIO->pContext, 0x0, sizeof(DIO_NonTunnel_Attrs)); | ||
104 | |||
105 | hDIO->open = OMX_DIO_NonTunnel_Open; | ||
106 | hDIO->close = OMX_DIO_NonTunnel_Close; | ||
107 | hDIO->queue = OMX_DIO_NonTunnel_Queue; | ||
108 | hDIO->dequeue = OMX_DIO_NonTunnel_Dequeue; | ||
109 | hDIO->send = OMX_DIO_NonTunnel_Send; | ||
110 | hDIO->cancel = OMX_DIO_NonTunnel_Cancel; | ||
111 | hDIO->control = OMX_DIO_NonTunnel_Control; | ||
112 | hDIO->getcount = OMX_DIO_NonTunnel_Getcount; | ||
113 | hDIO->deinit = OMX_DIO_NonTunnel_Deinit; | ||
114 | |||
115 | pContext = hDIO->pContext; | ||
116 | /* Initialize private data */ | ||
117 | pContext->sCreateParams = *(OMX_DIO_CreateParams *)pCreateParams; | ||
118 | |||
119 | EXIT: | ||
120 | return (eError); | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | * DIO NonTunnel DeInit | ||
125 | */ | ||
126 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Deinit (OMX_HANDLETYPE handle) | ||
127 | { | ||
128 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
129 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
130 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
131 | |||
132 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
133 | if( NULL != pContext ) { | ||
134 | OSAL_Free(pContext); | ||
135 | pContext = NULL; | ||
136 | } | ||
137 | |||
138 | return (eError); | ||
139 | } | ||
140 | |||
141 | /* | ||
142 | * DIO NonTunnel Open | ||
143 | */ | ||
144 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Open (OMX_HANDLETYPE handle, | ||
145 | OMX_DIO_OpenParams *pParams) | ||
146 | { | ||
147 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
148 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
149 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
150 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
151 | OMXBase_Port *pPort = NULL; | ||
152 | OMX_U32 i = 0; | ||
153 | OMX_U32 nPortIndex = 0; | ||
154 | OMX_U32 nStartPortNumber = 0; | ||
155 | OMX_U8 *pTmpBuffer = NULL; | ||
156 | OMX_U32 nLocalComBuffers = 0; | ||
157 | OMX_PTR *pBufArr = NULL; | ||
158 | |||
159 | OMX_COMPONENTTYPE *pComp = NULL; | ||
160 | OMXBaseComp *pBaseComp = NULL; | ||
161 | |||
162 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
163 | pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); | ||
164 | pComp = (OMX_COMPONENTTYPE *)(pContext->sCreateParams.hComponent); | ||
165 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
166 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
167 | nPortIndex = pContext->sCreateParams.nPortIndex; | ||
168 | |||
169 | /* supplier should allocate both the buffer and buffer headers | ||
170 | non supplier should allocate only the buffer headers */ | ||
171 | pPort->pBufferlist = (OMX_BUFFERHEADERTYPE * *)OSAL_Malloc( | ||
172 | (pPort->sPortDef.nBufferCountActual * sizeof(OMX_BUFFERHEADERTYPE *))); | ||
173 | |||
174 | OMX_CHECK(NULL != pPort->pBufferlist, OMX_ErrorInsufficientResources); | ||
175 | OSAL_Memset(pPort->pBufferlist, 0, (pPort->sPortDef.nBufferCountActual | ||
176 | * sizeof(OMX_BUFFERHEADERTYPE *))); | ||
177 | /* create a buffer header pool */ | ||
178 | pContext->pHdrPool = (OMX_PTR)OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE) | ||
179 | * (pPort->sPortDef.nBufferCountActual)); | ||
180 | OMX_CHECK(NULL != pContext->pHdrPool, OMX_ErrorInsufficientResources); | ||
181 | OSAL_Memset(pContext->pHdrPool, 0, sizeof(OMX_BUFFERHEADERTYPE) * | ||
182 | (pPort->sPortDef.nBufferCountActual)); | ||
183 | |||
184 | pContext->pPlatformPrivatePool = (OMX_PTR)OSAL_Malloc(pPort->sPortDef.nBufferCountActual | ||
185 | * sizeof(OMXBase_BufHdrPvtData)); | ||
186 | OMX_CHECK(NULL != pContext->pPlatformPrivatePool, OMX_ErrorInsufficientResources); | ||
187 | |||
188 | /*Setting platform port pvt pool to 0*/ | ||
189 | OSAL_Memset(pContext->pPlatformPrivatePool, 0, | ||
190 | pPort->sPortDef.nBufferCountActual * | ||
191 | sizeof(OMXBase_BufHdrPvtData)); | ||
192 | |||
193 | if( pPort->bIsBufferAllocator) { | ||
194 | //Setting up fields for calling configure | ||
195 | nLocalComBuffers = pBaseComp->pPorts[nPortIndex - nStartPortNumber]->sProps. | ||
196 | nNumComponentBuffers; | ||
197 | if( nLocalComBuffers != 1 && pBaseComp-> | ||
198 | pPorts[nPortIndex - nStartPortNumber]->sProps.eBufMemoryType != | ||
199 | MEM_TILER8_2D ) { | ||
200 | //For non 2D buffers multiple component buffers not supported | ||
201 | OMX_CHECK(OMX_FALSE, OMX_ErrorBadParameter); | ||
202 | } | ||
203 | |||
204 | pBufArr = OSAL_Malloc(sizeof(OMX_PTR) * nLocalComBuffers); | ||
205 | OMX_CHECK(NULL != pBufArr, OMX_ErrorInsufficientResources); | ||
206 | } | ||
207 | |||
208 | /* update buffer list with buffer and buffer headers */ | ||
209 | for( i = 0; i < pPort->sPortDef.nBufferCountActual; i++ ) { | ||
210 | pPort->pBufferlist[i] = (OMX_BUFFERHEADERTYPE *)(pContext->pHdrPool) + i; | ||
211 | OMX_BASE_INIT_STRUCT_PTR(pPort->pBufferlist[i], OMX_BUFFERHEADERTYPE); | ||
212 | pPort->pBufferlist[i]->pPlatformPrivate = | ||
213 | (OMXBase_BufHdrPvtData *)(pContext->pPlatformPrivatePool) + i; | ||
214 | |||
215 | ((OMXBase_BufHdrPvtData *)(pPort->pBufferlist[i]->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; | ||
216 | ((OMXBase_BufHdrPvtData *)(pPort->pBufferlist[i]->pPlatformPrivate))->bIsLocked = OMX_FALSE; | ||
217 | |||
218 | if( pPort->bIsBufferAllocator) { | ||
219 | MemHeader *h = &(((OMXBase_BufHdrPvtData *)(pPort->pBufferlist[i]->pPlatformPrivate))->sMemHdr[0]); | ||
220 | pPort->pBufferlist[i]->pBuffer = memplugin_alloc_noheader(h, pParams->nBufSize, 1, MEM_CARVEOUT, 0, 0); | ||
221 | if( nLocalComBuffers == 2 ) { | ||
222 | OMX_CHECK(OMX_FALSE, OMX_ErrorNotImplemented); | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /* create a fixed size OS pipe */ | ||
228 | tStatus = OSAL_CreatePipe(&pContext->pPipeHandle, | ||
229 | (sizeof(OMX_BUFFERHEADERTYPE *) * | ||
230 | pPort->sPortDef.nBufferCountActual), | ||
231 | sizeof(OMX_BUFFERHEADERTYPE *), 1); | ||
232 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorInsufficientResources); | ||
233 | pPort->nCachedBufferCnt = pPort->sPortDef.nBufferCountActual; | ||
234 | |||
235 | |||
236 | EXIT: | ||
237 | if( pBufArr != NULL ) { | ||
238 | OSAL_Free(pBufArr); | ||
239 | pBufArr = NULL; | ||
240 | } | ||
241 | if( OMX_ErrorNone != eError ) { | ||
242 | OMX_DIO_NonTunnel_Close(handle); | ||
243 | } | ||
244 | return (eError); | ||
245 | } | ||
246 | |||
247 | /* | ||
248 | * DIO NonTunnel Close | ||
249 | */ | ||
250 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Close(OMX_HANDLETYPE handle) | ||
251 | { | ||
252 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
253 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
254 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
255 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
256 | OMXBase_Port *pPort = NULL; | ||
257 | OMX_U32 i = 0, j =0, nPortIndex = 0, nStartPortNumber = 0, nCompBufs = 0; | ||
258 | OMX_PTR pTmpBuffer = NULL; | ||
259 | OMX_COMPONENTTYPE *pComp = NULL; | ||
260 | OMXBaseComp *pBaseComp = NULL; | ||
261 | |||
262 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
263 | OMX_CHECK(pContext != NULL, OMX_ErrorNone); | ||
264 | |||
265 | pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); | ||
266 | if( pPort ) { | ||
267 | pComp = (OMX_COMPONENTTYPE *)(pContext->sCreateParams.hComponent); | ||
268 | if( pComp ) { | ||
269 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
270 | } | ||
271 | if( pBaseComp ) { | ||
272 | nStartPortNumber = pBaseComp->nMinStartPortIndex; | ||
273 | nPortIndex = pPort->sPortDef.nPortIndex; | ||
274 | nCompBufs = pBaseComp->pPorts[nPortIndex - nStartPortNumber]->sProps.nNumComponentBuffers; | ||
275 | } | ||
276 | if( pPort->pBufferlist ) { | ||
277 | for( i = 0; i < pPort->nCachedBufferCnt; i++ ) { | ||
278 | if( pPort->pBufferlist[i] ) { | ||
279 | if( pPort->bIsBufferAllocator) { | ||
280 | MemHeader *h = &(((OMXBase_BufHdrPvtData *)(pPort->pBufferlist[i]->pPlatformPrivate))->sMemHdr[0]); | ||
281 | memplugin_free_noheader(h); | ||
282 | if( nCompBufs == 2 ) { | ||
283 | OMX_CHECK(OMX_FALSE, OMX_ErrorNotImplemented); | ||
284 | } | ||
285 | } | ||
286 | } | ||
287 | } | ||
288 | /* freeup the buffer list */ | ||
289 | OSAL_Free(pPort->pBufferlist); | ||
290 | pPort->pBufferlist = NULL; | ||
291 | pPort->nCachedBufferCnt = 0; | ||
292 | } | ||
293 | } | ||
294 | |||
295 | if( pContext->pPlatformPrivatePool ) { | ||
296 | OSAL_Free(pContext->pPlatformPrivatePool); | ||
297 | } | ||
298 | pContext->pPlatformPrivatePool = NULL; | ||
299 | if( pContext->pHdrPool ) { | ||
300 | OSAL_Free(pContext->pHdrPool); | ||
301 | } | ||
302 | pContext->pHdrPool = NULL; | ||
303 | /* delete a OS pipe */ | ||
304 | if( pContext->pPipeHandle != NULL ) { | ||
305 | tStatus = OSAL_DeletePipe(pContext->pPipeHandle); | ||
306 | if( tStatus != OSAL_ErrNone ) { | ||
307 | eError = OMX_ErrorUndefined; | ||
308 | } | ||
309 | pContext->pPipeHandle = NULL; | ||
310 | } | ||
311 | |||
312 | EXIT: | ||
313 | return (eError); | ||
314 | } | ||
315 | |||
316 | /* | ||
317 | * DIO NonTunnel Queue | ||
318 | */ | ||
319 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Queue (OMX_HANDLETYPE handle, | ||
320 | OMX_PTR pBuffHeader) | ||
321 | { | ||
322 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
323 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
324 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
325 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
326 | OMX_BUFFERHEADERTYPE *pOMXBufHeader; | ||
327 | OMXBase_Port *pPort; | ||
328 | |||
329 | pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) pBuffHeader; | ||
330 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
331 | |||
332 | pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); | ||
333 | tStatus = OSAL_WriteToPipe(pContext->pPipeHandle, &pOMXBufHeader, | ||
334 | sizeof(pOMXBufHeader), OSAL_SUSPEND); | ||
335 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
336 | |||
337 | EXIT: | ||
338 | return (eError); | ||
339 | } | ||
340 | |||
341 | /* | ||
342 | * DIO NonTunnel Dequeue | ||
343 | */ | ||
344 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Dequeue (OMX_HANDLETYPE handle, | ||
345 | OMX_PTR *pBuffHeader) | ||
346 | { | ||
347 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
348 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
349 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
350 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
351 | OMXBase_Port *pPort; | ||
352 | uint32_t actualSize = 0; | ||
353 | OMX_BUFFERHEADERTYPE *pOrigOMXBufHeader = NULL; | ||
354 | OMX_COMPONENTTYPE *pComp = NULL; | ||
355 | OMXBaseComp *pBaseComp = NULL; | ||
356 | OMX_U32 nPortIndex, nTimeout; | ||
357 | |||
358 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
359 | pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); | ||
360 | pComp = (OMX_COMPONENTTYPE *)pContext->sCreateParams.hComponent; | ||
361 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
362 | nPortIndex = pPort->sPortDef.nPortIndex; | ||
363 | nTimeout = pBaseComp->pPorts[nPortIndex]->sProps.nTimeoutForDequeue; | ||
364 | /* dequeue the buffer from the data pipe */ | ||
365 | tStatus = OSAL_ReadFromPipe(pContext->pPipeHandle, &pOrigOMXBufHeader, | ||
366 | sizeof(pOrigOMXBufHeader), &actualSize, nTimeout); | ||
367 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
368 | |||
369 | /*Cancel the buffer and return warning so that derived component may call | ||
370 | GetAttribute*/ | ||
371 | if( pOrigOMXBufHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG ) { | ||
372 | /*Reset codec config flag on o/p port*/ | ||
373 | if( OMX_DirOutput == pPort->sPortDef.eDir ) { | ||
374 | pOrigOMXBufHeader->nFlags &= (~OMX_BUFFERFLAG_CODECCONFIG); | ||
375 | } else { | ||
376 | tStatus = OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, &pOrigOMXBufHeader, | ||
377 | sizeof(pOrigOMXBufHeader), OSAL_NO_SUSPEND); | ||
378 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
379 | eError = (OMX_ERRORTYPE)OMX_TI_WarningAttributePending; | ||
380 | goto EXIT; | ||
381 | } | ||
382 | } | ||
383 | *pBuffHeader = (OMX_PTR)pOrigOMXBufHeader; | ||
384 | |||
385 | EXIT: | ||
386 | return (eError); | ||
387 | } | ||
388 | |||
389 | /* | ||
390 | * DIO NonTunnel Send | ||
391 | */ | ||
392 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Send (OMX_HANDLETYPE handle, | ||
393 | OMX_PTR pBuffHeader) | ||
394 | { | ||
395 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
396 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
397 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
398 | OMXBase_Port *pPort = NULL; | ||
399 | OMX_COMPONENTTYPE *pComp = NULL; | ||
400 | OMXBaseComp *pBaseComp = NULL; | ||
401 | OMX_CALLBACKTYPE *pAppCallbacks = NULL; | ||
402 | OMX_BUFFERHEADERTYPE *pOMXBufHeader; | ||
403 | |||
404 | pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) pBuffHeader; | ||
405 | |||
406 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
407 | pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); | ||
408 | pComp = (OMX_COMPONENTTYPE *)pContext->sCreateParams.hComponent; | ||
409 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
410 | pAppCallbacks = (OMX_CALLBACKTYPE *)pContext->sCreateParams.pAppCallbacks; | ||
411 | |||
412 | /* return the buffer back to the Application using EBD or FBD | ||
413 | * depending on the direction of the port (input or output) */ | ||
414 | if (((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->bufSt != OWNED_BY_CLIENT) { | ||
415 | ((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; | ||
416 | if( OMX_DirInput == pPort->sPortDef.eDir ) { | ||
417 | eError = pAppCallbacks->EmptyBufferDone(pComp, | ||
418 | pComp->pApplicationPrivate, pOMXBufHeader); | ||
419 | } else if( OMX_DirOutput == pPort->sPortDef.eDir ) { | ||
420 | eError = pAppCallbacks->FillBufferDone(pComp, | ||
421 | pComp->pApplicationPrivate, pOMXBufHeader); | ||
422 | } | ||
423 | } | ||
424 | EXIT: | ||
425 | return (eError); | ||
426 | } | ||
427 | |||
428 | /* | ||
429 | * DIO NonTunnel Cancel | ||
430 | */ | ||
431 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Cancel (OMX_HANDLETYPE handle, | ||
432 | OMX_PTR pBuffHeader) | ||
433 | { | ||
434 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
435 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
436 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
437 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
438 | OMXBase_Port *pPort = NULL; | ||
439 | OMX_BUFFERHEADERTYPE *pOMXBufHeader; | ||
440 | OMX_COMPONENTTYPE *pComp; | ||
441 | OMXBaseComp *pBaseComp; | ||
442 | OMXBaseComp_Pvt *pBaseCompPvt; | ||
443 | OMX_BOOL bCallProcess = OMX_FALSE; | ||
444 | |||
445 | pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) pBuffHeader; | ||
446 | |||
447 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
448 | pPort = (OMXBase_Port*)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); | ||
449 | |||
450 | pComp = (OMX_COMPONENTTYPE *)pContext->sCreateParams.hComponent; | ||
451 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
452 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
453 | |||
454 | tStatus = OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, &pOMXBufHeader, | ||
455 | sizeof(pOMXBufHeader), OSAL_NO_SUSPEND); | ||
456 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
457 | |||
458 | if( bCallProcess ) { | ||
459 | /*Calling process fn so that event to process the buffer can be generated*/ | ||
460 | pBaseCompPvt->fpInvokeProcessFunction(pComp, DATAEVENT); | ||
461 | } | ||
462 | |||
463 | EXIT: | ||
464 | return (eError); | ||
465 | } | ||
466 | |||
467 | |||
468 | /* | ||
469 | * DIO NonTunnel Control | ||
470 | */ | ||
471 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Control (OMX_HANDLETYPE handle, | ||
472 | OMX_DIO_CtrlCmdType nCmdType, | ||
473 | OMX_PTR pParams) | ||
474 | { | ||
475 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
476 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
477 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
478 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
479 | OMXBase_Port *pPort = NULL; | ||
480 | OMX_COMPONENTTYPE *pComp = NULL; | ||
481 | OMXBaseComp *pBaseComp = NULL; | ||
482 | OMXBaseComp_Pvt *pBaseCompPvt = NULL; | ||
483 | OMX_CALLBACKTYPE *pAppCallbacks = NULL; | ||
484 | OMX_BUFFERHEADERTYPE *pBuffHeader = NULL; | ||
485 | MemHeader *pAttrDesc = NULL; | ||
486 | uint32_t elementsInpipe = 0; | ||
487 | uint32_t actualSize = 0; | ||
488 | |||
489 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
490 | pComp = (OMX_COMPONENTTYPE *)pContext->sCreateParams.hComponent; | ||
491 | pBaseComp = (OMXBaseComp *)pComp->pComponentPrivate; | ||
492 | pBaseCompPvt = (OMXBaseComp_Pvt *)pBaseComp->pPvtData; | ||
493 | pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); | ||
494 | pAppCallbacks = (OMX_CALLBACKTYPE *)pContext->sCreateParams.pAppCallbacks; | ||
495 | |||
496 | switch( nCmdType ) { | ||
497 | /* Flush the queues or buffers on a port. Both Flush and Stop perform | ||
498 | the same operation i.e. send all the buffers back to the client */ | ||
499 | case OMX_DIO_CtrlCmd_Stop : | ||
500 | case OMX_DIO_CtrlCmd_Flush : | ||
501 | /* return all buffers to the IL client using EBD/FBD depending | ||
502 | * on the direction(input or output) of port */ | ||
503 | |||
504 | OSAL_GetPipeReadyMessageCount(pContext->pPipeHandle, &elementsInpipe); | ||
505 | |||
506 | while( elementsInpipe ) { | ||
507 | OSAL_ReadFromPipe(pContext->pPipeHandle, &pBuffHeader, | ||
508 | sizeof(pBuffHeader), &actualSize, OSAL_NO_SUSPEND); | ||
509 | elementsInpipe--; | ||
510 | if (((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt != OWNED_BY_CLIENT) { | ||
511 | ((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; | ||
512 | if( OMX_DirInput == pPort->sPortDef.eDir ) { | ||
513 | eError = pAppCallbacks->EmptyBufferDone(pComp, | ||
514 | pComp->pApplicationPrivate, pBuffHeader); | ||
515 | } else if( OMX_DirOutput == pPort->sPortDef.eDir ) { | ||
516 | pBuffHeader->nFilledLen = 0; | ||
517 | eError = pAppCallbacks->FillBufferDone(pComp, | ||
518 | pComp->pApplicationPrivate, pBuffHeader); | ||
519 | } | ||
520 | } | ||
521 | } | ||
522 | break; | ||
523 | |||
524 | case OMX_DIO_CtrlCmd_Start : | ||
525 | /*If there are buffers in the pipe in case of pause to executing | ||
526 | then start processing them*/ | ||
527 | OSAL_GetPipeReadyMessageCount(pContext->pPipeHandle, &elementsInpipe); | ||
528 | if( elementsInpipe ) { | ||
529 | pBaseCompPvt->fpInvokeProcessFunction(pComp, DATAEVENT); | ||
530 | } else { | ||
531 | OSAL_ErrorTrace(" Nothing to do "); | ||
532 | } | ||
533 | break; | ||
534 | |||
535 | case OMX_DIO_CtrlCmd_GetCtrlAttribute : | ||
536 | /*Buffer should be available when calling GetAttribute*/ | ||
537 | tStatus = OSAL_IsPipeReady(pContext->pPipeHandle); | ||
538 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
539 | |||
540 | tStatus = OSAL_ReadFromPipe(pContext->pPipeHandle, &pBuffHeader, | ||
541 | sizeof(pBuffHeader), &actualSize, OSAL_NO_SUSPEND); | ||
542 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
543 | if( !(pBuffHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) { | ||
544 | /*This buffer does not contain codec config*/ | ||
545 | eError = OMX_ErrorUndefined; | ||
546 | /*Write the buffer back to front of pipe*/ | ||
547 | OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, &pBuffHeader, | ||
548 | sizeof(pBuffHeader), OSAL_SUSPEND); | ||
549 | goto EXIT; | ||
550 | } | ||
551 | pAttrDesc = ((OMXBase_CodecConfigBuf*)pParams)->sBuffer; | ||
552 | if( pAttrDesc->size < pBuffHeader->nFilledLen ) { | ||
553 | tStatus = OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, | ||
554 | &pBuffHeader, sizeof(pBuffHeader), OSAL_SUSPEND); | ||
555 | pAttrDesc->size = pBuffHeader->nFilledLen; | ||
556 | |||
557 | eError = (OMX_ERRORTYPE)OMX_TI_WarningInsufficientAttributeSize; | ||
558 | goto EXIT; | ||
559 | } | ||
560 | pAttrDesc->size = pBuffHeader->nFilledLen; | ||
561 | OSAL_Memcpy(H2P(pAttrDesc), pBuffHeader->pBuffer + pBuffHeader->nOffset, | ||
562 | pAttrDesc->size); | ||
563 | |||
564 | /*Send the buffer back*/ | ||
565 | pBuffHeader->nFlags &= (~OMX_BUFFERFLAG_CODECCONFIG); | ||
566 | if (((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt != OWNED_BY_CLIENT) { | ||
567 | ((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; | ||
568 | if( OMX_DirInput == pPort->sPortDef.eDir ) { | ||
569 | eError = pAppCallbacks->EmptyBufferDone(pComp, | ||
570 | pComp->pApplicationPrivate, pBuffHeader); | ||
571 | } else if( OMX_DirOutput == pPort->sPortDef.eDir ) { | ||
572 | /*So that the other port does not try to interpret any garbage | ||
573 | data that may be present*/ | ||
574 | pBuffHeader->nFilledLen = 0; | ||
575 | eError = pAppCallbacks->FillBufferDone(pComp, | ||
576 | pComp->pApplicationPrivate, pBuffHeader); | ||
577 | } | ||
578 | } | ||
579 | break; | ||
580 | |||
581 | case OMX_DIO_CtrlCmd_SetCtrlAttribute : | ||
582 | /*Buffer should be available when calling SetAttribute*/ | ||
583 | tStatus = OSAL_IsPipeReady(pContext->pPipeHandle); | ||
584 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
585 | |||
586 | tStatus = OSAL_ReadFromPipe(pContext->pPipeHandle, &pBuffHeader, | ||
587 | sizeof(pBuffHeader), &actualSize, OSAL_NO_SUSPEND); | ||
588 | OMX_CHECK(OSAL_ErrNone == tStatus, OMX_ErrorUndefined); | ||
589 | |||
590 | pBuffHeader->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; | ||
591 | pAttrDesc = ((OMXBase_CodecConfigBuf *)pParams)->sBuffer; | ||
592 | if( pBuffHeader->nAllocLen < pAttrDesc->size ) { | ||
593 | OSAL_ErrorTrace("Cannot send attribute data, size is too large"); | ||
594 | tStatus = OSAL_WriteToFrontOfPipe(pContext->pPipeHandle, | ||
595 | &pBuffHeader, sizeof(pBuffHeader), OSAL_SUSPEND); | ||
596 | eError = OMX_ErrorInsufficientResources; | ||
597 | goto EXIT; | ||
598 | } | ||
599 | pBuffHeader->nFilledLen = pAttrDesc->size; | ||
600 | OSAL_Memcpy(pBuffHeader->pBuffer, pAttrDesc->ptr, pAttrDesc->size); | ||
601 | if (((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt != OWNED_BY_CLIENT) { | ||
602 | ((OMXBase_BufHdrPvtData *)(pBuffHeader->pPlatformPrivate))->bufSt = OWNED_BY_CLIENT; | ||
603 | /*Send the buffer*/ | ||
604 | if( OMX_DirInput == pPort->sPortDef.eDir ) { | ||
605 | eError = pAppCallbacks->EmptyBufferDone(pComp, | ||
606 | pComp->pApplicationPrivate, pBuffHeader); | ||
607 | } else if( OMX_DirOutput == pPort->sPortDef.eDir ) { | ||
608 | eError = pAppCallbacks->FillBufferDone(pComp, | ||
609 | pComp->pApplicationPrivate, pBuffHeader); | ||
610 | } | ||
611 | } | ||
612 | break; | ||
613 | |||
614 | default : | ||
615 | OSAL_ErrorTrace(" Invalid Command received \n"); | ||
616 | eError = OMX_ErrorUnsupportedIndex; | ||
617 | break; | ||
618 | } | ||
619 | |||
620 | EXIT: | ||
621 | return (eError); | ||
622 | } | ||
623 | |||
624 | |||
625 | /* | ||
626 | * DIO Non Tunnel GEtCount | ||
627 | */ | ||
628 | static OMX_ERRORTYPE OMX_DIO_NonTunnel_Getcount (OMX_HANDLETYPE handle, | ||
629 | OMX_U32 *pCount) | ||
630 | { | ||
631 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
632 | OMX_DIO_Object *hDIO = (OMX_DIO_Object *)handle; | ||
633 | DIO_NonTunnel_Attrs *pContext = NULL; | ||
634 | OMXBase_Port *pPort = NULL; | ||
635 | |||
636 | pContext = (DIO_NonTunnel_Attrs *)hDIO->pContext; | ||
637 | pPort = (OMXBase_Port *)_DIO_GetPort(handle, pContext->sCreateParams.nPortIndex); | ||
638 | if( pPort->bEosRecd && pPort->sPortDef.eDir == OMX_DirInput ) { | ||
639 | eError = (OMX_ERRORTYPE)OMX_TI_WarningEosReceived; | ||
640 | } | ||
641 | |||
642 | OSAL_GetPipeReadyMessageCount(pContext->pPipeHandle, (uint32_t*)pCount); | ||
643 | |||
644 | return (eError); | ||
645 | } | ||
646 | |||
647 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <string.h> | ||
18 | #include "omx_base_internal.h" | ||
19 | #include "omx_base_dio_plugin.h" | ||
20 | |||
21 | |||
22 | extern OMX_ERRORTYPE OMX_DIO_NonTunnel_Init(OMX_HANDLETYPE handle, | ||
23 | OMX_PTR pCreateParams); | ||
24 | |||
25 | OMX_DIO_Register OMX_DIO_Registered[] = | ||
26 | { | ||
27 | { "OMX.DIO.NONTUNNEL", &OMX_DIO_NonTunnel_Init }, | ||
28 | { NULL, NULL } | ||
29 | |||
30 | }; | ||
31 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <dirent.h> | ||
18 | |||
19 | #define MAX_ROLES 20 | ||
20 | #define MAX_TABLE_SIZE 50 | ||
21 | |||
22 | typedef struct _ComponentTable { | ||
23 | OMX_STRING name; | ||
24 | OMX_U16 nRoles; | ||
25 | OMX_STRING pRoleArray[MAX_ROLES]; | ||
26 | }ComponentTable; | ||
27 | |||
28 | OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( | ||
29 | OMX_IN OMX_STRING compName, | ||
30 | OMX_INOUT OMX_U32 *pNumRoles, | ||
31 | OMX_OUT OMX_U8 **roles); | ||
32 | |||
33 | OMX_ERRORTYPE OMX_PrintComponentTable(); | ||
34 | OMX_ERRORTYPE OMX_BuildComponentTable(); | ||
35 | OMX_ERRORTYPE ComponentTable_EventHandler( | ||
36 | OMX_IN OMX_HANDLETYPE hComponent, | ||
37 | OMX_IN OMX_PTR pAppData, | ||
38 | OMX_IN OMX_EVENTTYPE eEvent, | ||
39 | OMX_IN OMX_U32 nData1, | ||
40 | OMX_IN OMX_U32 nData2, | ||
41 | OMX_IN OMX_PTR pEventData); | ||
42 | |||
43 | OMX_ERRORTYPE ComponentTable_EmptyBufferDone( | ||
44 | OMX_OUT OMX_HANDLETYPE hComponent, | ||
45 | OMX_OUT OMX_PTR pAppData, | ||
46 | OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); | ||
47 | |||
48 | OMX_ERRORTYPE ComponentTable_FillBufferDone( | ||
49 | OMX_OUT OMX_HANDLETYPE hComponent, | ||
50 | OMX_OUT OMX_PTR pAppData, | ||
51 | 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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | /** OMX_Core_Wrapper.h | ||
18 | */ | ||
19 | |||
20 | #ifndef OMX_Core_Wrapper_h | ||
21 | #define OMX_Core_Wrapper_h | ||
22 | |||
23 | #ifdef __cplusplus | ||
24 | extern "C" { | ||
25 | #endif | ||
26 | |||
27 | |||
28 | /* Each OMX header shall include all required header files to allow the | ||
29 | * header to compile without errors. The includes below are required | ||
30 | * for this header file to compile successfully | ||
31 | */ | ||
32 | |||
33 | #include <OMX_Core.h> | ||
34 | |||
35 | OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_Init(void); | ||
36 | OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_Deinit(void); | ||
37 | OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_ComponentNameEnum( | ||
38 | OMX_OUT OMX_STRING cComponentName, | ||
39 | OMX_IN OMX_U32 nNameLength, | ||
40 | OMX_IN OMX_U32 nIndex); | ||
41 | OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_GetHandle( | ||
42 | OMX_OUT OMX_HANDLETYPE* pHandle, | ||
43 | OMX_IN OMX_STRING cComponentName, | ||
44 | OMX_IN OMX_PTR pAppData, | ||
45 | OMX_IN OMX_CALLBACKTYPE* pCallBacks); | ||
46 | OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_FreeHandle( | ||
47 | OMX_IN OMX_HANDLETYPE hComponent); | ||
48 | OMX_API OMX_ERRORTYPE TIOMX_GetComponentsOfRole ( | ||
49 | OMX_IN OMX_STRING role, | ||
50 | OMX_INOUT OMX_U32 *pNumComps, | ||
51 | OMX_INOUT OMX_U8 **compNames); | ||
52 | OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_SetupTunnel( | ||
53 | OMX_IN OMX_HANDLETYPE hOutput, | ||
54 | OMX_IN OMX_U32 nPortOutput, | ||
55 | OMX_IN OMX_HANDLETYPE hInput, | ||
56 | OMX_IN OMX_U32 nPortInput); | ||
57 | OMX_API OMX_ERRORTYPE OMX_APIENTRY TIOMX_GetContentPipe( | ||
58 | OMX_OUT OMX_HANDLETYPE *hPipe, | ||
59 | OMX_IN OMX_STRING szURI); | ||
60 | |||
61 | #ifdef __cplusplus | ||
62 | } | ||
63 | #endif | ||
64 | |||
65 | #endif | ||
66 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef OMX_TI_Custom_H | ||
18 | #define OMX_TI_Custom_H | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <OMX_IVCommon.h> | ||
25 | |||
26 | /** | ||
27 | * A pointer to this struct is passed to the OMX_SetParameter when the extension | ||
28 | * index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension | ||
29 | * is given. | ||
30 | * The corresponding extension Index is OMX_TI_IndexUseNativeBuffers. | ||
31 | * This will be used to inform OMX about the presence of gralloc pointers instead | ||
32 | * of virtual pointers | ||
33 | */ | ||
34 | typedef struct OMX_TI_PARAMUSENATIVEBUFFER { | ||
35 | OMX_U32 nSize; | ||
36 | OMX_VERSIONTYPE nVersion; | ||
37 | OMX_U32 nPortIndex; | ||
38 | OMX_BOOL bEnable; | ||
39 | } OMX_TI_PARAMUSENATIVEBUFFER; | ||
40 | |||
41 | /** | ||
42 | * A pointer to this struct is passed to OMX_GetParameter when the extension | ||
43 | * index for the 'OMX.google.android.index.getAndroidNativeBufferUsage' | ||
44 | * extension is given. | ||
45 | * The corresponding extension Index is OMX_TI_IndexAndroidNativeBufferUsage. | ||
46 | * The usage bits returned from this query will be used to allocate the Gralloc | ||
47 | * buffers that get passed to the useAndroidNativeBuffer command. | ||
48 | */ | ||
49 | typedef struct OMX_TI_PARAMNATIVEBUFFERUSAGE { | ||
50 | OMX_U32 nSize; | ||
51 | OMX_VERSIONTYPE nVersion; | ||
52 | OMX_U32 nPortIndex; | ||
53 | OMX_U32 nUsage; | ||
54 | } OMX_TI_PARAMNATIVEBUFFERUSAGE; | ||
55 | |||
56 | typedef enum OMX_TI_INDEXTYPE { | ||
57 | OMX_TI_IndexUseNativeBuffers = ((OMX_INDEXTYPE)OMX_IndexVendorStartUnused + 1), | ||
58 | OMX_TI_IndexAndroidNativeBufferUsage, | ||
59 | OMX_TI_IndexParamTimeStampInDecodeOrder, | ||
60 | OMX_TI_IndexEncoderReceiveMetadataBuffers, | ||
61 | OMX_TI_IndexDescribeColorFormat, | ||
62 | OMX_TI_IndexEnableDecoderZeroDisplayDelayMode, | ||
63 | OMX_TI_IndexPrepareForAdaptivePlayback | ||
64 | } OMX_TI_INDEXTYPE; | ||
65 | |||
66 | typedef enum OMX_TI_ERRORTYPE | ||
67 | { | ||
68 | /*Control attribute is pending - Dio_Dequeue will not work until attribute | ||
69 | is retreived*/ | ||
70 | OMX_TI_WarningAttributePending = (OMX_S32)((OMX_ERRORTYPE)OMX_ErrorVendorStartUnused + 1), | ||
71 | /*Attribute buffer size is insufficient - reallocate the attribute buffer*/ | ||
72 | OMX_TI_WarningInsufficientAttributeSize, | ||
73 | /*EOS buffer has been received*/ | ||
74 | OMX_TI_WarningEosReceived, | ||
75 | /*Port enable is called on an already enabled port*/ | ||
76 | OMX_TI_ErrorPortIsAlreadyEnabled, | ||
77 | /*Port disable is called on an already disabled port*/ | ||
78 | OMX_TI_ErrorPortIsAlreadyDisabled | ||
79 | } OMX_TI_ERRORTYPE; | ||
80 | |||
81 | |||
82 | /** | ||
83 | * OMX_TI_VIDEO_CONFIG_AVC_LTRP_INTERVAL : Structure to enable timestamps in decode order | ||
84 | * at i/p of decoders. | ||
85 | */ | ||
86 | typedef struct OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER { | ||
87 | OMX_U32 nSize; | ||
88 | OMX_VERSIONTYPE nVersion; | ||
89 | OMX_BOOL bEnabled; | ||
90 | } OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER; | ||
91 | |||
92 | |||
93 | /** | ||
94 | * OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE : Structure to enable Decoder zero display delay mode | ||
95 | * | ||
96 | */ | ||
97 | typedef struct OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE { | ||
98 | OMX_U32 nSize; | ||
99 | OMX_VERSIONTYPE nVersion; | ||
100 | OMX_U32 nPortIndex; | ||
101 | OMX_BOOL bEnabled; | ||
102 | } OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE; | ||
103 | |||
104 | #ifdef __cplusplus | ||
105 | } | ||
106 | #endif | ||
107 | |||
108 | #endif | ||
109 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_CORE" | ||
18 | |||
19 | #include <dlfcn.h> /* For dynamic loading */ | ||
20 | #include <stdio.h> | ||
21 | #include <string.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <pthread.h> | ||
24 | |||
25 | #include <OMX_Component.h> | ||
26 | #include <OMX_Core.h> | ||
27 | #include <OMX_ComponentRegistry.h> | ||
28 | |||
29 | #include <memplugin.h> | ||
30 | |||
31 | #include "osal_error.h" | ||
32 | #include "osal_trace.h" | ||
33 | #include "osal_mutex.h" | ||
34 | |||
35 | /** size for the array of allocated components. Sets the maximum | ||
36 | * number of components that can be allocated at once | ||
37 | */ | ||
38 | #define MAXCOMP (50) | ||
39 | #define MAXNAMESIZE (128) | ||
40 | #define EMPTY_STRING "\0" | ||
41 | |||
42 | /** Determine the number of elements in an array */ | ||
43 | #define COUNTOF(x) (sizeof(x) / sizeof(x[0])) | ||
44 | |||
45 | /** Array to hold the DLL pointers for each allocated component */ | ||
46 | static void *pModules[MAXCOMP] = { 0 }; | ||
47 | |||
48 | /** Array to hold the component handles for each allocated component */ | ||
49 | static void *pComponents[COUNTOF(pModules)] = { 0 }; | ||
50 | |||
51 | /* count for call OMX_Init() */ | ||
52 | int count = 0; | ||
53 | pthread_mutex_t mutex; | ||
54 | void *pCoreInitMutex = NULL; | ||
55 | |||
56 | int tableCount = 0; | ||
57 | ComponentTable componentTable[MAX_TABLE_SIZE]; | ||
58 | char *sRoleArray[60][20]; | ||
59 | char compName[60][200]; | ||
60 | #define MAX_CONCURRENT_INSTANCES 5 //aligned with IPUMM definitions | ||
61 | int concurrent_instances = 0; | ||
62 | |||
63 | char *tComponentName[MAXCOMP][MAX_ROLES] = | ||
64 | { | ||
65 | /*video decoder */ | ||
66 | { "OMX.TI.DUCATI1.VIDEO.DECODER", | ||
67 | "video_decoder.mpeg4", | ||
68 | "video_decoder.avc", | ||
69 | "video_decoder.h263", | ||
70 | "video_decoder.mpeg2", | ||
71 | NULL }, | ||
72 | { "OMX.TI.DUCATI1.VIDEO.H264E", | ||
73 | "video_encoder.avc", NULL }, | ||
74 | /* terminate the table */ | ||
75 | { NULL, NULL }, | ||
76 | }; | ||
77 | |||
78 | extern OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent); | ||
79 | |||
80 | #define CORE_assert CORE_paramCheck | ||
81 | #define CORE_require CORE_paramCheck | ||
82 | #define CORE_ensure CORE_paramCheck | ||
83 | |||
84 | #define CORE_paramCheck(C, V, S) do {\ | ||
85 | if( !(C)) { eError = V;\ | ||
86 | ALOGE("failed check: " # C);\ | ||
87 | ALOGE(" - returning error: " # V);\ | ||
88 | if( S ) { ALOGE(" - %s", S); }\ | ||
89 | goto EXIT; }\ | ||
90 | } while( 0 ) | ||
91 | |||
92 | /* | ||
93 | * OMX_Init() | ||
94 | * | ||
95 | * Description:This method will initialize the OMX Core. It is the | ||
96 | * responsibility of the application to call OMX_Init to ensure the proper | ||
97 | * set up of core resources. | ||
98 | * | ||
99 | * Returns: OMX_NOERROR Successful | ||
100 | * | ||
101 | * Note | ||
102 | */ | ||
103 | OMX_ERRORTYPE OMX_Init() | ||
104 | { | ||
105 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
106 | OSAL_ERROR eOsalError = OSAL_ErrNone; | ||
107 | |||
108 | eOsalError = OSAL_ObtainMutex(pCoreInitMutex, OSAL_SUSPEND); | ||
109 | CORE_assert(eOsalError == OSAL_ErrNone, OMX_ErrorInsufficientResources, "Mutex lock failed"); | ||
110 | count++; | ||
111 | if( count == 1 ) { | ||
112 | pthread_mutex_init(&mutex, NULL); | ||
113 | eError = OMX_BuildComponentTable(); | ||
114 | memplugin_open(); | ||
115 | } | ||
116 | |||
117 | eOsalError = OSAL_ReleaseMutex(pCoreInitMutex); | ||
118 | CORE_assert(eOsalError == OSAL_ErrNone, OMX_ErrorInsufficientResources, "Mutex release failed"); | ||
119 | EXIT: | ||
120 | return (eError); | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | * OMX_GetHandle | ||
125 | * | ||
126 | * Description: This method will create the handle of the COMPONENTTYPE | ||
127 | * If the component is currently loaded, this method will reutrn the | ||
128 | * hadle of existingcomponent or create a new instance of the component. | ||
129 | * It will call the OMX_ComponentInit function and then the setcallback | ||
130 | * method to initialize the callback functions | ||
131 | * Parameters: | ||
132 | * @param[out] pHandle Handle of the loaded components | ||
133 | * @param[in] cComponentName Name of the component to load | ||
134 | * @param[in] pAppData Used to identify the callbacks of component | ||
135 | * @param[in] pCallBacks Application callbacks | ||
136 | * | ||
137 | * @retval OMX_ErrorUndefined | ||
138 | * @retval OMX_ErrorInvalidComponentName | ||
139 | * @retval OMX_ErrorInvalidComponent | ||
140 | * @retval OMX_ErrorInsufficientResources | ||
141 | * @retval OMX_NOERROR Successful | ||
142 | * | ||
143 | * Note | ||
144 | */ | ||
145 | |||
146 | OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE *pHandle, | ||
147 | OMX_STRING cComponentName, OMX_PTR pAppData, | ||
148 | OMX_CALLBACKTYPE *pCallBacks) | ||
149 | { | ||
150 | static const char prefix[] = "lib"; | ||
151 | static const char postfix[] = ".so"; | ||
152 | |||
153 | OMX_ERRORTYPE (*pComponentInit)(OMX_HANDLETYPE *); | ||
154 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
155 | OMX_COMPONENTTYPE *componentType; | ||
156 | int i; | ||
157 | char buf[sizeof(prefix) + MAXNAMESIZE + sizeof(postfix)]; | ||
158 | const char *pErr = dlerror(); | ||
159 | char *dlError = NULL; | ||
160 | if( pthread_mutex_lock(&mutex) != 0 ) { | ||
161 | OSAL_ErrorTrace("Core: Error in Mutex lock"); | ||
162 | } | ||
163 | |||
164 | CORE_require(NULL != cComponentName, OMX_ErrorBadParameter, NULL); | ||
165 | CORE_require(NULL != pHandle, OMX_ErrorBadParameter, NULL); | ||
166 | CORE_require(NULL != pCallBacks, OMX_ErrorBadParameter, NULL); | ||
167 | CORE_require(count > 0, OMX_ErrorUndefined, "OMX_GetHandle called without calling OMX_Init first"); | ||
168 | CORE_require(concurrent_instances < MAX_CONCURRENT_INSTANCES, OMX_ErrorInsufficientResources, "Max Concurrent Instances reached"); | ||
169 | |||
170 | concurrent_instances++; | ||
171 | |||
172 | /* Verify that the name is not too long and could cause a crash. Notice | ||
173 | * that the comparison is a greater than or equals. This is to make | ||
174 | * sure that there is room for the terminating NULL at the end of the | ||
175 | * name. */ | ||
176 | CORE_require(strlen(cComponentName) < MAXNAMESIZE, | ||
177 | OMX_ErrorInvalidComponentName, NULL); | ||
178 | |||
179 | /* Locate the first empty slot for a component. If no slots | ||
180 | * are available, error out */ | ||
181 | for( i = 0; i < (int)COUNTOF(pModules); i++ ) { | ||
182 | if( pModules[i] == NULL ) { | ||
183 | break; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | CORE_assert(i != COUNTOF(pModules), OMX_ErrorInsufficientResources, NULL); | ||
188 | |||
189 | /* load the component and check for an error. If filename is not an | ||
190 | * absolute path (i.e., it does not begin with a "/" ), then the | ||
191 | * file is searched for in the following locations: | ||
192 | * | ||
193 | * The LD_LIBRARY_PATH environment variable locations | ||
194 | * The library cache, /etc/ld.so.cache. | ||
195 | * /lib | ||
196 | * /usr/lib | ||
197 | * | ||
198 | * If there is an error, we can't go on, so set the error code and exit */ | ||
199 | strcpy(buf, prefix); /* the lengths are defined herein or have been */ | ||
200 | strcat(buf, cComponentName); /* checked already, so strcpy and strcat are */ | ||
201 | strcat(buf, postfix); /* are safe to use in this context. */ | ||
202 | |||
203 | pModules[i] = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL); | ||
204 | if( pModules[i] == NULL ) { | ||
205 | dlError = (char *)dlerror(); | ||
206 | OSAL_ErrorTrace("Failed because %s", dlError); | ||
207 | eError = OMX_ErrorComponentNotFound; | ||
208 | goto EXIT; | ||
209 | } | ||
210 | |||
211 | /* Get a function pointer to the "OMX_ComponentInit" function. If | ||
212 | * there is an error, we can't go on, so set the error code and exit */ | ||
213 | pComponentInit = dlsym(pModules[i], "OMX_ComponentInit"); | ||
214 | pErr = dlerror(); | ||
215 | CORE_assert(((pErr == NULL) && (pComponentInit != NULL)), OMX_ErrorInvalidComponent, NULL); | ||
216 | |||
217 | /* We now can access the dll. So, we need to call the "OMX_ComponentInit" | ||
218 | * method to load up the "handle" (which is just a list of functions to | ||
219 | * call) and we should be all set. | ||
220 | */ | ||
221 | *pHandle = malloc(sizeof(OMX_COMPONENTTYPE)); | ||
222 | CORE_assert((*pHandle != NULL), OMX_ErrorInsufficientResources, "Malloc of pHandle* failed"); | ||
223 | |||
224 | pComponents[i] = *pHandle; | ||
225 | componentType = (OMX_COMPONENTTYPE *) *pHandle; | ||
226 | componentType->nSize = sizeof(OMX_COMPONENTTYPE); | ||
227 | |||
228 | componentType->nVersion.s.nVersionMajor = 1; | ||
229 | componentType->nVersion.s.nVersionMinor = 1; | ||
230 | componentType->nVersion.s.nRevision = 0; | ||
231 | componentType->nVersion.s.nStep = 0; | ||
232 | |||
233 | eError = (*pComponentInit)(*pHandle); | ||
234 | if( OMX_ErrorNone == eError ) { | ||
235 | eError = (componentType->SetCallbacks)(*pHandle, pCallBacks, pAppData); | ||
236 | CORE_assert(eError == OMX_ErrorNone, eError, "Core: Error returned from component SetCallBack"); | ||
237 | } else { | ||
238 | /* when the component fails to initialize, release the | ||
239 | component handle structure */ | ||
240 | free(*pHandle); | ||
241 | /* mark the component handle as NULL to prevent the caller from | ||
242 | actually trying to access the component with it, should they | ||
243 | ignore the return code */ | ||
244 | *pHandle = NULL; | ||
245 | pComponents[i] = NULL; | ||
246 | dlclose(pModules[i]); | ||
247 | pModules[i] = NULL; | ||
248 | goto EXIT; | ||
249 | } | ||
250 | eError = OMX_ErrorNone; | ||
251 | EXIT: | ||
252 | if( pthread_mutex_unlock(&mutex) != 0 ) { | ||
253 | OSAL_ErrorTrace("Core: Error in Mutex unlock"); | ||
254 | } | ||
255 | return (eError); | ||
256 | } | ||
257 | |||
258 | /* | ||
259 | * OMX_FreeHandle() | ||
260 | * | ||
261 | * Description:This method will unload the OMX component pointed by | ||
262 | * OMX_HANDLETYPE. It is the responsibility of the calling method to ensure that | ||
263 | * the Deinit method of the component has been called prior to unloading component | ||
264 | * | ||
265 | * Parameters: | ||
266 | * @param[in] hComponent the component to unload | ||
267 | * | ||
268 | * Returns: OMX_NOERROR Successful | ||
269 | * | ||
270 | * Note | ||
271 | * | ||
272 | */ | ||
273 | OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent) | ||
274 | { | ||
275 | OMX_ERRORTYPE eError = OMX_ErrorUndefined; | ||
276 | OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *) hComponent; | ||
277 | int i; | ||
278 | |||
279 | if( pthread_mutex_lock(&mutex) != 0 ) { | ||
280 | OSAL_ErrorTrace("Core: Error in Mutex lock"); | ||
281 | } | ||
282 | |||
283 | CORE_require(pHandle != NULL, OMX_ErrorBadParameter, NULL); | ||
284 | CORE_require(count > 0, OMX_ErrorUndefined, "OMX_FreeHandle called without calling OMX_Init first"); | ||
285 | |||
286 | /* Locate the component handle in the array of handles */ | ||
287 | for( i = 0; i < (int)COUNTOF(pModules); i++ ) { | ||
288 | if( pComponents[i] == hComponent ) { | ||
289 | break; | ||
290 | } | ||
291 | } | ||
292 | |||
293 | CORE_assert(i != COUNTOF(pModules), OMX_ErrorBadParameter, NULL); | ||
294 | |||
295 | eError = pHandle->ComponentDeInit(hComponent); | ||
296 | if( eError != OMX_ErrorNone ) { | ||
297 | OSAL_ErrorTrace("Error From ComponentDeInit.."); | ||
298 | } | ||
299 | |||
300 | /* release the component and the component handle */ | ||
301 | dlclose(pModules[i]); | ||
302 | pModules[i] = NULL; | ||
303 | free(pComponents[i]); | ||
304 | |||
305 | pComponents[i] = NULL; | ||
306 | |||
307 | concurrent_instances--; | ||
308 | eError = OMX_ErrorNone; | ||
309 | |||
310 | EXIT: | ||
311 | /* The unload is now complete, so set the error code to pass and exit */ | ||
312 | if( pthread_mutex_unlock(&mutex) != 0 ) { | ||
313 | OSAL_ErrorTrace("Core: Error in Mutex unlock"); | ||
314 | } | ||
315 | |||
316 | return (eError); | ||
317 | } | ||
318 | |||
319 | /* | ||
320 | * OMX_DeInit() | ||
321 | * | ||
322 | * Description:This method will release the resources of the OMX Core. It is the | ||
323 | * responsibility of the application to call OMX_DeInit to ensure the clean up of these | ||
324 | * resources. | ||
325 | * | ||
326 | * Returns: OMX_NOERROR Successful | ||
327 | * | ||
328 | * Note | ||
329 | * | ||
330 | */ | ||
331 | OMX_ERRORTYPE OMX_Deinit() | ||
332 | { | ||
333 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
334 | OSAL_ERROR eOsalError = OSAL_ErrNone; | ||
335 | |||
336 | eOsalError = OSAL_ObtainMutex(pCoreInitMutex, OSAL_SUSPEND); | ||
337 | if( eOsalError != OSAL_ErrNone ) { | ||
338 | OSAL_ErrorTrace("Mutex lock failed"); | ||
339 | } | ||
340 | /*Returning error none because of OMX spec limitation on error codes that | ||
341 | can be returned by OMX_Deinit */ | ||
342 | CORE_assert(count > 0, OMX_ErrorNone, "OMX_Deinit being called without a corresponding OMX_Init"); | ||
343 | count--; | ||
344 | |||
345 | if( pthread_mutex_lock(&mutex) != 0 ) { | ||
346 | OSAL_ErrorTrace("Core: Error in Mutex lock"); | ||
347 | } | ||
348 | |||
349 | if( count == 0 ) { | ||
350 | memplugin_close(); | ||
351 | if( pthread_mutex_unlock(&mutex) != 0 ) { | ||
352 | OSAL_ErrorTrace("Core: Error in Mutex unlock"); | ||
353 | } | ||
354 | if( pthread_mutex_destroy(&mutex) != 0 ) { | ||
355 | OSAL_ErrorTrace("%d :: Core: Error in Mutex destroy\n" ,__LINE__); | ||
356 | } | ||
357 | } else { | ||
358 | if( pthread_mutex_unlock(&mutex) != 0 ) { | ||
359 | OSAL_ErrorTrace("Core: Error in Mutex unlock"); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | EXIT: | ||
364 | eOsalError = OSAL_ReleaseMutex(pCoreInitMutex); | ||
365 | if( eOsalError != OSAL_ErrNone) { | ||
366 | OSAL_ErrorTrace("Mutex release failed"); | ||
367 | } | ||
368 | return (eError); | ||
369 | } | ||
370 | |||
371 | /* | ||
372 | * OMX_SetupTunnel() | ||
373 | * | ||
374 | * Description: Setup the specified tunnel the two components | ||
375 | * | ||
376 | * Parameters: | ||
377 | * @param[in] hOutput Handle of the component to be accessed | ||
378 | * @param[in] nPortOutput Source port used in the tunnel | ||
379 | * @param[in] hInput Component to setup the tunnel with. | ||
380 | * @param[in] nPortInput Destination port used in the tunnel | ||
381 | * | ||
382 | * Returns: OMX_NOERROR Successful | ||
383 | * | ||
384 | * Note | ||
385 | * | ||
386 | */ | ||
387 | /* OMX_SetupTunnel */ | ||
388 | OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel(OMX_IN OMX_HANDLETYPE | ||
389 | hOutput, OMX_IN OMX_U32 nPortOutput, OMX_IN OMX_HANDLETYPE hInput, | ||
390 | OMX_IN OMX_U32 nPortInput) | ||
391 | { | ||
392 | OMX_ERRORTYPE eError = OMX_ErrorNotImplemented; | ||
393 | OMX_COMPONENTTYPE *pCompIn, *pCompOut; | ||
394 | OMX_TUNNELSETUPTYPE oTunnelSetup; | ||
395 | |||
396 | if( hOutput == NULL && hInput == NULL ) { | ||
397 | return (OMX_ErrorBadParameter); | ||
398 | } | ||
399 | |||
400 | oTunnelSetup.nTunnelFlags = 0; | ||
401 | oTunnelSetup.eSupplier = OMX_BufferSupplyUnspecified; | ||
402 | |||
403 | pCompOut = (OMX_COMPONENTTYPE *) hOutput; | ||
404 | if( hOutput ) { | ||
405 | eError = pCompOut->ComponentTunnelRequest(hOutput, nPortOutput, | ||
406 | hInput, nPortInput, &oTunnelSetup); | ||
407 | } | ||
408 | |||
409 | if( eError == OMX_ErrorNone && hInput ) { | ||
410 | pCompIn = (OMX_COMPONENTTYPE *) hInput; | ||
411 | eError = pCompIn->ComponentTunnelRequest(hInput, nPortInput, | ||
412 | hOutput, nPortOutput, &oTunnelSetup); | ||
413 | if( eError != OMX_ErrorNone && hOutput ) { | ||
414 | /* cancel tunnel request on output port since input port failed */ | ||
415 | pCompOut->ComponentTunnelRequest(hOutput, nPortOutput, NULL, 0, NULL); | ||
416 | } | ||
417 | } | ||
418 | return (eError); | ||
419 | } | ||
420 | |||
421 | /* | ||
422 | * OMX_ComponentNameEnum() | ||
423 | * | ||
424 | * Description: This method will provide the name of the component at the given nIndex | ||
425 | * | ||
426 | * Parameters: | ||
427 | * @param[out] cComponentName The name of the component at nIndex | ||
428 | * @param[in] nNameLength The length of the component name | ||
429 | * @param[in] nIndex The index number of the component | ||
430 | * | ||
431 | * Returns: OMX_NOERROR Successful | ||
432 | * | ||
433 | * Note | ||
434 | * | ||
435 | */ | ||
436 | OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(OMX_OUT OMX_STRING | ||
437 | cComponentName, OMX_IN OMX_U32 nNameLength, OMX_IN OMX_U32 nIndex) | ||
438 | { | ||
439 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
440 | CORE_require(cComponentName != NULL, OMX_ErrorBadParameter, NULL); | ||
441 | CORE_require(count > 0, OMX_ErrorUndefined, "OMX_GetHandle called without calling OMX_Init first"); | ||
442 | |||
443 | if( nIndex >= (OMX_U32)tableCount ) { | ||
444 | eError = OMX_ErrorNoMore; | ||
445 | } else if (strlen(componentTable[nIndex].name) > nNameLength) { | ||
446 | eError = OMX_ErrorBadParameter; | ||
447 | } else { | ||
448 | strcpy(cComponentName, componentTable[nIndex].name); | ||
449 | } | ||
450 | EXIT: | ||
451 | return (eError); | ||
452 | } | ||
453 | |||
454 | /* | ||
455 | * OMX_GetRolesOfComponent() | ||
456 | * | ||
457 | * Description: This method will query the component for its supported roles | ||
458 | * | ||
459 | * Parameters: | ||
460 | * @param[in] cComponentName The name of the component to query | ||
461 | * @param[in] pNumRoles The number of roles supported by the component | ||
462 | * @param[in] roles The roles of the component | ||
463 | * | ||
464 | * Returns: OMX_NOERROR Successful | ||
465 | * OMX_ErrorBadParameter Faliure due to a bad input parameter | ||
466 | * | ||
467 | * Note | ||
468 | * | ||
469 | */ | ||
470 | OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent(OMX_IN OMX_STRING | ||
471 | cComponentName, OMX_INOUT OMX_U32 *pNumRoles, OMX_OUT OMX_U8 * *roles) | ||
472 | { | ||
473 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
474 | OMX_U32 i = 0; | ||
475 | OMX_U32 j = 0; | ||
476 | OMX_BOOL bFound = OMX_FALSE; | ||
477 | |||
478 | CORE_require(cComponentName != NULL, OMX_ErrorBadParameter, NULL); | ||
479 | CORE_require(pNumRoles != NULL, OMX_ErrorBadParameter, NULL); | ||
480 | CORE_require(strlen(cComponentName) < MAXNAMESIZE, | ||
481 | OMX_ErrorInvalidComponentName, NULL); | ||
482 | CORE_require(count > 0, OMX_ErrorUndefined, "OMX_GetHandle called without calling OMX_Init first"); | ||
483 | |||
484 | while( !bFound && i < (OMX_U32)tableCount ) { | ||
485 | if( strcmp(cComponentName, componentTable[i].name) == 0 ) { | ||
486 | bFound = OMX_TRUE; | ||
487 | } else { | ||
488 | i++; | ||
489 | } | ||
490 | } | ||
491 | |||
492 | if( roles == NULL ) { | ||
493 | *pNumRoles = componentTable[i].nRoles; | ||
494 | goto EXIT; | ||
495 | } else { | ||
496 | if( bFound && (*pNumRoles == componentTable[i].nRoles)) { | ||
497 | for( j = 0; j < componentTable[i].nRoles; j++ ) { | ||
498 | strcpy((OMX_STRING) roles[j], | ||
499 | componentTable[i].pRoleArray[j]); | ||
500 | } | ||
501 | } | ||
502 | } | ||
503 | EXIT: | ||
504 | return (eError); | ||
505 | } | ||
506 | |||
507 | /* | ||
508 | * OMX_GetComponentsOfRole() | ||
509 | * | ||
510 | * Description: This method will query the component for its supported roles | ||
511 | * | ||
512 | * Parameters: | ||
513 | * @param[in] role The role name to query for | ||
514 | * @param[in] pNumComps The number of components supporting the given role | ||
515 | * @param[in] compNames The names of the components supporting the given role | ||
516 | * | ||
517 | * Returns: OMX_NOERROR Successful | ||
518 | * | ||
519 | * Note | ||
520 | * | ||
521 | */ | ||
522 | OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole(OMX_IN OMX_STRING role, | ||
523 | OMX_INOUT OMX_U32 *pNumComps, OMX_INOUT OMX_U8 * *compNames) | ||
524 | { | ||
525 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
526 | OMX_U32 i = 0; | ||
527 | OMX_U32 j = 0; | ||
528 | OMX_U32 k = 0; | ||
529 | |||
530 | CORE_require(role != NULL, OMX_ErrorBadParameter, NULL); | ||
531 | CORE_require(pNumComps != NULL, OMX_ErrorBadParameter, NULL); | ||
532 | CORE_require(count > 0, OMX_ErrorUndefined, "OMX_GetHandle called without calling OMX_Init first"); | ||
533 | |||
534 | /* This implies that the componentTable is not filled */ | ||
535 | CORE_assert(componentTable[i].pRoleArray[j] != NULL, OMX_ErrorBadParameter, NULL); | ||
536 | |||
537 | for( i = 0; i < (OMX_U32)tableCount; i++ ) { | ||
538 | for( j = 0; j < componentTable[i].nRoles; j++ ) { | ||
539 | if( strcmp(componentTable[i].pRoleArray[j], role) == 0 ) { | ||
540 | /* the first call to this function should only count the number | ||
541 | of roles so that for the second call compNames can be allocated | ||
542 | with the proper size for that number of roles */ | ||
543 | if( compNames != NULL ) { | ||
544 | strncpy((OMX_STRING) (compNames[k]), | ||
545 | (OMX_STRING) componentTable[i].name, MAXNAMESIZE); | ||
546 | } | ||
547 | k++; | ||
548 | } | ||
549 | } | ||
550 | *pNumComps = k; | ||
551 | } | ||
552 | |||
553 | EXIT: | ||
554 | return (eError); | ||
555 | } | ||
556 | |||
557 | /*************************************** | ||
558 | PRINT TABLE FOR DEBUGGING PURPOSES ONLY | ||
559 | ***************************************/ | ||
560 | |||
561 | OMX_API OMX_ERRORTYPE OMX_PrintComponentTable() | ||
562 | { | ||
563 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
564 | int i = 0; | ||
565 | int j = 0; | ||
566 | |||
567 | OSAL_Info("--------Component Table:: %d Components found-------------", | ||
568 | tableCount); | ||
569 | |||
570 | for( i = 0; i < tableCount; i++ ) { | ||
571 | OSAL_Info("%i:: %s", i, componentTable[i].name); | ||
572 | |||
573 | for( j = 0; j < componentTable[i].nRoles; j++ ) { | ||
574 | OSAL_Info("%s", componentTable[i].pRoleArray[j]); | ||
575 | } | ||
576 | } | ||
577 | |||
578 | OSAL_Info("-----------------End Component Table ------------------"); | ||
579 | return (eError); | ||
580 | } | ||
581 | |||
582 | OMX_ERRORTYPE OMX_BuildComponentTable() | ||
583 | { | ||
584 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
585 | OMX_CALLBACKTYPE sCallbacks; | ||
586 | |||
587 | #ifndef STATIC_TABLE | ||
588 | OMX_HANDLETYPE hComp = 0; | ||
589 | OMX_U8 cRole[MAXNAMESIZE]; | ||
590 | OMX_STRING tempName = NULL; | ||
591 | OMX_STRING temp = NULL; | ||
592 | static OMX_STRING namePrefix = "OMX"; | ||
593 | static OMX_STRING filePrefix = "libOMX."; | ||
594 | static OMX_STRING suffix = ".so"; | ||
595 | #endif | ||
596 | int j = 0; | ||
597 | int numFiles = 0; | ||
598 | int i, k; | ||
599 | int componentfound = 0; | ||
600 | |||
601 | /* set up dummy call backs */ | ||
602 | sCallbacks.EventHandler = ComponentTable_EventHandler; | ||
603 | sCallbacks.EmptyBufferDone = ComponentTable_EmptyBufferDone; | ||
604 | sCallbacks.FillBufferDone = ComponentTable_FillBufferDone; | ||
605 | |||
606 | #ifndef STATIC_TABLE | ||
607 | /* scan the target/lib directory and create a list of files in the directory */ | ||
608 | numFiles = scandir(libdir, &namelist, 0, 0); | ||
609 | tableCount = 0; | ||
610 | |||
611 | while( numFiles-- ) { | ||
612 | /* check if the file is an OMX component */ | ||
613 | if( strncmp(namelist[numFiles]->d_name, filePrefix, strlen(filePrefix)) == 0 ) { | ||
614 | /* if the file is an OMX component, trim the prefix and suffix */ | ||
615 | tempName = (OMX_STRING) malloc(sizeof(namelist[numFiles]->d_name) + 1); /* adding one ensures */ | ||
616 | memset(tempName, 0x00, sizeof(namelist[numFiles]->d_name) + 1); /* that a null terminator will */ | ||
617 | /* always be present */ | ||
618 | /* copy only the name without the suffix */ | ||
619 | strncpy(tempName, namelist[numFiles]->d_name, | ||
620 | strlen(namelist[numFiles]->d_name) - | ||
621 | strlen(suffix)); | ||
622 | /* set a pointer to be after the lib prefix, i.e the beginning of the component name */ | ||
623 | temp = strstr(tempName, namePrefix); | ||
624 | /* then copy the component name to the table */ | ||
625 | /* | ||
626 | compName[tableCount]= (OMX_STRING) malloc(MAXNAMESIZE); | ||
627 | */ | ||
628 | strncpy(compName[tableCount], temp, strlen(temp) + 1); | ||
629 | componentTable[tableCount].name = | ||
630 | compName[tableCount]; | ||
631 | |||
632 | /* get the handle for the component and query for the roles of each component */ | ||
633 | eError = OMX_GetHandle(&hComp, componentTable[tableCount].name, 0x0, &sCallbacks); | ||
634 | if( eError == OMX_ErrorNone ) { | ||
635 | j = 0; | ||
636 | while( eError != OMX_ErrorNoMore ) { | ||
637 | eError = ((OMX_COMPONENTTYPE *) hComp)->ComponentRoleEnum(hComp, cRole, j++); | ||
638 | if( eError == OMX_ErrorNotImplemented ) { | ||
639 | j = 1; | ||
640 | break; | ||
641 | } | ||
642 | } | ||
643 | nRoles = j - 1; | ||
644 | componentTable[tableCount].nRoles = nRoles; | ||
645 | /* sRoleArray[tableCount] = (OMX_STRING *) malloc(nRoles * sizeof(OMX_STRING)); */ | ||
646 | if( nRoles > 0 ) { | ||
647 | /* sRoleArray[tableCount] = (OMX_STRING *) malloc(nRoles * sizeof(OMX_STRING)); */ | ||
648 | for( j = 0; j < nRoles; j++ ) { | ||
649 | sRoleArray[tableCount][j] = (OMX_STRING)malloc(sizeof(OMX_U8) *MAXNAMESIZE); | ||
650 | ((OMX_COMPONENTTYPE *)hComp)->ComponentRoleEnum(hComp, (OMX_U8 *)sRoleArray[tableCount][j], j); | ||
651 | componentTable[tableCount].pRoleArray[j] = sRoleArray[tableCount][j]; | ||
652 | } | ||
653 | } else { | ||
654 | /* sRoleArray[tableCount] = (OMX_STRING *) malloc(sizeof(OMX_STRING)); */ | ||
655 | sRoleArray[tableCount][j] = (OMX_STRING) malloc(sizeof(OMX_U8)* MAXNAMESIZE); | ||
656 | strcpy(sRoleArray[tableCount][j], EMPTY_STRING); | ||
657 | componentTable[tableCount].pRoleArray[j] = sRoleArray[tableCount][j]; | ||
658 | } | ||
659 | } | ||
660 | if( hComp ) { | ||
661 | /* free the component handle */ | ||
662 | eError = OMX_FreeHandle(hComp); | ||
663 | if( eError != OMX_ErrorNone ) { | ||
664 | goto EXIT; | ||
665 | } | ||
666 | } | ||
667 | /* increment the table counter index only if above was successful */ | ||
668 | tableCount++; | ||
669 | if( tempName != NULL ) { | ||
670 | free(tempName); | ||
671 | } | ||
672 | } | ||
673 | } | ||
674 | #endif | ||
675 | for( i = 0, numFiles = 0; i < MAXCOMP; i++ ) { | ||
676 | if( tComponentName[i][0] == NULL ) { | ||
677 | break; | ||
678 | } | ||
679 | |||
680 | for( j = 0; j < numFiles; j++ ) { | ||
681 | if( !strcmp(componentTable[j].name, tComponentName[i][0])) { | ||
682 | componentfound = 1; | ||
683 | break; | ||
684 | } | ||
685 | } | ||
686 | |||
687 | if( componentfound == 1 ) { | ||
688 | continue; | ||
689 | } | ||
690 | |||
691 | if( j == numFiles ) { /* new component */ | ||
692 | k = 1; | ||
693 | while( tComponentName[i][k] != NULL ) { | ||
694 | componentTable[numFiles].pRoleArray[k - 1] = | ||
695 | tComponentName[i][k]; | ||
696 | k++; | ||
697 | } | ||
698 | |||
699 | componentTable[numFiles].nRoles = k - 1; | ||
700 | strcpy(compName[numFiles], tComponentName[i][0]); | ||
701 | componentTable[numFiles].name = compName[numFiles]; | ||
702 | numFiles++; | ||
703 | } | ||
704 | } | ||
705 | |||
706 | tableCount = numFiles; | ||
707 | CORE_assert(eError == OMX_ErrorNone, eError, "Could not build Component Table"); | ||
708 | EXIT: | ||
709 | return (eError); | ||
710 | } | ||
711 | |||
712 | OMX_ERRORTYPE ComponentTable_EventHandler(OMX_IN OMX_HANDLETYPE hComponent, | ||
713 | OMX_IN OMX_PTR pAppData, | ||
714 | OMX_IN OMX_EVENTTYPE eEvent, | ||
715 | OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData) | ||
716 | { | ||
717 | (void)hComponent, pAppData, eEvent, nData1, nData2, pEventData; | ||
718 | return (OMX_ErrorNotImplemented); | ||
719 | } | ||
720 | |||
721 | OMX_ERRORTYPE ComponentTable_EmptyBufferDone(OMX_OUT OMX_HANDLETYPE | ||
722 | hComponent, OMX_OUT OMX_PTR pAppData, | ||
723 | OMX_OUT OMX_BUFFERHEADERTYPE *pBuffer) | ||
724 | { | ||
725 | (void)hComponent, pAppData, pBuffer; | ||
726 | |||
727 | return (OMX_ErrorNotImplemented); | ||
728 | } | ||
729 | |||
730 | OMX_ERRORTYPE ComponentTable_FillBufferDone(OMX_OUT OMX_HANDLETYPE hComponent, | ||
731 | OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_BUFFERHEADERTYPE *pBuffer) | ||
732 | { | ||
733 | (void)hComponent, pAppData, pBuffer; | ||
734 | |||
735 | return (OMX_ErrorNotImplemented); | ||
736 | } | ||
737 | |||
738 | /* | ||
739 | * @fn Core_Setup : This function is called when the the OMX Core library is | ||
740 | * loaded. It creates a mutex, which is used during OMX_Init() | ||
741 | */ | ||
742 | void __attribute__ ((constructor)) Core_Setup(void) | ||
743 | { | ||
744 | OSAL_ERROR eError = OSAL_ErrNone; | ||
745 | eError = OSAL_CreateMutex(&pCoreInitMutex); | ||
746 | if( eError != OSAL_ErrNone ) { | ||
747 | OSAL_ErrorTrace("Creation of default mutex failed"); | ||
748 | } | ||
749 | } | ||
750 | |||
751 | /* | ||
752 | * @fn Core_Destroy : This function is called when the the OMX Core library is | ||
753 | * unloaded. It destroys the mutex which was created by | ||
754 | * Core_Setup(). | ||
755 | * | ||
756 | */ | ||
757 | void __attribute__ ((destructor)) Core_Destroy(void) | ||
758 | { | ||
759 | OSAL_ERROR eError = OSAL_ErrNone; | ||
760 | eError = OSAL_DeleteMutex(pCoreInitMutex); | ||
761 | if( eError != OSAL_ErrNone ) { | ||
762 | OSAL_ErrorTrace("Destruction of default mutex failed"); | ||
763 | } | ||
764 | } | ||
765 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_CORE_WRAPPER" | ||
18 | |||
19 | #include <OMX_Component.h> | ||
20 | #include <OMX_Core.h> | ||
21 | #include <osal_trace.h> | ||
22 | |||
23 | #include "OMX_ComponentRegistry.h" | ||
24 | #include "OMX_Core_Wrapper.h" | ||
25 | |||
26 | /** determine capabilities of a component before acually using it */ | ||
27 | extern OMX_BOOL TIOMXConfigParser(OMX_PTR aInputParameters, | ||
28 | OMX_PTR aOutputParameters); | ||
29 | |||
30 | OMX_ERRORTYPE TIComponentTable_EventHandler(OMX_IN OMX_HANDLETYPE hComponent, | ||
31 | OMX_IN OMX_PTR pAppData, | ||
32 | OMX_IN OMX_EVENTTYPE eEvent, | ||
33 | OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData) | ||
34 | { | ||
35 | (void)hComponent, pAppData, eEvent, nData1, nData2, pEventData; | ||
36 | |||
37 | return OMX_ErrorNotImplemented; | ||
38 | } | ||
39 | |||
40 | OMX_ERRORTYPE TIComponentTable_EmptyBufferDone(OMX_OUT OMX_HANDLETYPE | ||
41 | hComponent, OMX_OUT OMX_PTR pAppData, | ||
42 | OMX_OUT OMX_BUFFERHEADERTYPE * pBuffer) | ||
43 | { | ||
44 | (void)hComponent, pAppData, pBuffer; | ||
45 | |||
46 | return OMX_ErrorNotImplemented; | ||
47 | } | ||
48 | |||
49 | OMX_ERRORTYPE TIComponentTable_FillBufferDone(OMX_OUT OMX_HANDLETYPE | ||
50 | hComponent, OMX_OUT OMX_PTR pAppData, | ||
51 | OMX_OUT OMX_BUFFERHEADERTYPE * pBuffer) | ||
52 | { | ||
53 | (void)hComponent, pAppData, pBuffer; | ||
54 | |||
55 | return OMX_ErrorNotImplemented; | ||
56 | } | ||
57 | |||
58 | |||
59 | OMX_API OMX_ERRORTYPE TIOMX_Init(void) | ||
60 | { | ||
61 | OSAL_Entering("TIOMX_Init\n"); | ||
62 | return OMX_Init(); | ||
63 | } | ||
64 | |||
65 | OMX_API OMX_ERRORTYPE TIOMX_Deinit(void) | ||
66 | { | ||
67 | OSAL_Entering("TIOMX_Deinit\n"); | ||
68 | return OMX_Deinit(); | ||
69 | } | ||
70 | |||
71 | OMX_API OMX_ERRORTYPE TIOMX_ComponentNameEnum(OMX_OUT OMX_STRING | ||
72 | cComponentName, OMX_IN OMX_U32 nNameLength, OMX_IN OMX_U32 nIndex) | ||
73 | { | ||
74 | OSAL_Entering("TIOMX_ComponentNameEnum\n"); | ||
75 | return OMX_ComponentNameEnum(cComponentName, nNameLength, nIndex); | ||
76 | } | ||
77 | |||
78 | OMX_API OMX_ERRORTYPE TIOMX_GetHandle(OMX_OUT OMX_HANDLETYPE * pHandle, | ||
79 | OMX_IN OMX_STRING cComponentName, | ||
80 | OMX_IN OMX_PTR pAppData, OMX_IN OMX_CALLBACKTYPE * pCallBacks) | ||
81 | { | ||
82 | OSAL_Entering("TIOMX_GetHandle\n"); | ||
83 | return OMX_GetHandle(pHandle, cComponentName, pAppData, pCallBacks); | ||
84 | } | ||
85 | |||
86 | OMX_API OMX_ERRORTYPE TIOMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent) | ||
87 | { | ||
88 | OSAL_Entering("TIOMX_FreeHandle\n"); | ||
89 | return OMX_FreeHandle(hComponent); | ||
90 | } | ||
91 | |||
92 | OMX_API OMX_ERRORTYPE TIOMX_GetComponentsOfRole(OMX_IN OMX_STRING role, | ||
93 | OMX_INOUT OMX_U32 * pNumComps, OMX_INOUT OMX_U8 ** compNames) | ||
94 | { | ||
95 | OSAL_Entering("TIOMX_GetComponentsOfRole\n"); | ||
96 | return OMX_GetComponentsOfRole(role, pNumComps, compNames); | ||
97 | } | ||
98 | |||
99 | OMX_API OMX_ERRORTYPE TIOMX_GetRolesOfComponent(OMX_IN OMX_STRING compName, | ||
100 | OMX_INOUT OMX_U32 * pNumRoles, OMX_OUT OMX_U8 ** roles) | ||
101 | { | ||
102 | OSAL_Entering("TIOMX_GetRolesOfComponent\n"); | ||
103 | return OMX_GetRolesOfComponent(compName, pNumRoles, roles); | ||
104 | } | ||
105 | |||
106 | OMX_API OMX_ERRORTYPE TIOMX_SetupTunnel(OMX_IN OMX_HANDLETYPE hOutput, | ||
107 | OMX_IN OMX_U32 nPortOutput, | ||
108 | OMX_IN OMX_HANDLETYPE hInput, OMX_IN OMX_U32 nPortInput) | ||
109 | { | ||
110 | OSAL_Entering("TIOMX_SetupTunnel\n"); | ||
111 | return OMX_SetupTunnel(hOutput, nPortOutput, hInput, nPortInput); | ||
112 | } | ||
113 | |||
114 | OMX_API OMX_ERRORTYPE TIOMX_GetContentPipe(OMX_OUT OMX_HANDLETYPE * hPipe, | ||
115 | OMX_IN OMX_STRING szURI) | ||
116 | { | ||
117 | (void)hPipe, szURI; | ||
118 | |||
119 | OSAL_Entering("TIOMX_GetContentPipe\n"); | ||
120 | return 0; | ||
121 | } | ||
122 | |||
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 @@ | |||
1 | LOCAL_PATH := $(call my-dir) | ||
2 | include $(CLEAR_VARS) | ||
3 | |||
4 | LOCAL_SRC_FILES := \ | ||
5 | TIOMXPlugin.cpp | ||
6 | |||
7 | LOCAL_C_INCLUDES:= \ | ||
8 | $(TOP)/frameworks/native/include/media/openmax \ | ||
9 | $(TOP)/frameworks/native/include/media/hardware | ||
10 | |||
11 | LOCAL_HEADER_LIBRARIES += media_plugin_headers | ||
12 | |||
13 | LOCAL_SHARED_LIBRARIES := \ | ||
14 | libbinder \ | ||
15 | libutils \ | ||
16 | libcutils \ | ||
17 | liblog \ | ||
18 | libui \ | ||
19 | libdl \ | ||
20 | |||
21 | LOCAL_MODULE := libstagefrighthw | ||
22 | LOCAL_VENDOR_MODULE := true | ||
23 | |||
24 | include $(BUILD_SHARED_LIBRARY) | ||
25 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include "TIOMXPlugin.h" | ||
18 | |||
19 | #include <dlfcn.h> | ||
20 | |||
21 | #include <HardwareAPI.h> | ||
22 | |||
23 | namespace android { | ||
24 | |||
25 | extern "C" OMXPluginBase *createOMXPlugin() { | ||
26 | return new TIOMXPlugin; | ||
27 | } | ||
28 | |||
29 | extern "C" void destroyOMXPlugin(OMXPluginBase *plugin) { | ||
30 | delete plugin; | ||
31 | } | ||
32 | |||
33 | #define LIBOMX "libOMX_Core.so" | ||
34 | |||
35 | TIOMXPlugin::TIOMXPlugin() | ||
36 | : mLibHandle(dlopen(LIBOMX, RTLD_NOW)), | ||
37 | mInit(NULL), | ||
38 | mDeinit(NULL), | ||
39 | mComponentNameEnum(NULL), | ||
40 | mGetHandle(NULL), | ||
41 | mFreeHandle(NULL), | ||
42 | mGetRolesOfComponentHandle(NULL) { | ||
43 | if (mLibHandle != NULL) { | ||
44 | mInit = (InitFunc)dlsym(mLibHandle, "TIOMX_Init"); | ||
45 | mDeinit = (DeinitFunc)dlsym(mLibHandle, "TIOMX_Deinit"); | ||
46 | |||
47 | mComponentNameEnum = | ||
48 | (ComponentNameEnumFunc)dlsym(mLibHandle, "TIOMX_ComponentNameEnum"); | ||
49 | |||
50 | mGetHandle = (GetHandleFunc)dlsym(mLibHandle, "TIOMX_GetHandle"); | ||
51 | mFreeHandle = (FreeHandleFunc)dlsym(mLibHandle, "TIOMX_FreeHandle"); | ||
52 | |||
53 | mGetRolesOfComponentHandle = | ||
54 | (GetRolesOfComponentFunc)dlsym( | ||
55 | mLibHandle, "TIOMX_GetRolesOfComponent"); | ||
56 | |||
57 | (*mInit)(); | ||
58 | } | ||
59 | else { | ||
60 | char const *err_str = dlerror(); | ||
61 | ALOGE("%s: failed to load %s, with error[%s]", __func__, LIBOMX, err_str?err_str:"unknown"); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | TIOMXPlugin::~TIOMXPlugin() { | ||
66 | if (mLibHandle != NULL) { | ||
67 | (*mDeinit)(); | ||
68 | |||
69 | dlclose(mLibHandle); | ||
70 | mLibHandle = NULL; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | OMX_ERRORTYPE TIOMXPlugin::makeComponentInstance( | ||
75 | const char *name, | ||
76 | const OMX_CALLBACKTYPE *callbacks, | ||
77 | OMX_PTR appData, | ||
78 | OMX_COMPONENTTYPE **component) { | ||
79 | if (mLibHandle == NULL) { | ||
80 | return OMX_ErrorUndefined; | ||
81 | } | ||
82 | |||
83 | return (*mGetHandle)( | ||
84 | reinterpret_cast<OMX_HANDLETYPE *>(component), | ||
85 | const_cast<char *>(name), | ||
86 | appData, const_cast<OMX_CALLBACKTYPE *>(callbacks)); | ||
87 | } | ||
88 | |||
89 | OMX_ERRORTYPE TIOMXPlugin::destroyComponentInstance( | ||
90 | OMX_COMPONENTTYPE *component) { | ||
91 | if (mLibHandle == NULL) { | ||
92 | return OMX_ErrorUndefined; | ||
93 | } | ||
94 | |||
95 | return (*mFreeHandle)(reinterpret_cast<OMX_HANDLETYPE *>(component)); | ||
96 | } | ||
97 | |||
98 | OMX_ERRORTYPE TIOMXPlugin::enumerateComponents( | ||
99 | OMX_STRING name, | ||
100 | size_t size, | ||
101 | OMX_U32 index) { | ||
102 | if (mLibHandle == NULL) { | ||
103 | ALOGE("mLibHandle is NULL!"); | ||
104 | return OMX_ErrorUndefined; | ||
105 | } | ||
106 | |||
107 | return (*mComponentNameEnum)(name, size, index); | ||
108 | } | ||
109 | |||
110 | OMX_ERRORTYPE TIOMXPlugin::getRolesOfComponent( | ||
111 | const char *name, | ||
112 | Vector<String8> *roles) { | ||
113 | roles->clear(); | ||
114 | |||
115 | if (mLibHandle == NULL) { | ||
116 | return OMX_ErrorUndefined; | ||
117 | } | ||
118 | |||
119 | OMX_U32 numRoles; | ||
120 | OMX_ERRORTYPE err = (*mGetRolesOfComponentHandle)( | ||
121 | const_cast<OMX_STRING>(name), &numRoles, NULL); | ||
122 | |||
123 | if (err != OMX_ErrorNone) { | ||
124 | return err; | ||
125 | } | ||
126 | |||
127 | if (numRoles > 0) { | ||
128 | OMX_U8 **array = new OMX_U8 *[numRoles]; | ||
129 | for (OMX_U32 i = 0; i < numRoles; ++i) { | ||
130 | array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE]; | ||
131 | } | ||
132 | |||
133 | err = (*mGetRolesOfComponentHandle)( | ||
134 | const_cast<OMX_STRING>(name), &numRoles, array); | ||
135 | |||
136 | for (OMX_U32 i = 0; i < numRoles; ++i) { | ||
137 | if (err == OMX_ErrorNone) { | ||
138 | String8 s((const char *)array[i]); | ||
139 | roles->push(s); | ||
140 | } | ||
141 | |||
142 | delete[] array[i]; | ||
143 | array[i] = NULL; | ||
144 | } | ||
145 | |||
146 | delete[] array; | ||
147 | array = NULL; | ||
148 | } | ||
149 | |||
150 | return err; | ||
151 | } | ||
152 | |||
153 | } // 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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2009 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef TI_OMX_PLUGIN_H_ | ||
18 | |||
19 | #define TI_OMX_PLUGIN_H_ | ||
20 | |||
21 | #include <OMXPluginBase.h> | ||
22 | |||
23 | namespace android { | ||
24 | |||
25 | struct TIOMXPlugin : public OMXPluginBase { | ||
26 | TIOMXPlugin(); | ||
27 | virtual ~TIOMXPlugin(); | ||
28 | |||
29 | virtual OMX_ERRORTYPE makeComponentInstance( | ||
30 | const char *name, | ||
31 | const OMX_CALLBACKTYPE *callbacks, | ||
32 | OMX_PTR appData, | ||
33 | OMX_COMPONENTTYPE **component); | ||
34 | |||
35 | virtual OMX_ERRORTYPE destroyComponentInstance( | ||
36 | OMX_COMPONENTTYPE *component); | ||
37 | |||
38 | virtual OMX_ERRORTYPE enumerateComponents( | ||
39 | OMX_STRING name, | ||
40 | size_t size, | ||
41 | OMX_U32 index); | ||
42 | |||
43 | virtual OMX_ERRORTYPE getRolesOfComponent( | ||
44 | const char *name, | ||
45 | Vector<String8> *roles); | ||
46 | |||
47 | private: | ||
48 | void *mLibHandle; | ||
49 | |||
50 | typedef OMX_ERRORTYPE (*InitFunc)(); | ||
51 | typedef OMX_ERRORTYPE (*DeinitFunc)(); | ||
52 | typedef OMX_ERRORTYPE (*ComponentNameEnumFunc)( | ||
53 | OMX_STRING, OMX_U32, OMX_U32); | ||
54 | |||
55 | typedef OMX_ERRORTYPE (*GetHandleFunc)( | ||
56 | OMX_HANDLETYPE *, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE *); | ||
57 | |||
58 | typedef OMX_ERRORTYPE (*FreeHandleFunc)(OMX_HANDLETYPE *); | ||
59 | |||
60 | typedef OMX_ERRORTYPE (*GetRolesOfComponentFunc)( | ||
61 | OMX_STRING, OMX_U32 *, OMX_U8 **); | ||
62 | |||
63 | InitFunc mInit; | ||
64 | DeinitFunc mDeinit; | ||
65 | ComponentNameEnumFunc mComponentNameEnum; | ||
66 | GetHandleFunc mGetHandle; | ||
67 | FreeHandleFunc mFreeHandle; | ||
68 | GetRolesOfComponentFunc mGetRolesOfComponentHandle; | ||
69 | |||
70 | TIOMXPlugin(const TIOMXPlugin &); | ||
71 | TIOMXPlugin &operator=(const TIOMXPlugin &); | ||
72 | }; | ||
73 | |||
74 | } // namespace android | ||
75 | |||
76 | #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 @@ | |||
1 | LOCAL_PATH:= $(call my-dir) | ||
2 | |||
3 | include $(CLEAR_VARS) | ||
4 | |||
5 | LOCAL_SRC_FILES:= \ | ||
6 | src/osal_events.c \ | ||
7 | src/osal_memory.c \ | ||
8 | src/osal_mutex.c \ | ||
9 | src/osal_pipes.c \ | ||
10 | src/osal_semaphores.c \ | ||
11 | src/osal_task.c \ | ||
12 | |||
13 | LOCAL_C_INCLUDES += \ | ||
14 | $(LOCAL_PATH)/inc | ||
15 | |||
16 | LOCAL_SHARED_LIBRARIES := \ | ||
17 | libc \ | ||
18 | libutils \ | ||
19 | liblog \ | ||
20 | |||
21 | LOCAL_MODULE:= libosal | ||
22 | LOCAL_MODULE_TAGS:= optional | ||
23 | LOCAL_VENDOR_MODULE := true | ||
24 | |||
25 | 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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OSAL_ERROR_H_ | ||
18 | #define _OSAL_ERROR_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" | ||
22 | { | ||
23 | #endif | ||
24 | |||
25 | #define OSAL_TRUE 1 | ||
26 | #define OSAL_FALSE 0 | ||
27 | |||
28 | #define SUCCESS 0 | ||
29 | #define NO_SUCCESS -1 | ||
30 | |||
31 | #define OSAL_SUSPEND 0xFFFFFFFFUL | ||
32 | #define OSAL_NO_SUSPEND 0x0 | ||
33 | #define OSAL_TIMED_OUT 0x7FFFFFFFUL | ||
34 | |||
35 | typedef enum osal_error { | ||
36 | OSAL_ErrNone = 0, | ||
37 | /* General module error list */ | ||
38 | OSAL_ErrNoPermissions = -1, | ||
39 | OSAL_ErrNotSupported = -2, | ||
40 | OSAL_ErrAlloc = -3, | ||
41 | OSAL_ErrOutOfResource = -4, | ||
42 | OSAL_ErrTimeOut = -5, | ||
43 | OSAL_ErrParameter = -6, | ||
44 | /* Pipe Module error list */ | ||
45 | OSAL_ErrNotReady = -11, | ||
46 | OSAL_ErrPipeFull = -12, | ||
47 | OSAL_ErrPipeEmpty = -13, | ||
48 | OSAL_ErrPipeDeleted = -14, | ||
49 | OSAL_ErrPipeReset = -15, | ||
50 | OSAL_ErrPipeClose = -16, | ||
51 | OSAL_ErrPipeWrite = -17, | ||
52 | OSAL_ErrPipeRead = -18, | ||
53 | /* Semaphore module error list */ | ||
54 | OSAL_ErrSemCreate = -20, | ||
55 | OSAL_ErrSemDelete = -21, | ||
56 | OSAL_ErrSemPost = -22, | ||
57 | OSAL_ErrSemGetValue = -23, | ||
58 | /* message queue module error list */ | ||
59 | OSAL_ErrMsgSzieMismatch = -30, | ||
60 | OSAL_ErrMsgTypeNotFound = -31, | ||
61 | OSAL_ErrUnKnown = -32, | ||
62 | /* Mutex module error list */ | ||
63 | OSAL_ErrMutexCreate = -40, | ||
64 | OSAL_ErrMutexDestroy = -41, | ||
65 | OSAL_ErrMutexLock = -42, | ||
66 | OSAL_ErrMutexUnlock = -43, | ||
67 | /* Events module error list */ | ||
68 | OSAL_ErrEventCreate = -50, | ||
69 | OSAL_ErrEventDestroy = -51, | ||
70 | OSAL_ErrSetEvent = -52, | ||
71 | OSAL_ErrRetrieve = -53, | ||
72 | OSAL_ErrEventSignal = -54, | ||
73 | /* Thread module error list */ | ||
74 | OSAL_ErrThreadCreate = -60, | ||
75 | OSAL_ErrThreadDestroy = -61, | ||
76 | } OSAL_ERROR; | ||
77 | |||
78 | |||
79 | #ifdef __cplusplus | ||
80 | } | ||
81 | #endif | ||
82 | |||
83 | #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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OSAL_EVENTS_H_ | ||
18 | #define _OSAL_EVENTS_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" | ||
22 | { | ||
23 | #endif | ||
24 | |||
25 | /* | ||
26 | * OSAL EVENT Operations list | ||
27 | */ | ||
28 | typedef enum osal_event_op | ||
29 | { | ||
30 | OSAL_EVENT_AND, | ||
31 | OSAL_EVENT_AND_CONSUME, | ||
32 | OSAL_EVENT_OR, | ||
33 | OSAL_EVENT_OR_CONSUME | ||
34 | } OSAL_EventOp; | ||
35 | |||
36 | OSAL_ERROR OSAL_CreateEvent(void **pEvents); | ||
37 | |||
38 | OSAL_ERROR OSAL_DeleteEvent(void *pEvents); | ||
39 | |||
40 | OSAL_ERROR OSAL_SetEvent(void *pEvents, uint32_t uEventFlag, OSAL_EventOp eOperation); | ||
41 | |||
42 | OSAL_ERROR OSAL_RetrieveEvent(void *pEvents, uint32_t uRequestedEvents, OSAL_EventOp eOperation, | ||
43 | uint32_t *pRetrievedEvents, uint32_t uTimeOut); | ||
44 | |||
45 | #ifdef __cplusplus | ||
46 | } | ||
47 | #endif | ||
48 | |||
49 | #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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OSAL_MEMORY_H_ | ||
18 | #define _OSAL_MEMORY_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" | ||
22 | { | ||
23 | #endif | ||
24 | |||
25 | #include "osal_error.h" | ||
26 | |||
27 | void *OSAL_Malloc(uint32_t size); | ||
28 | |||
29 | void OSAL_Free(void *pData); | ||
30 | |||
31 | OSAL_ERROR OSAL_Memset(void *pBuffer, uint8_t uValue, uint32_t uSize); | ||
32 | |||
33 | int32_t OSAL_Memcmp(void *pBuffer1, void *pBuffer2, uint32_t uSize); | ||
34 | |||
35 | OSAL_ERROR OSAL_Memcpy(void *pBufDst, void *pBufSrc, uint32_t uSize); | ||
36 | |||
37 | |||
38 | #ifdef __cplusplus | ||
39 | } | ||
40 | #endif | ||
41 | |||
42 | #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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OSAL_MUTEX_H_ | ||
18 | #define _OSAL_MUTEX_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" | ||
22 | { | ||
23 | #endif | ||
24 | |||
25 | OSAL_ERROR OSAL_CreateMutex(void **pMutex); | ||
26 | OSAL_ERROR OSAL_DeleteMutex(void *pMutex); | ||
27 | OSAL_ERROR OSAL_ObtainMutex(void *pMutex, uint32_t uTimeOut); | ||
28 | OSAL_ERROR OSAL_ReleaseMutex(void *pMutex); | ||
29 | |||
30 | #ifdef __cplusplus | ||
31 | } | ||
32 | #endif | ||
33 | |||
34 | #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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OSAL_PIPES_H_ | ||
18 | #define _OSAL_PIPES_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" | ||
22 | { | ||
23 | #endif | ||
24 | |||
25 | OSAL_ERROR OSAL_CreatePipe(void **pPipe, uint32_t pipeSize, uint32_t messageSize, uint8_t isFixedMessage); | ||
26 | |||
27 | OSAL_ERROR OSAL_DeletePipe(void *pPipe); | ||
28 | |||
29 | OSAL_ERROR OSAL_WriteToPipe(void *pPipe, void *pMessage, uint32_t size, int32_t timeout); | ||
30 | |||
31 | OSAL_ERROR OSAL_WriteToFrontOfPipe(void *pPipe, void *pMessage, uint32_t, int32_t timeout); | ||
32 | |||
33 | OSAL_ERROR OSAL_ReadFromPipe(void *pPipe, void *pMessage, uint32_t size, uint32_t *actualSize, int32_t timeout); | ||
34 | |||
35 | OSAL_ERROR OSAL_ClearPipe(void *pPipe); | ||
36 | |||
37 | OSAL_ERROR OSAL_IsPipeReady(void *pPipe); | ||
38 | |||
39 | OSAL_ERROR OSAL_GetPipeReadyMessageCount(void *pPipe, uint32_t *count); | ||
40 | |||
41 | |||
42 | #ifdef __cplusplus | ||
43 | } | ||
44 | #endif | ||
45 | |||
46 | #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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OSAL_SEMAPHORE_H_ | ||
18 | #define _OSAL_SEMAPHORE_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" | ||
22 | { | ||
23 | #endif | ||
24 | |||
25 | OSAL_ERROR OSAL_CreateSemaphore(void **pSemaphore, uint32_t uInitCount); | ||
26 | OSAL_ERROR OSAL_DeleteSemaphore(void *pSemaphore); | ||
27 | OSAL_ERROR OSAL_ObtainSemaphore(void *pSemaphore, uint32_t uTimeOut); | ||
28 | OSAL_ERROR OSAL_ReleaseSemaphore(void *pSemaphore); | ||
29 | OSAL_ERROR OSAL_ResetSemaphore(void *pSemaphore, uint32_t uInitCount); | ||
30 | OSAL_ERROR OSAL_GetSemaphoreCount(void *pSemaphore, uint32_t *count); | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | } | ||
34 | #endif | ||
35 | |||
36 | #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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OSAL_TASK_H_ | ||
18 | #define _OSAL_TASK_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" | ||
22 | { | ||
23 | #endif | ||
24 | |||
25 | typedef void *(*OSAL_TaskProc) (void *arg); | ||
26 | |||
27 | OSAL_ERROR OSAL_CreateTask(void **pTask, OSAL_TaskProc pFunc, uint32_t uArgc, | ||
28 | void *pArgv, uint32_t uStackSize, uint32_t uPriority, int8_t * pName); | ||
29 | |||
30 | OSAL_ERROR OSAL_DeleteTask(void *pTask); | ||
31 | |||
32 | OSAL_ERROR OSAL_SleepTask(uint32_t mSec); | ||
33 | |||
34 | #ifdef __cplusplus | ||
35 | } | ||
36 | #endif | ||
37 | |||
38 | #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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OSAL_TRACES_H_ | ||
18 | #define _OSAL_TRACES_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" | ||
22 | { | ||
23 | #endif | ||
24 | |||
25 | #include <utils/Log.h> | ||
26 | |||
27 | #define OSAL_ErrorTrace(fmt,...) ALOGE(fmt,##__VA_ARGS__); | ||
28 | #define OSAL_WarningTrace(fmt,...) ALOGE(fmt,##__VA_ARGS__); | ||
29 | #define OSAL_Info(fmt,...) ALOGD(fmt,##__VA_ARGS__); | ||
30 | #define OSAL_Entering(fmt,...) ALOGD(fmt,##__VA_ARGS__); | ||
31 | #define OSAL_Exiting(fmt,...) ALOGD(fmt,##__VA_ARGS__); | ||
32 | |||
33 | |||
34 | #ifdef __cplusplus | ||
35 | } | ||
36 | #endif | ||
37 | |||
38 | #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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <stdio.h> | ||
18 | #include <pthread.h> /*for POSIX calls */ | ||
19 | #include <sys/time.h> | ||
20 | #include <errno.h> | ||
21 | |||
22 | #include "osal_trace.h" | ||
23 | #include "osal_error.h" | ||
24 | #include "osal_memory.h" | ||
25 | #include "osal_events.h" | ||
26 | |||
27 | /* | ||
28 | * Thread event internal structure | ||
29 | */ | ||
30 | typedef struct | ||
31 | { | ||
32 | uint8_t bSignaled; | ||
33 | uint32_t eFlags; | ||
34 | pthread_mutex_t mutex; | ||
35 | pthread_cond_t condition; | ||
36 | } OSAL_ThreadEvent; | ||
37 | |||
38 | /* Event Create Method */ | ||
39 | OSAL_ERROR OSAL_CreateEvent(void **pEvents) | ||
40 | { | ||
41 | OSAL_ERROR bRet = OSAL_ErrUnKnown; | ||
42 | OSAL_ThreadEvent *plEvent = (OSAL_ThreadEvent *) OSAL_Malloc(sizeof(OSAL_ThreadEvent)); | ||
43 | if (NULL == plEvent) { | ||
44 | bRet = OSAL_ErrAlloc; | ||
45 | goto EXIT; | ||
46 | } | ||
47 | plEvent->bSignaled = OSAL_FALSE; | ||
48 | plEvent->eFlags = 0; | ||
49 | |||
50 | if (SUCCESS != pthread_mutex_init(&(plEvent->mutex), NULL)) { | ||
51 | OSAL_ErrorTrace("Event Create:Mutex Init failed !"); | ||
52 | bRet = OSAL_ErrMutexCreate; | ||
53 | goto EXIT; | ||
54 | } | ||
55 | |||
56 | if (SUCCESS != pthread_cond_init(&(plEvent->condition), NULL)) { | ||
57 | OSAL_ErrorTrace("Event Create:Conditional Variable Init failed !"); | ||
58 | pthread_mutex_destroy(&(plEvent->mutex)); | ||
59 | bRet = OSAL_ErrEventCreate; | ||
60 | } else { | ||
61 | *pEvents = (void *) plEvent; | ||
62 | bRet = OSAL_ErrNone; | ||
63 | } | ||
64 | EXIT: | ||
65 | if ((OSAL_ErrNone != bRet) && (NULL != plEvent)) { | ||
66 | OSAL_Free(plEvent); | ||
67 | } | ||
68 | return bRet; | ||
69 | } | ||
70 | |||
71 | /* | ||
72 | * Method to delete the event | ||
73 | */ | ||
74 | OSAL_ERROR OSAL_DeleteEvent(void *pEvents) | ||
75 | { | ||
76 | OSAL_ERROR bRet = OSAL_ErrNone; | ||
77 | OSAL_ThreadEvent *plEvent = (OSAL_ThreadEvent*) pEvents; | ||
78 | if (NULL == plEvent) { | ||
79 | bRet = OSAL_ErrParameter; | ||
80 | goto EXIT; | ||
81 | } | ||
82 | |||
83 | if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) { | ||
84 | OSAL_ErrorTrace("Event Delete: Mutex Lock failed !"); | ||
85 | bRet = OSAL_ErrMutexLock; | ||
86 | } | ||
87 | if (SUCCESS != pthread_cond_destroy(&(plEvent->condition))) { | ||
88 | OSAL_ErrorTrace("Event Delete: Conditional Variable Destroy failed !"); | ||
89 | bRet = OSAL_ErrEventDestroy; | ||
90 | } | ||
91 | if (SUCCESS != pthread_mutex_unlock(&(plEvent->mutex))) { | ||
92 | OSAL_ErrorTrace("Event Delete: Mutex Unlock failed !"); | ||
93 | bRet = OSAL_ErrMutexUnlock; | ||
94 | } | ||
95 | if (SUCCESS != pthread_mutex_destroy(&(plEvent->mutex))) { | ||
96 | OSAL_ErrorTrace("Event Delete: Mutex Destory failed !"); | ||
97 | bRet = OSAL_ErrMutexDestroy; | ||
98 | } | ||
99 | OSAL_Free(plEvent); | ||
100 | EXIT: | ||
101 | return bRet; | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | * Method to set event operation | ||
106 | */ | ||
107 | OSAL_ERROR OSAL_SetEvent(void *pEvents, uint32_t uEventFlags, OSAL_EventOp eOperation) | ||
108 | { | ||
109 | OSAL_ThreadEvent *plEvent = (OSAL_ThreadEvent*) pEvents; | ||
110 | if (NULL == plEvent) { | ||
111 | return OSAL_ErrParameter; | ||
112 | } | ||
113 | if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) { | ||
114 | OSAL_ErrorTrace("Event Set: Mutex Lock failed !"); | ||
115 | return OSAL_ErrMutexLock; | ||
116 | } | ||
117 | |||
118 | switch (eOperation) { | ||
119 | case OSAL_EVENT_AND: | ||
120 | plEvent->eFlags = plEvent->eFlags & uEventFlags; | ||
121 | break; | ||
122 | case OSAL_EVENT_OR: | ||
123 | plEvent->eFlags = plEvent->eFlags | uEventFlags; | ||
124 | break; | ||
125 | default: | ||
126 | OSAL_ErrorTrace("Event Set: Bad eOperation !"); | ||
127 | pthread_mutex_unlock(&plEvent->mutex); | ||
128 | return OSAL_ErrMutexUnlock; | ||
129 | }; | ||
130 | |||
131 | plEvent->bSignaled = OSAL_TRUE; | ||
132 | if (SUCCESS != pthread_cond_signal(&plEvent->condition)) { | ||
133 | OSAL_ErrorTrace("Event Set: Condition Variable Signal failed !"); | ||
134 | pthread_mutex_unlock(&plEvent->mutex); | ||
135 | return OSAL_ErrEventSignal; | ||
136 | } | ||
137 | |||
138 | if (SUCCESS != pthread_mutex_unlock(&plEvent->mutex)) { | ||
139 | OSAL_ErrorTrace("Event Set: Mutex Unlock failed !"); | ||
140 | return OSAL_ErrMutexUnlock; | ||
141 | } | ||
142 | return OSAL_ErrNone; | ||
143 | } | ||
144 | |||
145 | /* | ||
146 | * @fn OSAL_RetrieveEvent | ||
147 | * Spurious wakeups from the pthread_cond_timedwait() or pthread_cond_wait() functions may occur. | ||
148 | * A representative sequence for using condition variables is shown below | ||
149 | * | ||
150 | * Thread A (Retrieve Events) |Thread B (Set Events) | ||
151 | *------------------------------------------------------------------------------------------------------------ | ||
152 | *1) Do work up to the point where a certain condition must occur |1)Do work | ||
153 | * (such as "count" value) | ||
154 | 2) Lock associated mutex and check value of a global variable |2)Lock associated mutex | ||
155 | *3) Call pthread_cond_wait() to perform a blocking wait |3)Change the value of the global variable | ||
156 | * for signal from Thread-B. Note that a call to that Thread-A is waiting upon. | ||
157 | * pthread_cond_wait() automatically and atomically | ||
158 | * unlocks the associated mutex variable so that it can | ||
159 | * be used by Thread-B. | ||
160 | *4) When signalled, wake up. Mutex is automatically and |4)Check value of the global Thread-A wait | ||
161 | * atomically locked. variable. If it fulfills the desired | ||
162 | * condition, signal Thread-A. | ||
163 | *5) Explicitly unlock mutex |5) Unlock Mutex. | ||
164 | *6) Continue |6) Continue | ||
165 | */ | ||
166 | |||
167 | OSAL_ERROR OSAL_RetrieveEvent(void *pEvents, uint32_t uRequestedEvents, | ||
168 | OSAL_EventOp eOperation, uint32_t *pRetrievedEvents, uint32_t uTimeOutMsec) | ||
169 | { | ||
170 | OSAL_ERROR bRet = OSAL_ErrUnKnown; | ||
171 | struct timespec timeout; | ||
172 | struct timeval now; | ||
173 | uint32_t timeout_us; | ||
174 | uint32_t isolatedFlags; | ||
175 | int status = -1; | ||
176 | int and_operation; | ||
177 | OSAL_ThreadEvent *plEvent = (OSAL_ThreadEvent *) pEvents; | ||
178 | if (NULL == plEvent) { | ||
179 | return OSAL_ErrParameter; | ||
180 | } | ||
181 | |||
182 | /* Lock the mutex for access to the eFlags global variable */ | ||
183 | if (SUCCESS != pthread_mutex_lock(&(plEvent->mutex))) { | ||
184 | OSAL_ErrorTrace("Event Retrieve: Mutex Lock failed !"); | ||
185 | bRet = OSAL_ErrMutexLock; | ||
186 | goto EXIT; | ||
187 | } | ||
188 | |||
189 | /*Check the eOperation and put it in a variable */ | ||
190 | and_operation = (OSAL_EVENT_AND == eOperation || OSAL_EVENT_AND_CONSUME == eOperation); | ||
191 | /* Isolate the flags. The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation */ | ||
192 | isolatedFlags = plEvent->eFlags & uRequestedEvents; | ||
193 | /*Check if it is the AND operation. If yes then, all the flags must match */ | ||
194 | if (and_operation) { | ||
195 | isolatedFlags = (isolatedFlags == uRequestedEvents); | ||
196 | } | ||
197 | if (isolatedFlags) { | ||
198 | /*We have got required combination of the eFlags bits and will return it back */ | ||
199 | *pRetrievedEvents = plEvent->eFlags; | ||
200 | bRet = OSAL_ErrNone; | ||
201 | } else { | ||
202 | /*Required combination of bits is not yet available */ | ||
203 | if (OSAL_NO_SUSPEND == uTimeOutMsec) { | ||
204 | *pRetrievedEvents = 0; | ||
205 | bRet = OSAL_ErrNone; | ||
206 | } else if (OSAL_SUSPEND == uTimeOutMsec) { | ||
207 | /*Wait till we get the required combination of bits. We we get the required | ||
208 | *bits then we go out of the while loop | ||
209 | */ | ||
210 | while (!isolatedFlags) { | ||
211 | /*Wait on the conditional variable for another thread to set the eFlags and signal */ | ||
212 | pthread_cond_wait(&(plEvent->condition), &(plEvent->mutex)); | ||
213 | /* eFlags set by some thread. Now, isolate the flags. | ||
214 | * The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation | ||
215 | */ | ||
216 | isolatedFlags = plEvent->eFlags & uRequestedEvents; | ||
217 | /*Check if it is the AND operation. If yes then, all the flags must match */ | ||
218 | if (and_operation) { | ||
219 | isolatedFlags = (isolatedFlags == uRequestedEvents); | ||
220 | } | ||
221 | } | ||
222 | |||
223 | /* Obtained the requested combination of bits on eFlags */ | ||
224 | *pRetrievedEvents = plEvent->eFlags; | ||
225 | bRet = OSAL_ErrNone; | ||
226 | } else { | ||
227 | /* Calculate uTimeOutMsec in terms of the absolute time. uTimeOutMsec is in milliseconds */ | ||
228 | gettimeofday(&now, NULL); | ||
229 | timeout_us = now.tv_usec + 1000 * uTimeOutMsec; | ||
230 | timeout.tv_sec = now.tv_sec + timeout_us / 1000000; | ||
231 | timeout.tv_nsec = (timeout_us % 1000000) * 1000; | ||
232 | |||
233 | while (!isolatedFlags) { | ||
234 | /* Wait till uTimeOutMsec for a thread to signal on the conditional variable */ | ||
235 | status = pthread_cond_timedwait(&(plEvent->condition), &(plEvent->mutex), &timeout); | ||
236 | /*Timedout or error and returned without being signalled */ | ||
237 | if (SUCCESS != status) { | ||
238 | if (ETIMEDOUT == status) | ||
239 | bRet = OSAL_ErrTimeOut; | ||
240 | *pRetrievedEvents = 0; | ||
241 | break; | ||
242 | } | ||
243 | |||
244 | /* eFlags set by some thread. Now, isolate the flags. | ||
245 | * The & operation is suffice for an TIMM_OSAL_EVENT_OR eOperation | ||
246 | */ | ||
247 | isolatedFlags = plEvent->eFlags & uRequestedEvents; | ||
248 | |||
249 | /*Check if it is the AND operation. If yes then, all the flags must match */ | ||
250 | if (and_operation) { | ||
251 | isolatedFlags = (isolatedFlags == uRequestedEvents); | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | |||
257 | /*If we have got the required combination of bits, we will have to reset the eFlags if CONSUME is mentioned | ||
258 | *in the eOperations | ||
259 | */ | ||
260 | if (isolatedFlags && ((eOperation == OSAL_EVENT_AND_CONSUME) || | ||
261 | (eOperation == OSAL_EVENT_OR_CONSUME))) { | ||
262 | plEvent->eFlags = 0; | ||
263 | bRet = OSAL_ErrNone; | ||
264 | } | ||
265 | |||
266 | /*unlock the mutex */ | ||
267 | if (SUCCESS != pthread_mutex_unlock(&(plEvent->mutex))) { | ||
268 | OSAL_ErrorTrace("Event Retrieve: Mutex Unlock failed !"); | ||
269 | bRet = OSAL_ErrNone; | ||
270 | } | ||
271 | |||
272 | EXIT: | ||
273 | return bRet; | ||
274 | } | ||
275 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <string.h> | ||
18 | #include <malloc.h> | ||
19 | #include <stdint.h> | ||
20 | |||
21 | #include "osal_trace.h" | ||
22 | #include "osal_error.h" | ||
23 | #include "osal_memory.h" | ||
24 | |||
25 | void* OSAL_Malloc(size_t size) | ||
26 | { | ||
27 | void* pData = NULL; | ||
28 | pData = malloc((size_t) size); | ||
29 | return pData; | ||
30 | } | ||
31 | |||
32 | void OSAL_Free(void *pData) | ||
33 | { | ||
34 | if (NULL == pData) { | ||
35 | OSAL_WarningTrace("TIMM_OSAL_Free called on NULL pointer"); | ||
36 | return; | ||
37 | } | ||
38 | |||
39 | free(pData); | ||
40 | pData = NULL; | ||
41 | } | ||
42 | |||
43 | |||
44 | OSAL_ERROR OSAL_Memset(void *pBuffer, uint8_t uValue, uint32_t uSize) | ||
45 | { | ||
46 | if (NULL == pBuffer || uSize == 0) { | ||
47 | OSAL_WarningTrace("OSAL_Memset is called on NULL pointer"); | ||
48 | return OSAL_ErrParameter; | ||
49 | } | ||
50 | |||
51 | memset((void *)pBuffer, (int)uValue, (size_t) uSize); | ||
52 | return OSAL_ErrNone; | ||
53 | } | ||
54 | |||
55 | |||
56 | |||
57 | int32_t OSAL_Memcmp(void *pBuffer1, void *pBuffer2, uint32_t uSize) | ||
58 | { | ||
59 | if (NULL == pBuffer1 || NULL == pBuffer2) { | ||
60 | OSAL_WarningTrace("OSAL_MemCmp called with null buffers"); | ||
61 | return OSAL_ErrParameter; | ||
62 | } | ||
63 | |||
64 | int32_t result = memcmp(pBuffer1, pBuffer2, uSize); | ||
65 | return (result == 0) ? result : ((result > 0) ? 1 : -1); | ||
66 | } | ||
67 | |||
68 | |||
69 | OSAL_ERROR OSAL_Memcpy(void *pBufDst, void *pBufSrc, uint32_t uSize) | ||
70 | { | ||
71 | if (NULL == pBufDst || NULL == pBufSrc) { | ||
72 | OSAL_WarningTrace("OSAL_Memcpy called with null buffers"); | ||
73 | return OSAL_ErrParameter; | ||
74 | } | ||
75 | memcpy(pBufDst, pBufSrc, uSize); | ||
76 | return OSAL_ErrNone; | ||
77 | } | ||
78 | |||
79 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <errno.h> | ||
18 | #include <pthread.h> | ||
19 | #include <sys/time.h> | ||
20 | |||
21 | #include "osal_trace.h" | ||
22 | #include "osal_error.h" | ||
23 | #include "osal_memory.h" | ||
24 | #include "osal_semaphores.h" | ||
25 | |||
26 | OSAL_ERROR OSAL_CreateMutex(void **pMutex) | ||
27 | { | ||
28 | pthread_mutex_t *plMutex = (pthread_mutex_t *)OSAL_Malloc(sizeof(pthread_mutex_t)); | ||
29 | if (NULL == plMutex) { | ||
30 | return OSAL_ErrAlloc; | ||
31 | } | ||
32 | |||
33 | if (SUCCESS != pthread_mutex_init(plMutex, NULL)) { | ||
34 | OSAL_Free(plMutex); | ||
35 | return OSAL_ErrMutexCreate; | ||
36 | } | ||
37 | |||
38 | *pMutex = (void*) plMutex; | ||
39 | return OSAL_ErrNone; | ||
40 | } | ||
41 | |||
42 | OSAL_ERROR OSAL_DeleteMutex(void *pMutex) | ||
43 | { | ||
44 | pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; | ||
45 | if (NULL == plMutex) { | ||
46 | return OSAL_ErrParameter; | ||
47 | } | ||
48 | |||
49 | /*can we do away with if or with switch case */ | ||
50 | if (SUCCESS != pthread_mutex_destroy(plMutex)) { | ||
51 | OSAL_ErrorTrace("Delete Mutex failed !"); | ||
52 | return OSAL_ErrMutexDestroy; | ||
53 | } | ||
54 | |||
55 | OSAL_Free(plMutex); | ||
56 | return OSAL_ErrNone; | ||
57 | } | ||
58 | |||
59 | |||
60 | OSAL_ERROR OSAL_ObtainMutex(void *pMutex, uint32_t uTimeOut) | ||
61 | { | ||
62 | struct timespec abs_timeout; | ||
63 | struct timeval ltime_now; | ||
64 | uint32_t ltimenow_us; | ||
65 | pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; | ||
66 | if (plMutex == NULL) { | ||
67 | return OSAL_ErrParameter; | ||
68 | } | ||
69 | |||
70 | if (OSAL_SUSPEND == uTimeOut) { | ||
71 | if (SUCCESS != pthread_mutex_lock(plMutex)) { | ||
72 | OSAL_ErrorTrace("Lock Mutex failed !"); | ||
73 | return OSAL_ErrMutexLock; | ||
74 | } | ||
75 | } else if (OSAL_NO_SUSPEND == uTimeOut) { | ||
76 | if (SUCCESS != pthread_mutex_trylock(plMutex)) { | ||
77 | OSAL_ErrorTrace("Lock Mutex failed !"); | ||
78 | return OSAL_ErrMutexLock; | ||
79 | } | ||
80 | } else { | ||
81 | gettimeofday(<ime_now, NULL); | ||
82 | /*uTimeOut is assumed to be in milliseconds */ | ||
83 | ltimenow_us = ltime_now.tv_usec + 1000 * uTimeOut; | ||
84 | abs_timeout.tv_sec = ltime_now.tv_sec + uTimeOut / 1000; | ||
85 | abs_timeout.tv_nsec = (ltimenow_us % 1000000) * 1000; | ||
86 | if (SUCCESS != pthread_mutex_lock(plMutex)) { | ||
87 | OSAL_ErrorTrace("Lock Mutex failed !"); | ||
88 | return OSAL_ErrMutexLock; | ||
89 | } | ||
90 | } | ||
91 | return OSAL_ErrNone; | ||
92 | } | ||
93 | |||
94 | |||
95 | OSAL_ERROR OSAL_ReleaseMutex(void *pMutex) | ||
96 | { | ||
97 | pthread_mutex_t *plMutex = (pthread_mutex_t *) pMutex; | ||
98 | if (NULL == plMutex) { | ||
99 | return OSAL_ErrParameter; | ||
100 | } | ||
101 | |||
102 | if (SUCCESS != pthread_mutex_unlock(plMutex)) { | ||
103 | OSAL_ErrorTrace("Unlock Mutex failed !"); | ||
104 | return OSAL_ErrMutexUnlock; | ||
105 | } | ||
106 | return OSAL_ErrNone; | ||
107 | } | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <unistd.h> | ||
18 | #include <stdio.h> | ||
19 | #include <unistd.h> | ||
20 | #include <errno.h> | ||
21 | |||
22 | #include "osal_error.h" | ||
23 | #include "osal_memory.h" | ||
24 | #include "osal_trace.h" | ||
25 | |||
26 | /** | ||
27 | * structure definition for the OSAL pipe | ||
28 | */ | ||
29 | typedef struct timm_osal_pipe | ||
30 | { | ||
31 | int pfd[2]; | ||
32 | uint32_t pipeSize; | ||
33 | uint32_t messageSize; | ||
34 | uint8_t isFixedMessage; | ||
35 | int messageCount; | ||
36 | int totalBytesInPipe; | ||
37 | pthread_mutex_t mutex; | ||
38 | } OSAL_Pipe; | ||
39 | |||
40 | typedef enum | ||
41 | { | ||
42 | PIPE_RESET, | ||
43 | PIPE_INCREMENT, | ||
44 | PIPE_DECREMENT, | ||
45 | }PIPE_UPDATE; | ||
46 | |||
47 | static inline int UpdatePipe(void *pPipe, uint32_t msgCnt, uint32_t size, PIPE_UPDATE updateMode) | ||
48 | { | ||
49 | OSAL_Pipe *pHandle = (OSAL_Pipe*)pPipe; | ||
50 | |||
51 | switch(updateMode) { | ||
52 | case PIPE_RESET: | ||
53 | pHandle->messageCount = msgCnt; | ||
54 | pHandle->totalBytesInPipe = size; | ||
55 | break; | ||
56 | |||
57 | case PIPE_INCREMENT: | ||
58 | pHandle->messageCount += msgCnt; | ||
59 | pHandle->totalBytesInPipe += size; | ||
60 | break; | ||
61 | |||
62 | case PIPE_DECREMENT: | ||
63 | pHandle->messageCount -= msgCnt; | ||
64 | pHandle->totalBytesInPipe -= size; | ||
65 | break; | ||
66 | |||
67 | default: | ||
68 | OSAL_ErrorTrace("InValid Pipe update Mode"); | ||
69 | } | ||
70 | |||
71 | return OSAL_ErrNone; | ||
72 | } | ||
73 | |||
74 | OSAL_ERROR OSAL_CreatePipe(void **pPipe, uint32_t pipeSize, | ||
75 | uint32_t messageSize, uint8_t isFixedMessage) | ||
76 | { | ||
77 | OSAL_Pipe *pHandle = (OSAL_Pipe*)OSAL_Malloc(sizeof(OSAL_Pipe)); | ||
78 | if (NULL == pHandle) { | ||
79 | return OSAL_ErrAlloc; | ||
80 | } | ||
81 | |||
82 | OSAL_Memset(pHandle, 0x0, sizeof(OSAL_Pipe)); | ||
83 | pHandle->pfd[0] = -1; | ||
84 | pHandle->pfd[1] = -1; | ||
85 | if (SUCCESS != pipe(pHandle->pfd)) { | ||
86 | OSAL_ErrorTrace("Pipe failed: %s!!!", strerror(errno)); | ||
87 | OSAL_Free(pHandle); | ||
88 | return OSAL_ErrAlloc; | ||
89 | } | ||
90 | |||
91 | if (SUCCESS != pthread_mutex_init(&(pHandle->mutex), NULL)) { | ||
92 | OSAL_ErrorTrace("Pipe Create:Mutex Init failed !"); | ||
93 | OSAL_Free(pHandle); | ||
94 | return OSAL_ErrMutexCreate; | ||
95 | } | ||
96 | pHandle->pipeSize = pipeSize; | ||
97 | pHandle->messageSize = messageSize; | ||
98 | pHandle->isFixedMessage = isFixedMessage; | ||
99 | pHandle->messageCount = 0; | ||
100 | pHandle->totalBytesInPipe = 0; | ||
101 | |||
102 | *pPipe = (void*)pHandle; | ||
103 | return OSAL_ErrNone; | ||
104 | } | ||
105 | |||
106 | OSAL_ERROR OSAL_DeletePipe(void *pPipe) | ||
107 | { | ||
108 | OSAL_Pipe *pHandle = (OSAL_Pipe*) pPipe; | ||
109 | if (NULL == pHandle) { | ||
110 | return OSAL_ErrParameter; | ||
111 | } | ||
112 | |||
113 | if (SUCCESS != close(pHandle->pfd[0])) { | ||
114 | OSAL_ErrorTrace("Delete_Pipe Read fd failed!!!"); | ||
115 | return OSAL_ErrPipeClose; | ||
116 | } | ||
117 | if (SUCCESS != close(pHandle->pfd[1])) { | ||
118 | OSAL_ErrorTrace("Delete_Pipe Write fd failed!!!"); | ||
119 | return OSAL_ErrPipeClose; | ||
120 | } | ||
121 | |||
122 | if (SUCCESS != pthread_mutex_destroy(&(pHandle->mutex))) { | ||
123 | OSAL_ErrorTrace("Pipe Delete: Mutex Destory failed !"); | ||
124 | return OSAL_ErrMutexDestroy; | ||
125 | } | ||
126 | |||
127 | OSAL_Free(pHandle); | ||
128 | return OSAL_ErrNone; | ||
129 | } | ||
130 | |||
131 | |||
132 | OSAL_ERROR OSAL_WriteToPipe(void *pPipe, void *pMessage, uint32_t size, int32_t timeout) | ||
133 | { | ||
134 | uint32_t lSizeWritten = -1; | ||
135 | OSAL_ERROR ret = OSAL_ErrNone; | ||
136 | OSAL_Pipe *pHandle = (OSAL_Pipe*)pPipe; | ||
137 | (void)timeout; | ||
138 | |||
139 | if (NULL == pHandle || size == 0) { | ||
140 | OSAL_ErrorTrace("0 size!!!"); | ||
141 | return OSAL_ErrParameter; | ||
142 | } | ||
143 | |||
144 | |||
145 | if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { | ||
146 | OSAL_ErrorTrace("update Pipe: Mutex Lock failed !"); | ||
147 | return OSAL_ErrMutexLock; | ||
148 | } | ||
149 | |||
150 | /*Update message count and size */ | ||
151 | ret = UpdatePipe(pHandle, 1, size, PIPE_INCREMENT); | ||
152 | if (ret) { | ||
153 | goto EXIT; | ||
154 | } | ||
155 | |||
156 | lSizeWritten = write(pHandle->pfd[1], pMessage, size); | ||
157 | if (lSizeWritten != size) { | ||
158 | OSAL_ErrorTrace("Write of pipe failed!!!"); | ||
159 | /*Update message count and size */ | ||
160 | UpdatePipe(pHandle, 1, size, PIPE_DECREMENT); | ||
161 | ret = OSAL_ErrPipeWrite; | ||
162 | } | ||
163 | |||
164 | EXIT: | ||
165 | |||
166 | if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { | ||
167 | OSAL_ErrorTrace("update Pipe: Mutex Unlock failed !"); | ||
168 | ret = OSAL_ErrMutexUnlock; | ||
169 | } | ||
170 | |||
171 | return ret; | ||
172 | } | ||
173 | |||
174 | |||
175 | OSAL_ERROR OSAL_WriteToFrontOfPipe(void *pPipe, void *pMessage, uint32_t size, int32_t timeout) | ||
176 | { | ||
177 | uint32_t lSizeWritten = -1; | ||
178 | uint32_t lSizeRead = -1; | ||
179 | OSAL_ERROR ret = OSAL_ErrNone; | ||
180 | OSAL_Pipe *pHandle = (OSAL_Pipe*) pPipe; | ||
181 | uint8_t *tempPtr = NULL; | ||
182 | (void)timeout; | ||
183 | |||
184 | /*First write to this pipe */ | ||
185 | if (NULL == pHandle || size == 0) { | ||
186 | return OSAL_ErrParameter; | ||
187 | |||
188 | } | ||
189 | |||
190 | if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { | ||
191 | OSAL_ErrorTrace("update Pipe: Mutex Lock failed !"); | ||
192 | return OSAL_ErrMutexLock; | ||
193 | } | ||
194 | |||
195 | /*Update message count and size */ | ||
196 | ret = UpdatePipe(pHandle, 1, size, PIPE_INCREMENT); | ||
197 | if (ret) { | ||
198 | goto EXIT; | ||
199 | } | ||
200 | |||
201 | |||
202 | lSizeWritten = write(pHandle->pfd[1], pMessage, size); | ||
203 | if (lSizeWritten != size) { | ||
204 | /*Update message count and size */ | ||
205 | UpdatePipe(pHandle, 1, size, PIPE_DECREMENT); | ||
206 | ret = OSAL_ErrPipeWrite; | ||
207 | goto EXIT; | ||
208 | } | ||
209 | |||
210 | if (pHandle->messageCount > 1) { | ||
211 | /*First allocate memory */ | ||
212 | tempPtr = (uint8_t*)OSAL_Malloc(pHandle->totalBytesInPipe-size); | ||
213 | if (NULL == tempPtr) { | ||
214 | ret = OSAL_ErrAlloc; | ||
215 | goto EXIT; | ||
216 | } | ||
217 | |||
218 | /*Read out of pipe */ | ||
219 | lSizeRead = read(pHandle->pfd[0], tempPtr, pHandle->totalBytesInPipe-size); | ||
220 | |||
221 | /*Write back to pipe */ | ||
222 | lSizeWritten = write(pHandle->pfd[1], tempPtr, lSizeRead); | ||
223 | if (lSizeWritten != lSizeRead) { | ||
224 | /*Update message count and size */ | ||
225 | UpdatePipe(pHandle, 1, size, PIPE_RESET); | ||
226 | ret = OSAL_ErrPipeWrite; | ||
227 | } | ||
228 | OSAL_Free(tempPtr); | ||
229 | } | ||
230 | |||
231 | EXIT: | ||
232 | if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { | ||
233 | OSAL_ErrorTrace("update Pipe: Mutex Unlock failed !"); | ||
234 | ret = OSAL_ErrMutexUnlock; | ||
235 | } | ||
236 | |||
237 | return ret; | ||
238 | } | ||
239 | |||
240 | |||
241 | OSAL_ERROR OSAL_ReadFromPipe(void *pPipe, void *pMessage, uint32_t size, | ||
242 | uint32_t *actualSize, int32_t timeout) | ||
243 | { | ||
244 | uint32_t lSizeRead = -1; | ||
245 | OSAL_ERROR ret = OSAL_ErrNone; | ||
246 | OSAL_Pipe *pHandle = (OSAL_Pipe*) pPipe; | ||
247 | |||
248 | if (NULL == pHandle || size == 0) { | ||
249 | OSAL_ErrorTrace("nRead size has error!!!"); | ||
250 | return OSAL_ErrParameter; | ||
251 | } | ||
252 | |||
253 | if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { | ||
254 | OSAL_ErrorTrace("update Pipe: Mutex Lock failed !"); | ||
255 | return OSAL_ErrMutexLock; | ||
256 | } | ||
257 | |||
258 | if (pHandle->messageCount == 0 && timeout == OSAL_NO_SUSPEND) { | ||
259 | /*If timeout is 0 and pipe is empty, return error */ | ||
260 | OSAL_ErrorTrace("Pipe is empty!!!"); | ||
261 | ret = OSAL_ErrPipeEmpty; | ||
262 | goto EXIT; | ||
263 | } | ||
264 | |||
265 | if (timeout != OSAL_NO_SUSPEND && timeout != (int32_t)OSAL_SUSPEND) { | ||
266 | OSAL_WarningTrace("Only infinite or no timeouts \ | ||
267 | supported. Going to read with infinite timeout now"); | ||
268 | } | ||
269 | |||
270 | /*read blocks infinitely until message is available */ | ||
271 | *actualSize = lSizeRead = read(pHandle->pfd[0], pMessage, size); | ||
272 | if (0 == lSizeRead) { | ||
273 | OSAL_ErrorTrace("EOF reached or no data in pipe!!!"); | ||
274 | ret = OSAL_ErrPipeRead; | ||
275 | goto EXIT; | ||
276 | } | ||
277 | |||
278 | ret = UpdatePipe(pHandle, 1, lSizeRead, PIPE_DECREMENT); | ||
279 | |||
280 | EXIT: | ||
281 | |||
282 | if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { | ||
283 | OSAL_ErrorTrace("update Pipe: Mutex Unlock failed !"); | ||
284 | ret = OSAL_ErrMutexUnlock; | ||
285 | } | ||
286 | |||
287 | return ret; | ||
288 | |||
289 | } | ||
290 | |||
291 | |||
292 | OSAL_ERROR OSAL_ClearPipe(void *pPipe) | ||
293 | { | ||
294 | (void)pPipe; | ||
295 | OSAL_WarningTrace("This function is currently not implemented"); | ||
296 | return OSAL_ErrNone; | ||
297 | } | ||
298 | |||
299 | OSAL_ERROR OSAL_IsPipeReady(void *pPipe) | ||
300 | { | ||
301 | OSAL_Pipe *pHandle = (OSAL_Pipe *) pPipe; | ||
302 | int isReady; | ||
303 | |||
304 | if (NULL == pHandle) { | ||
305 | return OSAL_ErrParameter; | ||
306 | } | ||
307 | |||
308 | if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { | ||
309 | OSAL_ErrorTrace("IsPipeReady: Mutex Lock failed !"); | ||
310 | return OSAL_ErrMutexLock; | ||
311 | } | ||
312 | |||
313 | isReady = (pHandle->messageCount <= 0) ? OSAL_ErrNotReady : OSAL_ErrNone; | ||
314 | |||
315 | if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { | ||
316 | OSAL_ErrorTrace("IsPipeReady: Mutex Unlock failed !"); | ||
317 | return OSAL_ErrMutexUnlock; | ||
318 | } | ||
319 | return isReady; | ||
320 | } | ||
321 | |||
322 | OSAL_ERROR OSAL_GetPipeReadyMessageCount(void *pPipe, uint32_t *count) | ||
323 | { | ||
324 | OSAL_Pipe *pHandle = (OSAL_Pipe*) pPipe; | ||
325 | if (NULL == pHandle) { | ||
326 | *count = 0; | ||
327 | return OSAL_ErrParameter; | ||
328 | } | ||
329 | |||
330 | if (SUCCESS != pthread_mutex_lock(&(pHandle->mutex))) { | ||
331 | OSAL_ErrorTrace("GetPipeReadyMessageCount: Mutex Lock failed !"); | ||
332 | return OSAL_ErrMutexLock; | ||
333 | } | ||
334 | |||
335 | |||
336 | *count = pHandle->messageCount; | ||
337 | |||
338 | if (SUCCESS != pthread_mutex_unlock(&(pHandle->mutex))) { | ||
339 | OSAL_ErrorTrace("GetPipeReadyMessageCount: Mutex Unlock failed !"); | ||
340 | return OSAL_ErrMutexUnlock; | ||
341 | } | ||
342 | |||
343 | return OSAL_ErrNone; | ||
344 | } | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <stdio.h> | ||
18 | |||
19 | #include <semaphore.h> | ||
20 | #include <sys/time.h> | ||
21 | |||
22 | #include "osal_trace.h" | ||
23 | #include "osal_error.h" | ||
24 | #include "osal_memory.h" | ||
25 | |||
26 | OSAL_ERROR OSAL_CreateSemaphore(void **pSemaphore, uint32_t uInitCount) | ||
27 | { | ||
28 | OSAL_ERROR bRet = OSAL_ErrUnKnown; | ||
29 | *pSemaphore = NULL; | ||
30 | sem_t *psem = (sem_t *)OSAL_Malloc(sizeof(sem_t)); | ||
31 | if (NULL == psem) { | ||
32 | bRet = OSAL_ErrAlloc; | ||
33 | goto EXIT; | ||
34 | } | ||
35 | |||
36 | /*Unnamed semaphore */ | ||
37 | if (SUCCESS != sem_init(psem, 0, uInitCount)) { | ||
38 | OSAL_ErrorTrace("Semaphore Create failed !"); | ||
39 | bRet = OSAL_ErrSemCreate; | ||
40 | goto EXIT; | ||
41 | } | ||
42 | *pSemaphore = (void *) psem; | ||
43 | bRet = OSAL_ErrNone; | ||
44 | |||
45 | EXIT: | ||
46 | if (OSAL_ErrNone != bRet && NULL != psem) { | ||
47 | OSAL_Free(psem); | ||
48 | } | ||
49 | return bRet; | ||
50 | } | ||
51 | |||
52 | OSAL_ERROR OSAL_DeleteSemaphore(void *pSemaphore) | ||
53 | { | ||
54 | sem_t *psem = (sem_t *)pSemaphore; | ||
55 | if (NULL == psem) { | ||
56 | return OSAL_ErrParameter; | ||
57 | } | ||
58 | /* Release the semaphore. */ | ||
59 | if (SUCCESS != sem_destroy(psem)) { | ||
60 | OSAL_ErrorTrace("Semaphore Delete failed !"); | ||
61 | return OSAL_ErrSemDelete; | ||
62 | } | ||
63 | |||
64 | OSAL_Free(psem); | ||
65 | return OSAL_ErrNone; | ||
66 | } | ||
67 | |||
68 | OSAL_ERROR OSAL_ObtainSemaphore(void *pSemaphore, uint32_t uTimeOut) | ||
69 | { | ||
70 | struct timeval ltime_now; | ||
71 | struct timespec abs_timeout; | ||
72 | sem_t *psem = (sem_t *) pSemaphore; | ||
73 | if (psem == NULL) { | ||
74 | return OSAL_ErrParameter; | ||
75 | } | ||
76 | |||
77 | if (OSAL_SUSPEND == uTimeOut) { | ||
78 | if (SUCCESS != sem_wait(psem)) { | ||
79 | OSAL_ErrorTrace("Semaphore Wait failed !"); | ||
80 | return OSAL_ErrTimeOut; | ||
81 | } | ||
82 | } else if (OSAL_NO_SUSPEND == uTimeOut) { | ||
83 | if (SUCCESS != sem_trywait(psem)) { | ||
84 | OSAL_ErrorTrace("Semaphore blocked !"); | ||
85 | return OSAL_ErrTimeOut; | ||
86 | } | ||
87 | } else { | ||
88 | /* Some delay in calling gettimeofday and sem_timedwait - cant | ||
89 | * be avoided. Possibility of thread switch after gettimeofday | ||
90 | * in which case time out will be less than expected */ | ||
91 | gettimeofday(<ime_now, NULL); | ||
92 | /*uTimeOut is assumed to be in milliseconds */ | ||
93 | abs_timeout.tv_sec = ltime_now.tv_sec + (uTimeOut / 1000); | ||
94 | abs_timeout.tv_nsec = 1000 * (ltime_now.tv_usec + ((uTimeOut % 1000) * 1000)); | ||
95 | if (SUCCESS != sem_timedwait(psem, &abs_timeout)) { | ||
96 | OSAL_ErrorTrace("Semaphore Timed Wait failed !"); | ||
97 | return OSAL_ErrTimeOut; | ||
98 | } | ||
99 | } | ||
100 | return OSAL_ErrNone; | ||
101 | } | ||
102 | |||
103 | OSAL_ERROR OSAL_ReleaseSemaphore(void *pSemaphore) | ||
104 | { | ||
105 | sem_t *psem = (sem_t *) pSemaphore; | ||
106 | if (NULL == psem) { | ||
107 | return OSAL_ErrParameter; | ||
108 | } | ||
109 | /* Release the semaphore. */ | ||
110 | if (SUCCESS != sem_post(psem)) { | ||
111 | OSAL_ErrorTrace("Release failed !"); | ||
112 | return OSAL_ErrSemPost; | ||
113 | } | ||
114 | return OSAL_ErrNone; | ||
115 | } | ||
116 | |||
117 | OSAL_ERROR OSAL_ResetSemaphore(void *pSemaphore, uint32_t uInitCount) | ||
118 | { | ||
119 | (void)pSemaphore, uInitCount; | ||
120 | return OSAL_ErrNone; | ||
121 | } | ||
122 | |||
123 | OSAL_ERROR OSAL_GetSemaphoreCount(void *pSemaphore, uint32_t *count) | ||
124 | { | ||
125 | int sval = -2; /*value that is not possible */ | ||
126 | sem_t *psem = (sem_t *) pSemaphore; | ||
127 | if (NULL == psem) { | ||
128 | return OSAL_ErrParameter; | ||
129 | } | ||
130 | |||
131 | /* Release the semaphore. */ | ||
132 | if (SUCCESS != sem_getvalue(psem, &sval)) { | ||
133 | OSAL_ErrorTrace("Get Semaphore Count failed !"); | ||
134 | return OSAL_ErrSemGetValue; | ||
135 | } | ||
136 | |||
137 | *count = sval; | ||
138 | return OSAL_ErrNone; | ||
139 | } | ||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | |||
18 | #include <stdio.h> | ||
19 | #include <pthread.h> /*for POSIX calls */ | ||
20 | #include <sched.h> /*for sched structure */ | ||
21 | #include <unistd.h> | ||
22 | |||
23 | #include "osal_trace.h" | ||
24 | #include "osal_error.h" | ||
25 | #include "osal_memory.h" | ||
26 | #include "osal_task.h" | ||
27 | |||
28 | /** | ||
29 | * osal_task structure definition | ||
30 | */ | ||
31 | typedef struct osal_task | ||
32 | { | ||
33 | pthread_t threadID; /*SHM check */ | ||
34 | pthread_attr_t ThreadAttr; /* To set the priority and stack size */ | ||
35 | /*parameters to the task */ | ||
36 | uint32_t uArgc; | ||
37 | void *pArgv; | ||
38 | uint8_t isCreated; /** flag to check if task got created */ | ||
39 | } OSAL_Task; | ||
40 | |||
41 | /* | ||
42 | * Task creation | ||
43 | */ | ||
44 | OSAL_ERROR OSAL_CreateTask(void **pTask, OSAL_TaskProc pFunc, uint32_t uArgc, | ||
45 | void *pArgv, uint32_t uStackSize, uint32_t uPriority, int8_t *pName) | ||
46 | { | ||
47 | OSAL_ERROR bRet = OSAL_ErrThreadCreate; | ||
48 | OSAL_Task *pHandle = NULL; | ||
49 | struct sched_param sched; | ||
50 | size_t stackSize; | ||
51 | (void)pName; | ||
52 | *pTask = NULL; | ||
53 | |||
54 | /*Task structure allocation */ | ||
55 | pHandle = (OSAL_Task*)OSAL_Malloc(sizeof(OSAL_Task)); | ||
56 | if (NULL == pHandle) { | ||
57 | bRet = OSAL_ErrAlloc; | ||
58 | goto EXIT; | ||
59 | } | ||
60 | |||
61 | /* Initial cleaning of the task structure */ | ||
62 | OSAL_Memset((void*)pHandle, 0, sizeof(OSAL_Task)); | ||
63 | |||
64 | /*Arguments for task */ | ||
65 | pHandle->uArgc = uArgc; | ||
66 | pHandle->pArgv = pArgv; | ||
67 | pHandle->isCreated = OSAL_FALSE; | ||
68 | |||
69 | if (SUCCESS != pthread_attr_init(&pHandle->ThreadAttr)) { | ||
70 | OSAL_ErrorTrace("Task Init Attr Init failed!"); | ||
71 | goto EXIT; | ||
72 | } | ||
73 | |||
74 | /* Updation of the priority and the stack size */ | ||
75 | if (SUCCESS != pthread_attr_getschedparam(&pHandle->ThreadAttr, &sched)) { | ||
76 | OSAL_ErrorTrace("Task Init Get Sched Params failed!"); | ||
77 | goto EXIT; | ||
78 | } | ||
79 | |||
80 | sched.sched_priority = uPriority; /* relative to the default priority */ | ||
81 | if (SUCCESS != pthread_attr_setschedparam(&pHandle->ThreadAttr, &sched)) { | ||
82 | OSAL_ErrorTrace("Task Init Set Sched Paramsfailed!"); | ||
83 | goto EXIT; | ||
84 | } | ||
85 | |||
86 | /*First get the default stack size */ | ||
87 | if (SUCCESS != pthread_attr_getstacksize(&pHandle->ThreadAttr, &stackSize)) { | ||
88 | OSAL_ErrorTrace("Task Init Set Stack Size failed!"); | ||
89 | goto EXIT; | ||
90 | } | ||
91 | |||
92 | /*Check if requested stack size is larger than the current default stack size */ | ||
93 | if (uStackSize > stackSize) { | ||
94 | stackSize = uStackSize; | ||
95 | if (SUCCESS != pthread_attr_setstacksize(&pHandle->ThreadAttr, stackSize)) { | ||
96 | OSAL_ErrorTrace("Task Init Set Stack Size failed!"); | ||
97 | goto EXIT; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | if (SUCCESS != pthread_create(&pHandle->threadID, &pHandle->ThreadAttr, pFunc, pArgv)) { | ||
102 | OSAL_ErrorTrace("Create_Task failed !"); | ||
103 | goto EXIT; | ||
104 | } | ||
105 | |||
106 | /* Task was successfully created */ | ||
107 | pHandle->isCreated = OSAL_TRUE; | ||
108 | *pTask = (void*) pHandle; | ||
109 | bRet = OSAL_ErrNone; | ||
110 | |||
111 | EXIT: | ||
112 | if (OSAL_ErrNone != bRet) { | ||
113 | OSAL_Free(pHandle); | ||
114 | } | ||
115 | return bRet; | ||
116 | } | ||
117 | |||
118 | |||
119 | OSAL_ERROR OSAL_DeleteTask(void *pTask) | ||
120 | { | ||
121 | OSAL_Task *pHandle = (OSAL_Task*)pTask; | ||
122 | void *retVal; | ||
123 | |||
124 | if (NULL == pHandle || OSAL_TRUE != pHandle->isCreated) { | ||
125 | /* this task was never created */ | ||
126 | return OSAL_ErrParameter; | ||
127 | } | ||
128 | if (pthread_attr_destroy(&pHandle->ThreadAttr)) { | ||
129 | OSAL_ErrorTrace("Delete_Task failed !"); | ||
130 | return OSAL_ErrThreadDestroy; | ||
131 | } | ||
132 | if (pthread_join(pHandle->threadID, &retVal)) { | ||
133 | OSAL_ErrorTrace("Delete_Task failed !"); | ||
134 | return OSAL_ErrThreadDestroy; | ||
135 | } | ||
136 | |||
137 | OSAL_Free(pHandle); | ||
138 | return OSAL_ErrNone; | ||
139 | } | ||
140 | |||
141 | |||
142 | OSAL_ERROR OSAL_SleepTask(uint32_t mSec) | ||
143 | { | ||
144 | usleep(1000 * mSec); | ||
145 | return OSAL_ErrNone; | ||
146 | } | ||
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 @@ | |||
1 | LOCAL_PATH:= $(call my-dir) | ||
2 | |||
3 | # | ||
4 | # libOMX.TI.DUCATI1.VIDEO.DECODER.so | ||
5 | # | ||
6 | |||
7 | include $(CLEAR_VARS) | ||
8 | |||
9 | LOCAL_C_INCLUDES += \ | ||
10 | frameworks/native/include/media/openmax \ | ||
11 | $(LOCAL_PATH)/../base/omx_core/inc \ | ||
12 | $(LOCAL_PATH)/../osal/inc \ | ||
13 | $(LOCAL_PATH)/../base/omx_base_comp/inc \ | ||
14 | $(LOCAL_PATH)/../base/omx_base_dio_plugin/inc \ | ||
15 | hardware/libhardware/include \ | ||
16 | hardware/ti/dra7xx/hwcomposer/ \ | ||
17 | hardware/ti/dce/ \ | ||
18 | $(LOCAL_PATH)/omx_videodec_common/inc/ \ | ||
19 | $(LOCAL_PATH)/omx_h264_dec/inc/ \ | ||
20 | $(LOCAL_PATH)/omx_mpeg4_dec/inc/ \ | ||
21 | $(LOCAL_PATH)/omx_mpeg2_dec/inc/ \ | ||
22 | hardware/ti/dce/packages/codec_engine/ \ | ||
23 | hardware/ti/dce/packages/framework_components/ \ | ||
24 | hardware/ti/dce/packages/ivahd_codecs/ \ | ||
25 | hardware/ti/dce/packages/xdais/ \ | ||
26 | hardware/ti/dce/packages/xdctools | ||
27 | |||
28 | LOCAL_HEADER_LIBRARIES += libutils_headers | ||
29 | |||
30 | LOCAL_SHARED_LIBRARIES := \ | ||
31 | libosal \ | ||
32 | libc \ | ||
33 | liblog \ | ||
34 | libOMX \ | ||
35 | libhardware \ | ||
36 | libdce | ||
37 | |||
38 | LOCAL_CFLAGS += -Dxdc_target_types__=google/targets/arm/std.h -DBUILDOS_ANDROID -Dxdc__deprecated_types | ||
39 | |||
40 | LOCAL_MODULE_TAGS:= optional | ||
41 | |||
42 | LOCAL_SRC_FILES:= omx_videodec_common/src/omx_video_decoder.c \ | ||
43 | omx_videodec_common/src/omx_video_decoder_componenttable.c \ | ||
44 | omx_videodec_common/src/omx_video_decoder_internal.c \ | ||
45 | omx_h264_dec/src/omx_h264dec.c \ | ||
46 | omx_mpeg4_dec/src/omx_mpeg4dec.c \ | ||
47 | omx_mpeg2_dec/src/omx_mpeg2dec.c | ||
48 | |||
49 | LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.DECODER | ||
50 | LOCAL_VENDOR_MODULE := true | ||
51 | |||
52 | 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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_H264VD_H_ | ||
18 | #define _OMX_H264VD_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <omx_video_decoder.h> | ||
25 | #include <ti/sdo/codecs/h264vdec/ih264vdec.h> | ||
26 | |||
27 | /*! Padding for width as per Codec Requirement */ | ||
28 | #define PADX (32) | ||
29 | /*! Padding for height as per Codec requirement */ | ||
30 | #define PADY (24) | ||
31 | |||
32 | /** Default Frame skip H264 Decoder */ | ||
33 | #define H264VD_DEFAULT_FRAME_SKIP IVIDEO_SKIP_DEFAULT | ||
34 | |||
35 | |||
36 | static OMX_ERRORTYPE OMXH264VD_GetParameter(OMX_HANDLETYPE hComponent, | ||
37 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
38 | |||
39 | static OMX_ERRORTYPE OMXH264VD_SetParameter(OMX_HANDLETYPE hComponent, | ||
40 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
41 | |||
42 | void OMXH264VD_Set_StaticParams(OMX_HANDLETYPE hComponent, void *staticparams); | ||
43 | |||
44 | void OMXH264VD_Set_DynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams); | ||
45 | |||
46 | void OMXH264VD_Set_Status(OMX_HANDLETYPE hComponent, void *status); | ||
47 | |||
48 | OMX_ERRORTYPE OMXH264VD_HandleError(OMX_HANDLETYPE hComponent); | ||
49 | |||
50 | PaddedBuffParams CalculateH264VD_outbuff_details(OMX_HANDLETYPE hComponent, | ||
51 | OMX_U32 width, OMX_U32 height); | ||
52 | |||
53 | extern OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent); | ||
54 | extern void OMXH264VD_DeInit(OMX_HANDLETYPE hComponent); | ||
55 | extern OMX_U32 OMXH264VD_Calculate_TotalRefFrames(OMX_U32 nWidth, OMX_U32 nHeight, OMX_VIDEO_AVCLEVELTYPE eLevel); | ||
56 | |||
57 | typedef struct OMXH264VidDecComp { | ||
58 | OMX_VIDEO_PARAM_AVCTYPE tH264VideoParam; | ||
59 | } OMXH264VidDecComp; | ||
60 | |||
61 | |||
62 | #ifdef __cplusplus | ||
63 | } | ||
64 | #endif | ||
65 | |||
66 | #endif /* _OMX_H2644VD_NEW_H_ */ | ||
67 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_H264_VIDDEC" | ||
18 | |||
19 | #include <omx_h264vd.h> | ||
20 | #include <omx_video_decoder_internal.h> | ||
21 | |||
22 | #define OMX_MAX_DEC_OP_BUFFERS 20 | ||
23 | |||
24 | OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent) | ||
25 | { | ||
26 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
27 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
28 | OMXVidDecComp *pVidDecComp = NULL; | ||
29 | OMXH264VidDecComp *pH264VidDecComp = NULL; | ||
30 | IVIDDEC3_Params *pDecParams; | ||
31 | IH264VDEC_Params *params; | ||
32 | |||
33 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
34 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
35 | |||
36 | /*! Initialize the function parameters for OMX functions */ | ||
37 | pHandle->SetParameter = OMXH264VD_SetParameter; | ||
38 | pHandle->GetParameter = OMXH264VD_GetParameter; | ||
39 | |||
40 | /*! Initialize the function pointers */ | ||
41 | pVidDecComp->fpSet_StaticParams = OMXH264VD_Set_StaticParams; | ||
42 | pVidDecComp->fpSet_DynamicParams = OMXH264VD_Set_DynamicParams; | ||
43 | pVidDecComp->fpSet_Status = OMXH264VD_Set_Status; | ||
44 | pVidDecComp->fpCalc_OubuffDetails | ||
45 | = CalculateH264VD_outbuff_details; | ||
46 | pVidDecComp->fpDeinit_Codec = OMXH264VD_DeInit; | ||
47 | pVidDecComp->cDecoderName = "ivahd_h264dec"; | ||
48 | pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingAVC; | ||
49 | pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused; | ||
50 | pVidDecComp->fpHandle_ExtendedError = OMXH264VD_HandleError; | ||
51 | |||
52 | pVidDecComp->pCodecSpecific = | ||
53 | (OMXH264VidDecComp *) OSAL_Malloc(sizeof (OMXH264VidDecComp)); | ||
54 | OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources); | ||
55 | |||
56 | pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; | ||
57 | |||
58 | OMX_BASE_INIT_STRUCT_PTR(&(pH264VidDecComp->tH264VideoParam), OMX_VIDEO_PARAM_AVCTYPE); | ||
59 | pH264VidDecComp->tH264VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT; | ||
60 | pH264VidDecComp->tH264VideoParam.eProfile = OMX_VIDEO_AVCProfileHigh; | ||
61 | pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel41; | ||
62 | pH264VidDecComp->tH264VideoParam.nRefFrames = 0xFFFFFFFF; | ||
63 | |||
64 | /*! Allocate Memory for Static Parameter */ | ||
65 | pVidDecComp->pDecStaticParams | ||
66 | = (IVIDDEC3_Params *) memplugin_alloc(sizeof(IH264VDEC_Params), 1, MEM_CARVEOUT, 0, 0); | ||
67 | OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources); | ||
68 | OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IH264VDEC_Params)); | ||
69 | |||
70 | params = (IH264VDEC_Params *) (pVidDecComp->pDecStaticParams); | ||
71 | pDecParams = &(params->viddec3Params); | ||
72 | pDecParams->displayDelay = IVIDDEC3_DISPLAY_DELAY_AUTO; | ||
73 | params->presetLevelIdc = IH264VDEC_LEVEL41; | ||
74 | params->dpbSizeInFrames = IH264VDEC_DPB_NUMFRAMES_AUTO; | ||
75 | |||
76 | /*! Allocate Memory for Dynamic Parameter */ | ||
77 | pVidDecComp->pDecDynParams | ||
78 | = (IVIDDEC3_DynamicParams *) memplugin_alloc(sizeof(IH264VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0); | ||
79 | OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources); | ||
80 | OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IH264VDEC_DynamicParams)); | ||
81 | |||
82 | /*! Allocate Memory for Status Structure */ | ||
83 | pVidDecComp->pDecStatus | ||
84 | = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IH264VDEC_Status), 1, MEM_CARVEOUT, 0, 0); | ||
85 | OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources); | ||
86 | OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IH264VDEC_Status)); | ||
87 | ((IH264VDEC_Status *)pVidDecComp->pDecStatus)->spsMaxRefFrames = 1; | ||
88 | |||
89 | /*! Allocate Memory for Input Arguments */ | ||
90 | pVidDecComp->pDecInArgs | ||
91 | = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IH264VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0); | ||
92 | OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources); | ||
93 | OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IH264VDEC_InArgs)); | ||
94 | |||
95 | /*! Allocate Memory for Output Arguments */ | ||
96 | pVidDecComp->pDecOutArgs | ||
97 | = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IH264VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0); | ||
98 | OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources); | ||
99 | OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IH264VDEC_OutArgs)); | ||
100 | |||
101 | pVidDecComp->pDecInArgs->size = sizeof(IH264VDEC_InArgs); | ||
102 | pVidDecComp->pDecOutArgs->size = sizeof(IH264VDEC_OutArgs); | ||
103 | |||
104 | pDecParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE; | ||
105 | pDecParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE; | ||
106 | pDecParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE; | ||
107 | |||
108 | pDecParams->operatingMode = IVIDEO_DECODE_ONLY; | ||
109 | pDecParams->inputDataMode = IVIDEO_ENTIREFRAME; | ||
110 | pDecParams->numInputDataUnits = 0; | ||
111 | |||
112 | EXIT: | ||
113 | return (eError); | ||
114 | } | ||
115 | |||
116 | |||
117 | void OMXH264VD_Set_StaticParams(OMX_HANDLETYPE hComponent, void *staticparams) | ||
118 | { | ||
119 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
120 | OMXVidDecComp *pVidDecComp = NULL; | ||
121 | IVIDDEC3_Params *pDecParams; | ||
122 | IH264VDEC_Params *params = (IH264VDEC_Params *)staticparams; | ||
123 | |||
124 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
125 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
126 | |||
127 | pDecParams = &(params->viddec3Params); | ||
128 | pDecParams->size = sizeof(IH264VDEC_Params); | ||
129 | pDecParams->maxWidth = 1920; | ||
130 | pDecParams->maxHeight = 1088; | ||
131 | pDecParams->maxFrameRate = 30000; | ||
132 | pDecParams->maxBitRate = 10000000; | ||
133 | pDecParams->dataEndianness = XDM_BYTE; | ||
134 | |||
135 | /*init outArgs IVIDDEC3_OutArgs*/ | ||
136 | pDecParams->forceChromaFormat = XDM_YUV_420SP; | ||
137 | pDecParams->displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED; | ||
138 | pDecParams->outputDataMode = IVIDEO_ENTIREFRAME; | ||
139 | pDecParams->numOutputDataUnits = 0; | ||
140 | pDecParams->errorInfoMode = IVIDEO_ERRORINFO_OFF; | ||
141 | params->errConcealmentMode = | ||
142 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment; | ||
143 | |||
144 | params->temporalDirModePred = IH264VDEC_ENABLE_TEMPORALDIRECT; | ||
145 | params->debugTraceLevel= 0; | ||
146 | params->lastNFramesToLog= 0; | ||
147 | |||
148 | return; | ||
149 | } | ||
150 | |||
151 | |||
152 | void OMXH264VD_Set_DynamicParams(OMX_HANDLETYPE hComponent, void *dynParams) | ||
153 | { | ||
154 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
155 | OMXVidDecComp *pVidDecComp = NULL; | ||
156 | IVIDDEC3_DynamicParams *pDecDynParams; | ||
157 | IH264VDEC_DynamicParams *params = (IH264VDEC_DynamicParams *) dynParams; | ||
158 | |||
159 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
160 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
161 | pDecDynParams = &(params->viddec3DynamicParams); | ||
162 | pDecDynParams->size = sizeof(IVIDDEC3_DynamicParams); | ||
163 | |||
164 | /* init dynamic params IVIDDEC3_DynamicParams */ | ||
165 | pDecDynParams->decodeHeader = XDM_DECODE_AU; /* Supported */ | ||
166 | |||
167 | pDecDynParams->displayWidth = 0; /* Not Supported: Set default */ | ||
168 | /*Not Supported: Set default*/ | ||
169 | pDecDynParams->frameSkipMode = H264VD_DEFAULT_FRAME_SKIP; | ||
170 | pDecDynParams->newFrameFlag = XDAS_TRUE; //Not Supported: Set default | ||
171 | |||
172 | if( ((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) | ||
173 | { | ||
174 | pDecDynParams->putBufferFxn = NULL; | ||
175 | pDecDynParams->putBufferHandle = NULL; | ||
176 | pDecDynParams->putDataFxn = NULL; | ||
177 | pDecDynParams->putDataHandle = NULL; | ||
178 | pDecDynParams->getDataHandle = NULL; | ||
179 | pDecDynParams->getDataFxn = NULL; | ||
180 | } | ||
181 | |||
182 | return; | ||
183 | } | ||
184 | |||
185 | /**/ | ||
186 | void OMXH264VD_Set_Status(OMX_HANDLETYPE hComponent, void *decstatus) | ||
187 | { | ||
188 | IH264VDEC_Status *status; | ||
189 | (void)hComponent; | ||
190 | |||
191 | status = (IH264VDEC_Status *)decstatus; | ||
192 | status->viddec3Status.size = sizeof(IH264VDEC_Status); | ||
193 | return; | ||
194 | } | ||
195 | |||
196 | PaddedBuffParams CalculateH264VD_outbuff_details(OMX_HANDLETYPE hComponent, OMX_U32 width, OMX_U32 height) | ||
197 | { | ||
198 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
199 | OMXVidDecComp *pVidDecComp = NULL; | ||
200 | OMXH264VidDecComp *pH264VidDecComp = NULL; | ||
201 | OMX_U32 nRefBufferCount=16; | ||
202 | IH264VDEC_Status *pDecStatus = NULL; | ||
203 | IH264VDEC_Params *staticparams; | ||
204 | |||
205 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
206 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
207 | pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; | ||
208 | |||
209 | pDecStatus = (IH264VDEC_Status *)(pVidDecComp->pDecStatus); | ||
210 | |||
211 | PaddedBuffParams OutBuffDetails; | ||
212 | OutBuffDetails.nBufferSize | ||
213 | = ((((width + (2 * PADX) + 127) & 0xFFFFFF80) * (height + 4 * PADY))); | ||
214 | /* Multiply buffer size by 1.5 to account for both luma and chroma */ | ||
215 | OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1; | ||
216 | OutBuffDetails.nBufferCountMin = OMXH264VD_Calculate_TotalRefFrames(width, height, pH264VidDecComp->tH264VideoParam.eLevel); | ||
217 | staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams); | ||
218 | |||
219 | /* Assume 0 ref frames initially only if IL client is using port reconfig for allocating padded buffers. | ||
220 | * In that case use the correct ref frames at the time of port reconfig to calculate nBufferCountMin/Actual. | ||
221 | */ | ||
222 | if( pDecStatus->spsMaxRefFrames != 0 || pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { | ||
223 | if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) { | ||
224 | staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER; | ||
225 | } else { | ||
226 | staticparams->viddec3Params.displayDelay = pDecStatus->spsMaxRefFrames; | ||
227 | } | ||
228 | |||
229 | staticparams->dpbSizeInFrames = pDecStatus->spsMaxRefFrames; | ||
230 | pH264VidDecComp->tH264VideoParam.nRefFrames = pDecStatus->spsMaxRefFrames; | ||
231 | if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) { | ||
232 | /*Base profile*/ | ||
233 | OutBuffDetails.nBufferCountMin = pDecStatus->spsMaxRefFrames + 1; | ||
234 | } else { | ||
235 | /* High Profile */ | ||
236 | OutBuffDetails.nBufferCountMin = 2 * pDecStatus->spsMaxRefFrames + 1; | ||
237 | } | ||
238 | } else if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) { | ||
239 | if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) { | ||
240 | OutBuffDetails.nBufferCountMin = OMXH264VD_Calculate_TotalRefFrames | ||
241 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
242 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
243 | pH264VidDecComp->tH264VideoParam.eLevel); | ||
244 | } else { | ||
245 | nRefBufferCount = OMXH264VD_Calculate_TotalRefFrames | ||
246 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
247 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
248 | pH264VidDecComp->tH264VideoParam.eLevel) - 1; | ||
249 | if((2 * nRefBufferCount + 1) < OMX_MAX_DEC_OP_BUFFERS ) { | ||
250 | OutBuffDetails.nBufferCountMin = 2 * nRefBufferCount + 1; | ||
251 | } else { | ||
252 | OutBuffDetails.nBufferCountMin = OMX_MAX_DEC_OP_BUFFERS; //Cap max buffers to 20 | ||
253 | } | ||
254 | } | ||
255 | } else if( pH264VidDecComp->tH264VideoParam.nRefFrames <= 16 ) { | ||
256 | if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) { | ||
257 | OutBuffDetails.nBufferCountMin = pH264VidDecComp->tH264VideoParam.nRefFrames + 1; | ||
258 | } else { | ||
259 | OutBuffDetails.nBufferCountMin = 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1; | ||
260 | } | ||
261 | } | ||
262 | OutBuffDetails.nBufferCountActual = OutBuffDetails.nBufferCountMin + 2; | ||
263 | OutBuffDetails.n1DBufferAlignment = 16; | ||
264 | OutBuffDetails.nPaddedWidth = (width + (2 * PADX) + 127) & 0xFFFFFF80; | ||
265 | OutBuffDetails.nPaddedHeight = height + 4 * PADY; | ||
266 | OutBuffDetails.n2DBufferYAlignment = 1; | ||
267 | OutBuffDetails.n2DBufferXAlignment = 16; | ||
268 | |||
269 | return (OutBuffDetails); | ||
270 | } | ||
271 | |||
272 | |||
273 | void OMXH264VD_DeInit(OMX_HANDLETYPE hComponent) | ||
274 | { | ||
275 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
276 | OMXVidDecComp *pVidDecComp = NULL; | ||
277 | |||
278 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
279 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
280 | /*! Delete all the memory which was allocated during init of decoder */ | ||
281 | if( pVidDecComp->pDecStaticParams ) { | ||
282 | memplugin_free(pVidDecComp->pDecStaticParams); | ||
283 | pVidDecComp->pDecStaticParams = NULL; | ||
284 | } | ||
285 | if( pVidDecComp->pDecDynParams ) { | ||
286 | memplugin_free(pVidDecComp->pDecDynParams); | ||
287 | pVidDecComp->pDecDynParams = NULL; | ||
288 | } | ||
289 | if( pVidDecComp->pDecStatus ) { | ||
290 | memplugin_free(pVidDecComp->pDecStatus); | ||
291 | pVidDecComp->pDecStatus = NULL; | ||
292 | } | ||
293 | if( pVidDecComp->pDecInArgs ) { | ||
294 | memplugin_free(pVidDecComp->pDecInArgs); | ||
295 | pVidDecComp->pDecInArgs = NULL; | ||
296 | } | ||
297 | if( pVidDecComp->pDecOutArgs ) { | ||
298 | memplugin_free(pVidDecComp->pDecOutArgs); | ||
299 | pVidDecComp->pDecOutArgs = NULL; | ||
300 | } | ||
301 | if( pVidDecComp->pCodecSpecific ) { | ||
302 | OSAL_Free(pVidDecComp->pCodecSpecific); | ||
303 | pVidDecComp->pCodecSpecific = NULL; | ||
304 | } | ||
305 | pHandle->SetParameter = OMXVidDec_SetParameter; | ||
306 | pHandle->GetParameter = OMXVidDec_GetParameter; | ||
307 | pVidDecComp->fpHandle_ExtendedError = NULL; | ||
308 | } | ||
309 | |||
310 | |||
311 | OMX_U32 OMXH264VD_Calculate_TotalRefFrames(OMX_U32 nWidth, OMX_U32 nHeight, OMX_VIDEO_AVCLEVELTYPE eLevel) | ||
312 | { | ||
313 | OMX_U32 ref_frames = 0; | ||
314 | OMX_U32 MaxDpbMbs; | ||
315 | OMX_U32 PicWidthInMbs; | ||
316 | OMX_U32 FrameHeightInMbs; | ||
317 | |||
318 | switch( eLevel ) { | ||
319 | case OMX_VIDEO_AVCLevel1 : | ||
320 | case OMX_VIDEO_AVCLevel1b : | ||
321 | { | ||
322 | MaxDpbMbs = 396; | ||
323 | break; | ||
324 | } | ||
325 | |||
326 | case OMX_VIDEO_AVCLevel11 : | ||
327 | { | ||
328 | MaxDpbMbs = 900; | ||
329 | break; | ||
330 | } | ||
331 | |||
332 | case OMX_VIDEO_AVCLevel12 : | ||
333 | case OMX_VIDEO_AVCLevel13 : | ||
334 | case OMX_VIDEO_AVCLevel2 : | ||
335 | { | ||
336 | MaxDpbMbs = 2376; | ||
337 | break; | ||
338 | } | ||
339 | |||
340 | case OMX_VIDEO_AVCLevel21 : | ||
341 | { | ||
342 | MaxDpbMbs = 4752; | ||
343 | break; | ||
344 | } | ||
345 | |||
346 | case OMX_VIDEO_AVCLevel22 : | ||
347 | case OMX_VIDEO_AVCLevel3 : | ||
348 | { | ||
349 | MaxDpbMbs = 8100; | ||
350 | break; | ||
351 | } | ||
352 | |||
353 | case OMX_VIDEO_AVCLevel31 : | ||
354 | { | ||
355 | MaxDpbMbs = 18000; | ||
356 | break; | ||
357 | } | ||
358 | |||
359 | case OMX_VIDEO_AVCLevel32 : | ||
360 | { | ||
361 | MaxDpbMbs = 20480; | ||
362 | break; | ||
363 | } | ||
364 | |||
365 | case OMX_VIDEO_AVCLevel5 : | ||
366 | { | ||
367 | MaxDpbMbs = 110400; //Maximum value for upto level 5 | ||
368 | break; | ||
369 | } | ||
370 | |||
371 | case OMX_VIDEO_AVCLevel51 : | ||
372 | { | ||
373 | MaxDpbMbs = 184320; //Maximum value for upto level 5.1 | ||
374 | break; | ||
375 | } | ||
376 | |||
377 | default : | ||
378 | { | ||
379 | MaxDpbMbs = 32768; //Maximum value for upto level 4.1 | ||
380 | } | ||
381 | } | ||
382 | |||
383 | PicWidthInMbs = nWidth / 16; | ||
384 | FrameHeightInMbs = nHeight / 16; | ||
385 | ref_frames = (OMX_U32)(MaxDpbMbs / (PicWidthInMbs * FrameHeightInMbs)); | ||
386 | |||
387 | ref_frames = (ref_frames > 16) ? 16 : ref_frames; | ||
388 | |||
389 | /* Three is added to total reference frames because of the N+3 buffer issue | ||
390 | * It was found that theoretically 2N+1 buffers are required but from a practical | ||
391 | * point of view N+3 was sufficient */ | ||
392 | return (ref_frames + 1); | ||
393 | } | ||
394 | |||
395 | |||
396 | OMX_ERRORTYPE OMXH264VD_SetParameter(OMX_HANDLETYPE hComponent, | ||
397 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) | ||
398 | { | ||
399 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
400 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
401 | OMXVidDecComp *pVidDecComp = NULL; | ||
402 | OMXH264VidDecComp *pH264VidDecComp = NULL; | ||
403 | OMX_VIDEO_PARAM_AVCTYPE *pH264VideoParam = NULL; | ||
404 | OMX_U32 nRefBufferCount = 0; | ||
405 | OMX_U8 i; | ||
406 | IH264VDEC_Params *staticparams; | ||
407 | |||
408 | OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), | ||
409 | OMX_ErrorBadParameter); | ||
410 | |||
411 | /*! Initialize the pointers */ | ||
412 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
413 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
414 | pH264VidDecComp = (OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; | ||
415 | staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams); | ||
416 | |||
417 | switch( nIndex ) { | ||
418 | case OMX_IndexParamVideoAvc : | ||
419 | { | ||
420 | pH264VideoParam = (OMX_VIDEO_PARAM_AVCTYPE *) pParamStruct; | ||
421 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
422 | OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || | ||
423 | (pVidDecComp->sBase.pPorts[pH264VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), | ||
424 | OMX_ErrorIncorrectStateOperation); | ||
425 | |||
426 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError); | ||
427 | OMX_CHECK(pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline | ||
428 | || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileMain | ||
429 | || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileExtended | ||
430 | || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileHigh, | ||
431 | OMX_ErrorUnsupportedSetting); | ||
432 | OMX_CHECK(pH264VideoParam->eLevel <= OMX_VIDEO_AVCLevel51, | ||
433 | OMX_ErrorUnsupportedSetting); | ||
434 | if( pH264VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
435 | pH264VidDecComp->tH264VideoParam = *pH264VideoParam; | ||
436 | } else if( pH264VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
437 | OSAL_ErrorTrace("OMX_IndexParamVideoAvc supported only on i/p port"); | ||
438 | eError = OMX_ErrorUnsupportedIndex; | ||
439 | goto EXIT; | ||
440 | } else { | ||
441 | eError = OMX_ErrorBadPortIndex; | ||
442 | } | ||
443 | ALOGE("Profile set = %x, Level Set = %x, num ref frames set = %d", | ||
444 | pH264VideoParam->eProfile, pH264VideoParam->eLevel, pH264VideoParam->nRefFrames); | ||
445 | if( pH264VideoParam->eLevel == OMX_VIDEO_AVCLevel5 ) { | ||
446 | staticparams->presetLevelIdc = IH264VDEC_LEVEL5; | ||
447 | } else if( pH264VideoParam->eLevel == OMX_VIDEO_AVCLevel51 ) { | ||
448 | staticparams->presetLevelIdc = IH264VDEC_LEVEL51; | ||
449 | } | ||
450 | if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) { | ||
451 | if( pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline ) { | ||
452 | staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER; | ||
453 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin = | ||
454 | OMXH264VD_Calculate_TotalRefFrames( | ||
455 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
456 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
457 | pH264VideoParam->eLevel); | ||
458 | } else { | ||
459 | nRefBufferCount = OMXH264VD_Calculate_TotalRefFrames | ||
460 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
461 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
462 | pH264VideoParam->eLevel) - 1; | ||
463 | |||
464 | if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) { | ||
465 | staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER; | ||
466 | } else { | ||
467 | staticparams->viddec3Params.displayDelay = nRefBufferCount; | ||
468 | } | ||
469 | |||
470 | if((2 * nRefBufferCount + 1) < OMX_MAX_DEC_OP_BUFFERS ) { | ||
471 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin | ||
472 | = 2 * nRefBufferCount + 1; | ||
473 | } else { | ||
474 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin | ||
475 | = OMX_MAX_DEC_OP_BUFFERS; //Cap max buffers to 20 | ||
476 | } | ||
477 | } | ||
478 | } else if( pH264VidDecComp->tH264VideoParam.nRefFrames <= 16 ) { | ||
479 | staticparams->dpbSizeInFrames = pH264VidDecComp->tH264VideoParam.nRefFrames; | ||
480 | if( pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline ) { | ||
481 | staticparams->viddec3Params.displayDelay | ||
482 | = IVIDDEC3_DECODE_ORDER; | ||
483 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin | ||
484 | = pH264VidDecComp->tH264VideoParam.nRefFrames + 1; | ||
485 | } else { | ||
486 | if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) { | ||
487 | staticparams->viddec3Params.displayDelay | ||
488 | = IVIDDEC3_DECODE_ORDER; | ||
489 | } else { | ||
490 | staticparams->viddec3Params.displayDelay | ||
491 | = pH264VidDecComp->tH264VideoParam.nRefFrames; | ||
492 | } | ||
493 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin = | ||
494 | 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1; | ||
495 | } | ||
496 | } else { | ||
497 | OSAL_ErrorTrace("Invalid value of nRefFrames = %d of the structure OMX_VIDEO_PARAM_AVCTYPE provided ", | ||
498 | pH264VidDecComp->tH264VideoParam.nRefFrames); | ||
499 | } | ||
500 | } | ||
501 | break; | ||
502 | |||
503 | case OMX_IndexParamVideoProfileLevelQuerySupported : | ||
504 | { | ||
505 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
506 | OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, | ||
507 | OMX_ErrorIncorrectStateOperation); | ||
508 | /* Check for the correct nSize & nVersion information */ | ||
509 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
510 | /*As of now do nothing. This i ndex is required for StdVideoDecoderTest. Later on do code review and fill in proper code here.*/ | ||
511 | eError = OMX_ErrorNoMore; | ||
512 | } | ||
513 | break; | ||
514 | |||
515 | case OMX_IndexParamVideoProfileLevelCurrent : | ||
516 | { | ||
517 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
518 | OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, | ||
519 | OMX_ErrorIncorrectStateOperation); | ||
520 | /* Check for the correct nSize & nVersion information */ | ||
521 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
522 | /*As of now do nothing. This index is required for StdVideoDecoderTest. Later on do code review and fill in proper code here.*/ | ||
523 | eError = OMX_ErrorNoMore; | ||
524 | } | ||
525 | break; | ||
526 | |||
527 | default : | ||
528 | eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct); | ||
529 | } | ||
530 | |||
531 | EXIT: | ||
532 | return (eError); | ||
533 | } | ||
534 | |||
535 | |||
536 | OMX_ERRORTYPE OMXH264VD_GetParameter(OMX_HANDLETYPE hComponent, | ||
537 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) | ||
538 | { | ||
539 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
540 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
541 | OMXVidDecComp *pVidDecComp = NULL; | ||
542 | OMXH264VidDecComp *pH264VidDecComp = NULL; | ||
543 | OMX_VIDEO_PARAM_AVCTYPE *pH264VideoParam = NULL; | ||
544 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pH264ProfileLevelParam = NULL; | ||
545 | |||
546 | |||
547 | OMX_CHECK((hComponent != NULL) && | ||
548 | (pParamStruct != NULL), OMX_ErrorBadParameter); | ||
549 | |||
550 | // Initialize the local variables | ||
551 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
552 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
553 | |||
554 | pH264VidDecComp = (OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; | ||
555 | |||
556 | /* GetParameter can't be invoked incase the comp is in Invalid State */ | ||
557 | OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, | ||
558 | OMX_ErrorIncorrectStateOperation); | ||
559 | |||
560 | switch( nIndex ) { | ||
561 | case OMX_IndexParamVideoAvc : | ||
562 | { | ||
563 | pH264VideoParam = (OMX_VIDEO_PARAM_AVCTYPE *) pParamStruct; | ||
564 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError); | ||
565 | if( pH264VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
566 | *pH264VideoParam = pH264VidDecComp->tH264VideoParam; | ||
567 | } else if( pH264VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
568 | OSAL_ErrorTrace("OMX_IndexParamVideoAvc supported only on i/p port"); | ||
569 | eError = OMX_ErrorUnsupportedIndex; | ||
570 | } else { | ||
571 | eError = OMX_ErrorBadPortIndex; | ||
572 | } | ||
573 | } | ||
574 | break; | ||
575 | |||
576 | case OMX_IndexParamVideoProfileLevelQuerySupported : | ||
577 | { | ||
578 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
579 | pH264ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct; | ||
580 | if( pH264ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
581 | if( pH264ProfileLevelParam->nProfileIndex == 0 ) { | ||
582 | pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileBaseline; | ||
583 | pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41; | ||
584 | } else if( pH264ProfileLevelParam->nProfileIndex == 1 ) { | ||
585 | pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileMain; | ||
586 | pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41; | ||
587 | } else if( pH264ProfileLevelParam->nProfileIndex == 2 ) { | ||
588 | pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileHigh; | ||
589 | pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41; | ||
590 | } else { | ||
591 | eError = OMX_ErrorNoMore; | ||
592 | } | ||
593 | } else if( pH264ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
594 | OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port"); | ||
595 | eError = OMX_ErrorUnsupportedIndex; | ||
596 | } else { | ||
597 | eError = OMX_ErrorBadPortIndex; | ||
598 | } | ||
599 | } | ||
600 | break; | ||
601 | |||
602 | case OMX_IndexParamVideoProfileLevelCurrent : | ||
603 | { | ||
604 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
605 | eError = OMX_ErrorNoMore; | ||
606 | } | ||
607 | break; | ||
608 | |||
609 | case OMX_IndexParamVideoMacroblocksPerFrame : | ||
610 | { | ||
611 | OMX_U32 MBwidth = 0, MBheight = 0; | ||
612 | /* Check for the correct nSize & nVersion information */ | ||
613 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_MACROBLOCKSTYPE, eError); | ||
614 | MBwidth = (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth) / 16; | ||
615 | MBwidth = MBwidth + ((pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth) % 16); | ||
616 | MBheight = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight / 16; | ||
617 | MBheight = MBheight + ((pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight) % 16); | ||
618 | ((OMX_PARAM_MACROBLOCKSTYPE *)(pParamStruct))->nMacroblocks = MBwidth * MBheight; | ||
619 | } | ||
620 | break; | ||
621 | |||
622 | default : | ||
623 | eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct); | ||
624 | } | ||
625 | |||
626 | EXIT: | ||
627 | return (eError); | ||
628 | } | ||
629 | |||
630 | /* */ | ||
631 | OMX_ERRORTYPE OMXH264VD_HandleError(OMX_HANDLETYPE hComponent) | ||
632 | { | ||
633 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
634 | OMX_U32 nRefFramesOld, nRefFrames41, nRefFrames5; | ||
635 | OMXH264VidDecComp *pH264VidDecComp = NULL; | ||
636 | IH264VDEC_Params *staticparams = NULL; | ||
637 | IH264VDEC_Status *pDecStatus = NULL; | ||
638 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
639 | OMXVidDecComp *pVidDecComp = NULL; | ||
640 | OMX_U32 nBufferCountMin_old = 0; | ||
641 | |||
642 | /* Initialize pointers */ | ||
643 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
644 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
645 | staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams); | ||
646 | pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific; | ||
647 | |||
648 | pDecStatus = (IH264VDEC_Status *)(pVidDecComp->pDecStatus); | ||
649 | if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) { | ||
650 | nRefFramesOld = OMXH264VD_Calculate_TotalRefFrames | ||
651 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
652 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
653 | pH264VidDecComp->tH264VideoParam.eLevel) - 1; | ||
654 | } else { | ||
655 | nRefFramesOld = pH264VidDecComp->tH264VideoParam.nRefFrames; | ||
656 | } | ||
657 | nRefFrames41 = OMXH264VD_Calculate_TotalRefFrames | ||
658 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
659 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
660 | OMX_VIDEO_AVCLevel41) - 1; | ||
661 | nRefFrames5 = OMXH264VD_Calculate_TotalRefFrames | ||
662 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
663 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
664 | OMX_VIDEO_AVCLevel5) - 1; | ||
665 | nBufferCountMin_old = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin; | ||
666 | if( pDecStatus->spsMaxRefFrames > nRefFramesOld ) { | ||
667 | ALOGE("spsMaxRefFrames = %d, nRefFrames set initially = %d", | ||
668 | (OMX_U32)pDecStatus->spsMaxRefFrames, pH264VidDecComp->tH264VideoParam.nRefFrames); | ||
669 | pH264VidDecComp->tH264VideoParam.nRefFrames | ||
670 | = pDecStatus->spsMaxRefFrames; | ||
671 | staticparams->dpbSizeInFrames | ||
672 | = pDecStatus->spsMaxRefFrames; | ||
673 | staticparams->viddec3Params.displayDelay | ||
674 | = pDecStatus->spsMaxRefFrames; | ||
675 | if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) { | ||
676 | staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER; | ||
677 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin | ||
678 | = pH264VidDecComp->tH264VideoParam.nRefFrames + 1; | ||
679 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountActual | ||
680 | = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin + 2; | ||
681 | } else { | ||
682 | if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) { | ||
683 | staticparams->viddec3Params.displayDelay | ||
684 | = IVIDDEC3_DECODE_ORDER; | ||
685 | } else { | ||
686 | staticparams->viddec3Params.displayDelay = pDecStatus->spsMaxRefFrames; | ||
687 | } | ||
688 | |||
689 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin | ||
690 | = 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1; | ||
691 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountActual | ||
692 | = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin + 2; | ||
693 | } | ||
694 | if( pDecStatus->spsMaxRefFrames > nRefFrames5 ) { | ||
695 | pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel51; | ||
696 | staticparams->presetLevelIdc = IH264VDEC_LEVEL51; | ||
697 | OSAL_ErrorTrace("Resetting level of the stream to Level 5.1"); | ||
698 | pVidDecComp->nCodecRecreationRequired = 1; | ||
699 | pVidDecComp->nOutPortReconfigRequired = 1; | ||
700 | } else if( pDecStatus->spsMaxRefFrames > nRefFrames41 ) { | ||
701 | pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel5; | ||
702 | staticparams->presetLevelIdc = IH264VDEC_LEVEL5; | ||
703 | OSAL_ErrorTrace("Resetting level of the stream to Level 5"); | ||
704 | pVidDecComp->nCodecRecreationRequired = 1; | ||
705 | pVidDecComp->nOutPortReconfigRequired = 1; | ||
706 | } else if( pDecStatus->spsMaxRefFrames > nRefFramesOld ) { | ||
707 | pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel41; | ||
708 | OSAL_ErrorTrace("Resetting level of the stream to Level 4.1"); | ||
709 | } | ||
710 | if( pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin | ||
711 | > nBufferCountMin_old ) { | ||
712 | OSAL_ErrorTrace("nBufferCountMin_old = %d, nBufferCountMin_new = %d", | ||
713 | nBufferCountMin_old, pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin); | ||
714 | pVidDecComp->nOutPortReconfigRequired = 1; | ||
715 | pVidDecComp->nCodecRecreationRequired = 1; | ||
716 | } | ||
717 | } | ||
718 | |||
719 | return (eError); | ||
720 | } | ||
721 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_MPEG2DEC_H_ | ||
18 | #define _OMX_MPEG2DEC_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif /* __cplusplus */ | ||
23 | |||
24 | /****************************************************************** | ||
25 | * INCLUDE FILES | ||
26 | ******************************************************************/ | ||
27 | #include <omx_video_decoder.h> | ||
28 | #include <ti/sdo/codecs/mpeg2vdec/impeg2vdec.h> | ||
29 | |||
30 | |||
31 | void OMXMPEG2VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams); | ||
32 | |||
33 | void OMXMPEG2VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams); | ||
34 | |||
35 | void OMXMPEG2VD_SetStatus(OMX_HANDLETYPE hComponent, void *status); | ||
36 | |||
37 | PaddedBuffParams CalculateMPEG2VD_outbuff_details(OMX_HANDLETYPE hComponent, | ||
38 | OMX_U32 width, OMX_U32 height); | ||
39 | |||
40 | /*---------- function prototypes ------------------- */ | ||
41 | extern OMX_ERRORTYPE OMX_TI_VideoDecoder_ComponentInit(OMX_HANDLETYPE hComponent); | ||
42 | OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent); | ||
43 | void OMXMPEG2VD_DeInit(OMX_HANDLETYPE hComponent); | ||
44 | OMX_ERRORTYPE OMXMPEG2VD_HandleError(OMX_HANDLETYPE hComponent); | ||
45 | |||
46 | extern OMX_ERRORTYPE OMXMPEG2VD_SetParameter(OMX_HANDLETYPE hComponent, | ||
47 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
48 | extern OMX_ERRORTYPE OMXMPEG2VD_GetParameter(OMX_HANDLETYPE hComponent, | ||
49 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
50 | |||
51 | extern OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent, | ||
52 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
53 | extern OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent, | ||
54 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
55 | |||
56 | |||
57 | typedef struct OMXMPEG2VidDecComp { | ||
58 | OMX_PARAM_DEBLOCKINGTYPE tDeblockingParam; | ||
59 | OMX_VIDEO_PARAM_MPEG2TYPE tMPEG2VideoParam; | ||
60 | } OMXMPEG2VidDecComp; | ||
61 | |||
62 | |||
63 | #ifdef __cplusplus | ||
64 | } | ||
65 | #endif /* __cplusplus */ | ||
66 | |||
67 | #endif /* _OMX_MPEG2DEC_H_ */ | ||
68 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_MPEG2_VIDDEC" | ||
18 | |||
19 | #include <omx_mpeg2dec.h> | ||
20 | |||
21 | |||
22 | OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent) | ||
23 | { | ||
24 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
25 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
26 | OMXVidDecComp *pVidDecComp = NULL; | ||
27 | OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL; | ||
28 | |||
29 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
30 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
31 | |||
32 | /*! Initialize the function parameters for OMX functions */ | ||
33 | pHandle->SetParameter = OMXMPEG2VD_SetParameter; | ||
34 | pHandle->GetParameter = OMXMPEG2VD_GetParameter; | ||
35 | |||
36 | /*! Initialize the function pointers */ | ||
37 | pVidDecComp->fpSet_StaticParams = OMXMPEG2VD_SetStaticParams; | ||
38 | pVidDecComp->fpSet_DynamicParams = OMXMPEG2VD_SetDynamicParams; | ||
39 | pVidDecComp->fpSet_Status = OMXMPEG2VD_SetStatus; | ||
40 | pVidDecComp->fpCalc_OubuffDetails = CalculateMPEG2VD_outbuff_details; | ||
41 | pVidDecComp->fpDeinit_Codec = OMXMPEG2VD_DeInit; | ||
42 | pVidDecComp->cDecoderName = "ivahd_mpeg2vdec"; | ||
43 | |||
44 | pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingMPEG2; | ||
45 | pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused; | ||
46 | |||
47 | pVidDecComp->fpHandle_ExtendedError = OMXMPEG2VD_HandleError; | ||
48 | |||
49 | pVidDecComp->pCodecSpecific = | ||
50 | (OMXMPEG2VidDecComp *) OSAL_Malloc(sizeof (OMXMPEG2VidDecComp)); | ||
51 | OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources); | ||
52 | |||
53 | pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific; | ||
54 | |||
55 | OMX_BASE_INIT_STRUCT_PTR(&(pMPEG2VidDecComp->tDeblockingParam), OMX_PARAM_DEBLOCKINGTYPE); | ||
56 | pMPEG2VidDecComp->tDeblockingParam.nPortIndex = OMX_VIDDEC_OUTPUT_PORT; | ||
57 | pMPEG2VidDecComp->tDeblockingParam.bDeblocking = OMX_FALSE; | ||
58 | |||
59 | |||
60 | OMX_BASE_INIT_STRUCT_PTR(&(pMPEG2VidDecComp->tMPEG2VideoParam), OMX_VIDEO_PARAM_MPEG2TYPE); | ||
61 | pMPEG2VidDecComp->tMPEG2VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT; | ||
62 | pMPEG2VidDecComp->tMPEG2VideoParam.eProfile = OMX_VIDEO_MPEG2ProfileMain; | ||
63 | pMPEG2VidDecComp->tMPEG2VideoParam.eLevel = OMX_VIDEO_MPEG2LevelML; | ||
64 | |||
65 | /*! Allocate Memory for Static Parameter */ | ||
66 | pVidDecComp->pDecStaticParams = (IVIDDEC3_Params *)memplugin_alloc(sizeof(IMPEG2VDEC_Params), 1, MEM_CARVEOUT, 0, 0); | ||
67 | OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources); | ||
68 | OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IMPEG2VDEC_Params)); | ||
69 | |||
70 | /*! Allocate Memory for Dynamic Parameter */ | ||
71 | pVidDecComp->pDecDynParams = (IVIDDEC3_DynamicParams *)memplugin_alloc(sizeof(IMPEG2VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0); | ||
72 | OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources); | ||
73 | OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IMPEG2VDEC_DynamicParams)); | ||
74 | |||
75 | /*! Allocate Memory for Status Structure */ | ||
76 | pVidDecComp->pDecStatus = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IMPEG2VDEC_Status), 1, MEM_CARVEOUT, 0, 0); | ||
77 | OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources); | ||
78 | OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IMPEG2VDEC_Status)); | ||
79 | |||
80 | /*! Allocate Memory for Input Arguments */ | ||
81 | pVidDecComp->pDecInArgs = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IMPEG2VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0); | ||
82 | OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources); | ||
83 | OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IMPEG2VDEC_InArgs)); | ||
84 | |||
85 | /*! Allocate Memory for Output Arguments */ | ||
86 | pVidDecComp->pDecOutArgs = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IMPEG2VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0); | ||
87 | OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources); | ||
88 | OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IMPEG2VDEC_OutArgs)); | ||
89 | |||
90 | pVidDecComp->pDecInArgs->size = sizeof(IMPEG2VDEC_InArgs); | ||
91 | pVidDecComp->pDecOutArgs->size = sizeof(IMPEG2VDEC_OutArgs); | ||
92 | |||
93 | pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE; | ||
94 | pVidDecComp->pDecStaticParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE; | ||
95 | pVidDecComp->pDecStaticParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE; | ||
96 | |||
97 | pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_DECODE_ONLY; //IVIDEO_TRANSCODE_FRAMELEVEL; // | ||
98 | |||
99 | pVidDecComp->pDecStaticParams->inputDataMode = IVIDEO_ENTIREFRAME; | ||
100 | pVidDecComp->pDecStaticParams->numInputDataUnits = 0; | ||
101 | |||
102 | |||
103 | EXIT: | ||
104 | return (eError); | ||
105 | |||
106 | } | ||
107 | |||
108 | void OMXMPEG2VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams) | ||
109 | { | ||
110 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
111 | OMXVidDecComp *pVidDecComp = NULL; | ||
112 | OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL; | ||
113 | OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; | ||
114 | IMPEG2VDEC_Params *params; | ||
115 | |||
116 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
117 | pVidDecComp | ||
118 | = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
119 | p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]); | ||
120 | |||
121 | pMPEG2VidDecComp = | ||
122 | (OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific; | ||
123 | |||
124 | params = (IMPEG2VDEC_Params *) staticparams; | ||
125 | |||
126 | params->viddecParams.size = sizeof(IMPEG2VDEC_Params); | ||
127 | |||
128 | params->viddecParams.maxWidth = p2DOutBufAllocParam->nWidth; | ||
129 | |||
130 | params->viddecParams.maxFrameRate = 30000; | ||
131 | |||
132 | params->viddecParams.maxBitRate = 10000000; | ||
133 | |||
134 | params->viddecParams.dataEndianness = XDM_BYTE; | ||
135 | params->viddecParams.forceChromaFormat = XDM_YUV_420SP; | ||
136 | params->viddecParams.displayDelay = IVIDDEC3_DISPLAY_DELAY_1; | ||
137 | params->viddecParams.inputDataMode = IVIDEO_ENTIREFRAME; | ||
138 | params->viddecParams.numInputDataUnits = 0; | ||
139 | params->viddecParams.numOutputDataUnits = 0; | ||
140 | params->viddecParams.outputDataMode = IVIDEO_ENTIREFRAME; | ||
141 | params->viddecParams.displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED; | ||
142 | |||
143 | params->viddecParams.errorInfoMode = IVIDEO_ERRORINFO_OFF; | ||
144 | |||
145 | params->outloopDeBlocking = pMPEG2VidDecComp->tDeblockingParam.bDeblocking; | ||
146 | params->ErrorConcealmentON = pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment; | ||
147 | /* If ErrorConcealmentON, then metadata[0] should be set to IVIDEO_METADATAPLANE_MBINFO */ | ||
148 | if (params->ErrorConcealmentON) { | ||
149 | pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_MBINFO; | ||
150 | pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_TRANSCODE_FRAMELEVEL; | ||
151 | } | ||
152 | |||
153 | params->debugTraceLevel= 0; | ||
154 | params->lastNFramesToLog= 0; | ||
155 | |||
156 | return; | ||
157 | } | ||
158 | |||
159 | |||
160 | void OMXMPEG2VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynParams) | ||
161 | { | ||
162 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
163 | OMXVidDecComp *pVidDecComp = NULL; | ||
164 | OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; | ||
165 | IMPEG2VDEC_DynamicParams *dynamicParams; | ||
166 | |||
167 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
168 | pVidDecComp | ||
169 | = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
170 | p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]); | ||
171 | dynamicParams = (IMPEG2VDEC_DynamicParams *)dynParams; | ||
172 | |||
173 | /*! Update the Individual fields in the Dyanmic Params of MPEG2 decoder */ | ||
174 | dynamicParams->viddecDynamicParams.size = sizeof(IMPEG2VDEC_DynamicParams); | ||
175 | dynamicParams->viddecDynamicParams.decodeHeader = XDM_DECODE_AU; | ||
176 | dynamicParams->viddecDynamicParams.displayWidth = p2DOutBufAllocParam->nWidth; | ||
177 | dynamicParams->viddecDynamicParams.frameSkipMode = IVIDEO_NO_SKIP; | ||
178 | dynamicParams->viddecDynamicParams.newFrameFlag = XDAS_TRUE; | ||
179 | dynamicParams->viddecDynamicParams.putDataFxn = NULL; | ||
180 | dynamicParams->viddecDynamicParams.putDataHandle = NULL; | ||
181 | dynamicParams->viddecDynamicParams.getDataFxn = NULL; | ||
182 | dynamicParams->viddecDynamicParams.getDataHandle = NULL; | ||
183 | dynamicParams->viddecDynamicParams.putBufferFxn = NULL; | ||
184 | dynamicParams->viddecDynamicParams.putBufferHandle = NULL; | ||
185 | dynamicParams->viddecDynamicParams.lateAcquireArg = IRES_HDVICP2_UNKNOWNLATEACQUIREARG; | ||
186 | return; | ||
187 | } | ||
188 | |||
189 | |||
190 | void OMXMPEG2VD_SetStatus(OMX_HANDLETYPE hComponent, void *decstatus) | ||
191 | { | ||
192 | IMPEG2VDEC_Status *status; | ||
193 | (void)hComponent; | ||
194 | |||
195 | status = (IMPEG2VDEC_Status *)decstatus; | ||
196 | |||
197 | status->viddecStatus.size = sizeof(IMPEG2VDEC_Status); | ||
198 | return; | ||
199 | } | ||
200 | |||
201 | |||
202 | PaddedBuffParams CalculateMPEG2VD_outbuff_details(OMX_HANDLETYPE hComponent, | ||
203 | OMX_U32 width, OMX_U32 height) | ||
204 | { | ||
205 | PaddedBuffParams OutBuffDetails; | ||
206 | (void)hComponent; | ||
207 | |||
208 | /* OutBuffDetails.nBufferSize | ||
209 | = ((((width + PADX + 127) & ~127) * (height + PADY))); */ | ||
210 | /* The 2 additional rows and columns are required as per codec request to boost performance. */ | ||
211 | OutBuffDetails.nBufferSize | ||
212 | = ((((width + 127) & ~127) + 2) * (height + 2)); | ||
213 | /* Multiply buffer size by 1.5 to account for both luma and chroma */ | ||
214 | OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1; | ||
215 | |||
216 | OutBuffDetails.nBufferCountMin = 4; | ||
217 | OutBuffDetails.nBufferCountActual = 8; | ||
218 | OutBuffDetails.n1DBufferAlignment = 16; | ||
219 | //OutBuffDetails.nPaddedWidth = (width + PADX + 127) & ~127; | ||
220 | //OutBuffDetails.nPaddedHeight = height + PADY; | ||
221 | OutBuffDetails.nPaddedWidth = (width + 127) & ~127; | ||
222 | OutBuffDetails.nPaddedHeight = height; | ||
223 | OutBuffDetails.n2DBufferYAlignment = 1; | ||
224 | OutBuffDetails.n2DBufferXAlignment = 16; | ||
225 | |||
226 | return (OutBuffDetails); | ||
227 | } | ||
228 | |||
229 | |||
230 | void OMXMPEG2VD_DeInit(OMX_HANDLETYPE hComponent) | ||
231 | { | ||
232 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
233 | OMXVidDecComp *pVidDecComp = NULL; | ||
234 | |||
235 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
236 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
237 | /*! Delete all the memory which was allocated during init of decoder */ | ||
238 | if( pVidDecComp->pDecStaticParams ) { | ||
239 | memplugin_free(pVidDecComp->pDecStaticParams); | ||
240 | pVidDecComp->pDecStaticParams = NULL; | ||
241 | } | ||
242 | if( pVidDecComp->pDecDynParams ) { | ||
243 | memplugin_free(pVidDecComp->pDecDynParams); | ||
244 | pVidDecComp->pDecDynParams = NULL; | ||
245 | } | ||
246 | if( pVidDecComp->pDecStatus ) { | ||
247 | memplugin_free(pVidDecComp->pDecStatus); | ||
248 | pVidDecComp->pDecStatus = NULL; | ||
249 | } | ||
250 | if( pVidDecComp->pDecInArgs ) { | ||
251 | memplugin_free(pVidDecComp->pDecInArgs); | ||
252 | pVidDecComp->pDecInArgs = NULL; | ||
253 | } | ||
254 | if( pVidDecComp->pDecOutArgs ) { | ||
255 | memplugin_free(pVidDecComp->pDecOutArgs); | ||
256 | pVidDecComp->pDecOutArgs = NULL; | ||
257 | } | ||
258 | if( pVidDecComp->pCodecSpecific ) { | ||
259 | OSAL_Free(pVidDecComp->pCodecSpecific); | ||
260 | pVidDecComp->pCodecSpecific = NULL; | ||
261 | } | ||
262 | pHandle->SetParameter = OMXVidDec_SetParameter; | ||
263 | pHandle->GetParameter = OMXVidDec_GetParameter; | ||
264 | pVidDecComp->fpHandle_ExtendedError = NULL; | ||
265 | } | ||
266 | |||
267 | OMX_ERRORTYPE OMXMPEG2VD_SetParameter(OMX_HANDLETYPE hComponent, | ||
268 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) | ||
269 | { | ||
270 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
271 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
272 | OMXVidDecComp *pVidDecComp = NULL; | ||
273 | OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL; | ||
274 | OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL; | ||
275 | OMX_VIDEO_PARAM_MPEG2TYPE *pMPEG2VideoParam = NULL; | ||
276 | |||
277 | OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), | ||
278 | OMX_ErrorBadParameter); | ||
279 | |||
280 | /*! Initialize the pointers */ | ||
281 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
282 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
283 | pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific; | ||
284 | |||
285 | switch( nIndex ) { | ||
286 | case OMX_IndexParamVideoMpeg2 : | ||
287 | |||
288 | pMPEG2VideoParam = (OMX_VIDEO_PARAM_MPEG2TYPE *) pParamStruct; | ||
289 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
290 | OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || | ||
291 | (pVidDecComp->sBase.pPorts[pMPEG2VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), | ||
292 | OMX_ErrorIncorrectStateOperation); | ||
293 | |||
294 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG2TYPE, eError); | ||
295 | OMX_CHECK(pMPEG2VideoParam->eProfile == OMX_VIDEO_MPEG2ProfileSimple | ||
296 | || pMPEG2VideoParam->eProfile == OMX_VIDEO_MPEG2ProfileMain, | ||
297 | OMX_ErrorUnsupportedSetting); | ||
298 | if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
299 | pMPEG2VidDecComp->tMPEG2VideoParam = *pMPEG2VideoParam; | ||
300 | } else if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
301 | OSAL_ErrorTrace("OMX_IndexParamVideoMpeg2 supported only on i/p port"); | ||
302 | eError = OMX_ErrorUnsupportedIndex; | ||
303 | } else { | ||
304 | eError = OMX_ErrorBadPortIndex; | ||
305 | } | ||
306 | break; | ||
307 | case OMX_IndexParamCommonDeblocking : | ||
308 | |||
309 | pDeblockingParam = (OMX_PARAM_DEBLOCKINGTYPE *) pParamStruct; | ||
310 | |||
311 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
312 | OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || | ||
313 | (pVidDecComp->sBase.pPorts[pDeblockingParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), | ||
314 | OMX_ErrorIncorrectStateOperation); | ||
315 | |||
316 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_DEBLOCKINGTYPE, eError); | ||
317 | if( pDeblockingParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
318 | pMPEG2VidDecComp->tDeblockingParam.bDeblocking = pDeblockingParam->bDeblocking; | ||
319 | } else if( pDeblockingParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
320 | OSAL_ErrorTrace("\n Deblocking supported only on o/p port... \n"); | ||
321 | eError = OMX_ErrorUnsupportedIndex; | ||
322 | } else { | ||
323 | eError = OMX_ErrorBadPortIndex; | ||
324 | } | ||
325 | break; | ||
326 | default : | ||
327 | eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct); | ||
328 | } | ||
329 | |||
330 | EXIT: | ||
331 | return (eError); | ||
332 | } | ||
333 | |||
334 | OMX_ERRORTYPE OMXMPEG2VD_GetParameter(OMX_HANDLETYPE hComponent, | ||
335 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) | ||
336 | { | ||
337 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
338 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
339 | OMXVidDecComp *pVidDecComp = NULL; | ||
340 | OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL; | ||
341 | OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL; | ||
342 | OMX_VIDEO_PARAM_MPEG2TYPE *pMPEG2VideoParam = NULL; | ||
343 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pMPEG2ProfileLevelParam = NULL; | ||
344 | |||
345 | OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), | ||
346 | OMX_ErrorBadParameter); | ||
347 | |||
348 | /*! Initialize the pointers */ | ||
349 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
350 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
351 | /* GetParameter can't be invoked incase the comp is in Invalid State */ | ||
352 | OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, | ||
353 | OMX_ErrorIncorrectStateOperation); | ||
354 | |||
355 | pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific; | ||
356 | |||
357 | switch( nIndex ) { | ||
358 | case OMX_IndexParamVideoMpeg2 : | ||
359 | |||
360 | pMPEG2VideoParam = (OMX_VIDEO_PARAM_MPEG2TYPE *) pParamStruct; | ||
361 | |||
362 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG2TYPE, eError); | ||
363 | if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
364 | *pMPEG2VideoParam = pMPEG2VidDecComp->tMPEG2VideoParam; | ||
365 | } else if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
366 | OSAL_ErrorTrace("OMX_IndexParamVideoMpeg2 supported only on i/p port"); | ||
367 | eError = OMX_ErrorUnsupportedIndex; | ||
368 | } else { | ||
369 | eError = OMX_ErrorBadPortIndex; | ||
370 | } | ||
371 | break; | ||
372 | case OMX_IndexParamCommonDeblocking : | ||
373 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_DEBLOCKINGTYPE, eError); | ||
374 | pDeblockingParam = (OMX_PARAM_DEBLOCKINGTYPE *) pParamStruct; | ||
375 | if( pDeblockingParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
376 | pDeblockingParam->bDeblocking = pMPEG2VidDecComp->tDeblockingParam.bDeblocking; | ||
377 | } else if( pDeblockingParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
378 | OSAL_ErrorTrace("\n Deblocking supported only on o/p port... \n"); | ||
379 | eError = OMX_ErrorUnsupportedIndex; | ||
380 | } else { | ||
381 | eError = OMX_ErrorBadPortIndex; | ||
382 | } | ||
383 | break; | ||
384 | case OMX_IndexParamVideoProfileLevelQuerySupported : | ||
385 | { | ||
386 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
387 | pMPEG2ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct; | ||
388 | if( pMPEG2ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
389 | if( pMPEG2ProfileLevelParam->nProfileIndex == 0 ) { | ||
390 | if( pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2 ) { | ||
391 | pMPEG2ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG2ProfileSimple; | ||
392 | pMPEG2ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG2LevelLL; | ||
393 | } | ||
394 | } else if( pMPEG2ProfileLevelParam->nProfileIndex == 1 ) { | ||
395 | if( pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2 ) { | ||
396 | pMPEG2ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG2ProfileMain; | ||
397 | pMPEG2ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG2LevelML; | ||
398 | } | ||
399 | } else { | ||
400 | eError = OMX_ErrorNoMore; | ||
401 | } | ||
402 | } else if( pMPEG2ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
403 | OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port"); | ||
404 | eError = OMX_ErrorUnsupportedIndex; | ||
405 | } else { | ||
406 | eError = OMX_ErrorBadPortIndex; | ||
407 | } | ||
408 | } | ||
409 | break; | ||
410 | |||
411 | default : | ||
412 | eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct); | ||
413 | } | ||
414 | |||
415 | EXIT: | ||
416 | return (eError); | ||
417 | } | ||
418 | |||
419 | |||
420 | OMX_ERRORTYPE OMXMPEG2VD_HandleError(OMX_HANDLETYPE hComponent) | ||
421 | { | ||
422 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
423 | XDAS_Int32 status = 0; | ||
424 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
425 | OMXVidDecComp *pVidDecComp = NULL; | ||
426 | |||
427 | /* Initialize pointers */ | ||
428 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
429 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
430 | |||
431 | /*! Call the Codec Status function to know cause of error */ | ||
432 | status = VIDDEC3_control(pVidDecComp->pDecHandle, | ||
433 | XDM_GETSTATUS, | ||
434 | pVidDecComp->pDecDynParams, | ||
435 | pVidDecComp->pDecStatus); | ||
436 | /* Check whether the Codec Status call was succesful */ | ||
437 | if( status != VIDDEC3_EOK ) { | ||
438 | OSAL_ErrorTrace("VIDDEC3_control XDM_GETSTATUS failed"); | ||
439 | eError = OMX_ErrorInsufficientResources; | ||
440 | goto EXIT; | ||
441 | } | ||
442 | |||
443 | ALOGE("Mpeg2: extendedErrorCode0 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode0); | ||
444 | ALOGE("Mpeg2: extendedErrorCode1 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode1); | ||
445 | ALOGE("Mpeg2: extendedErrorCode2 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode2); | ||
446 | ALOGE("Mpeg2: extendedErrorCode3 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode3); | ||
447 | |||
448 | EXIT: | ||
449 | return (eError); | ||
450 | } | ||
451 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_MPEG4VD_H_ | ||
18 | #define _OMX_MPEG4VD_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <omx_video_decoder.h> | ||
25 | #include <ti/sdo/codecs/mpeg4vdec/impeg4vdec.h> | ||
26 | |||
27 | /*! Padding for width as per Codec Requirement */ | ||
28 | #define PADX (32) | ||
29 | /*! Padding for height as per Codec requirement */ | ||
30 | #define PADY (32) | ||
31 | |||
32 | |||
33 | void OMXMPEG4VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams); | ||
34 | |||
35 | void OMXMPEG4VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams); | ||
36 | |||
37 | void OMXMPEG4VD_SetStatus(OMX_HANDLETYPE hComponent, void *status); | ||
38 | |||
39 | PaddedBuffParams CalculateMPEG4VD_outbuff_details(OMX_HANDLETYPE hComponent, | ||
40 | OMX_U32 width, OMX_U32 height); | ||
41 | |||
42 | OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent); | ||
43 | OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent); | ||
44 | OMX_ERRORTYPE OMXMPEG4_H263VD_Init(OMX_HANDLETYPE hComponent); | ||
45 | void OMXMPEG4VD_DeInit(OMX_HANDLETYPE hComponent); | ||
46 | OMX_ERRORTYPE OMXMPEG4VD_HandleError(OMX_HANDLETYPE hComponent); | ||
47 | |||
48 | extern OMX_ERRORTYPE OMXMPEG4VD_SetParameter(OMX_HANDLETYPE hComponent, | ||
49 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
50 | extern OMX_ERRORTYPE OMXMPEG4VD_GetParameter(OMX_HANDLETYPE hComponent, | ||
51 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
52 | |||
53 | extern OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent, | ||
54 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
55 | extern OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent, | ||
56 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
57 | |||
58 | |||
59 | typedef struct OMXMPEG4VidDecComp { | ||
60 | OMX_PARAM_DEBLOCKINGTYPE tDeblockingParam; | ||
61 | OMX_VIDEO_PARAM_MPEG4TYPE tMPEG4VideoParam; | ||
62 | OMX_BOOL bIsSorensonSpark; | ||
63 | } OMXMPEG4VidDecComp; | ||
64 | |||
65 | |||
66 | #ifdef __cplusplus | ||
67 | } | ||
68 | #endif | ||
69 | |||
70 | #endif /* _OMX_MPEG4VD_H_ */ | ||
71 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_MPEG4_VIDDEC" | ||
18 | #include <omx_mpeg4vd.h> | ||
19 | |||
20 | OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent) | ||
21 | { | ||
22 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
23 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
24 | OMXVidDecComp *pVidDecComp = NULL; | ||
25 | OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; | ||
26 | |||
27 | eError = OMXMPEG4_H263VD_Init(hComponent); | ||
28 | |||
29 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
30 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
31 | |||
32 | pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; | ||
33 | pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingMPEG4; | ||
34 | pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused; | ||
35 | pMPEG4VidDecComp->bIsSorensonSpark = OMX_FALSE; | ||
36 | |||
37 | return (eError); | ||
38 | } | ||
39 | |||
40 | OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent) | ||
41 | { | ||
42 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
43 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
44 | OMXVidDecComp *pVidDecComp = NULL; | ||
45 | OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; | ||
46 | |||
47 | eError = OMXMPEG4_H263VD_Init(hComponent); | ||
48 | |||
49 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
50 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
51 | pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; | ||
52 | |||
53 | pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingH263; | ||
54 | pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused; | ||
55 | |||
56 | pMPEG4VidDecComp->bIsSorensonSpark = OMX_FALSE; | ||
57 | |||
58 | return (eError); | ||
59 | } | ||
60 | |||
61 | OMX_ERRORTYPE OMXMPEG4_H263VD_Init(OMX_HANDLETYPE hComponent) | ||
62 | { | ||
63 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
64 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
65 | OMXVidDecComp *pVidDecComp = NULL; | ||
66 | OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; | ||
67 | |||
68 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
69 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
70 | |||
71 | /*! Initialize the function pointers */ | ||
72 | pVidDecComp->fpSet_StaticParams = OMXMPEG4VD_SetStaticParams; | ||
73 | pVidDecComp->fpSet_DynamicParams = OMXMPEG4VD_SetDynamicParams; | ||
74 | pVidDecComp->fpSet_Status = OMXMPEG4VD_SetStatus; | ||
75 | pVidDecComp->fpCalc_OubuffDetails = CalculateMPEG4VD_outbuff_details; | ||
76 | pVidDecComp->fpDeinit_Codec = OMXMPEG4VD_DeInit; | ||
77 | pVidDecComp->cDecoderName = "ivahd_mpeg4dec"; | ||
78 | pHandle->SetParameter = OMXMPEG4VD_SetParameter; | ||
79 | pHandle->GetParameter = OMXMPEG4VD_GetParameter; | ||
80 | pVidDecComp->fpHandle_ExtendedError = OMXMPEG4VD_HandleError; | ||
81 | |||
82 | /*! Initialize the framerate divisor to 10000 as WA because MPEG4 codec is providing framerate by multiplying with 10000 instead of 1000*/ | ||
83 | pVidDecComp->nFrameRateDivisor = 10000; | ||
84 | |||
85 | pVidDecComp->pCodecSpecific = (OMXMPEG4VidDecComp *) OSAL_Malloc(sizeof (OMXMPEG4VidDecComp)); | ||
86 | OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources); | ||
87 | |||
88 | pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; | ||
89 | |||
90 | OMX_BASE_INIT_STRUCT_PTR(&(pMPEG4VidDecComp->tDeblockingParam), OMX_PARAM_DEBLOCKINGTYPE); | ||
91 | pMPEG4VidDecComp->tDeblockingParam.nPortIndex = OMX_VIDDEC_OUTPUT_PORT; | ||
92 | pMPEG4VidDecComp->tDeblockingParam.bDeblocking = OMX_TRUE; | ||
93 | |||
94 | OMX_BASE_INIT_STRUCT_PTR(&(pMPEG4VidDecComp->tMPEG4VideoParam), OMX_VIDEO_PARAM_MPEG4TYPE); | ||
95 | pMPEG4VidDecComp->tMPEG4VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT; | ||
96 | pMPEG4VidDecComp->tMPEG4VideoParam.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedSimple; | ||
97 | pMPEG4VidDecComp->tMPEG4VideoParam.eLevel = OMX_VIDEO_MPEG4Level5; | ||
98 | |||
99 | /*! Allocate Memory for Static Parameter */ | ||
100 | pVidDecComp->pDecStaticParams = (IVIDDEC3_Params *) memplugin_alloc(sizeof(IMPEG4VDEC_Params), 1, MEM_CARVEOUT, 0, 0); | ||
101 | OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources); | ||
102 | OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IMPEG4VDEC_Params)); | ||
103 | |||
104 | /*! Allocate Memory for Dynamic Parameter */ | ||
105 | pVidDecComp->pDecDynParams = (IVIDDEC3_DynamicParams *)memplugin_alloc(sizeof(IMPEG4VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0); | ||
106 | OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources); | ||
107 | OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IMPEG4VDEC_DynamicParams)); | ||
108 | |||
109 | /*! Allocate Memory for Status Structure */ | ||
110 | pVidDecComp->pDecStatus = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IMPEG4VDEC_Status), 1, MEM_CARVEOUT, 0, 0); | ||
111 | OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources); | ||
112 | OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IMPEG4VDEC_Status)); | ||
113 | |||
114 | /*! Allocate Memory for Input Arguments */ | ||
115 | pVidDecComp->pDecInArgs = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IMPEG4VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0); | ||
116 | OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources); | ||
117 | OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IMPEG4VDEC_InArgs)); | ||
118 | |||
119 | /*! Allocate Memory for Output Arguments */ | ||
120 | pVidDecComp->pDecOutArgs = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IMPEG4VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0); | ||
121 | OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources); | ||
122 | OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IMPEG4VDEC_OutArgs)); | ||
123 | |||
124 | pVidDecComp->pDecInArgs->size = sizeof(IMPEG4VDEC_InArgs); | ||
125 | pVidDecComp->pDecOutArgs->size = sizeof(IMPEG4VDEC_OutArgs); | ||
126 | |||
127 | pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE; | ||
128 | pVidDecComp->pDecStaticParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE; | ||
129 | pVidDecComp->pDecStaticParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE; | ||
130 | |||
131 | pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_DECODE_ONLY; | ||
132 | |||
133 | pVidDecComp->pDecStaticParams->inputDataMode = IVIDEO_ENTIREFRAME; | ||
134 | pVidDecComp->pDecStaticParams->numInputDataUnits = 0; | ||
135 | |||
136 | EXIT: | ||
137 | return (eError); | ||
138 | } | ||
139 | |||
140 | void OMXMPEG4VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams) | ||
141 | { | ||
142 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
143 | OMXVidDecComp *pVidDecComp = NULL; | ||
144 | OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; | ||
145 | IMPEG4VDEC_Params *params; | ||
146 | |||
147 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
148 | pVidDecComp | ||
149 | = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
150 | |||
151 | pMPEG4VidDecComp = | ||
152 | (OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; | ||
153 | |||
154 | params = (IMPEG4VDEC_Params *) staticparams; | ||
155 | |||
156 | params->viddec3Params.size = sizeof(IMPEG4VDEC_Params); | ||
157 | params->viddec3Params.maxFrameRate = 300000; | ||
158 | params->viddec3Params.maxBitRate = 10000000; | ||
159 | params->viddec3Params.dataEndianness = XDM_BYTE; | ||
160 | params->viddec3Params.forceChromaFormat = XDM_YUV_420SP; | ||
161 | params->viddec3Params.displayDelay = IVIDDEC3_DISPLAY_DELAY_1; | ||
162 | params->viddec3Params.inputDataMode = IVIDEO_ENTIREFRAME; | ||
163 | params->viddec3Params.numInputDataUnits = 0; | ||
164 | params->viddec3Params.outputDataMode = IVIDEO_ENTIREFRAME; | ||
165 | params->viddec3Params.displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED; | ||
166 | |||
167 | params->viddec3Params.errorInfoMode = IVIDEO_ERRORINFO_OFF; | ||
168 | params->outloopDeBlocking = IMPEG4VDEC_DEBLOCK_DISABLE; | ||
169 | params->enhancedDeBlockingQp = 31; | ||
170 | params->sorensonSparkStream = pMPEG4VidDecComp->bIsSorensonSpark; | ||
171 | params->errorConcealmentEnable = pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment; | ||
172 | params->debugTraceLevel = 0; | ||
173 | params->lastNFramesToLog = 0; | ||
174 | params->paddingMode = IMPEG4VDEC_MPEG4_MODE_PADDING; | ||
175 | |||
176 | return; | ||
177 | } | ||
178 | |||
179 | |||
180 | void OMXMPEG4VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynParams) | ||
181 | { | ||
182 | IMPEG4VDEC_DynamicParams *dynamicParams; | ||
183 | (void)hComponent; | ||
184 | |||
185 | dynamicParams = (IMPEG4VDEC_DynamicParams *)dynParams; | ||
186 | |||
187 | /*! Update the Individual fields in the Dyanmic Params of MPEG4 decoder */ | ||
188 | dynamicParams->viddec3DynamicParams.size = sizeof(IMPEG4VDEC_DynamicParams); | ||
189 | dynamicParams->viddec3DynamicParams.decodeHeader = XDM_DECODE_AU; | ||
190 | dynamicParams->viddec3DynamicParams.displayWidth = 0; | ||
191 | dynamicParams->viddec3DynamicParams.frameSkipMode = IVIDEO_NO_SKIP; | ||
192 | dynamicParams->viddec3DynamicParams.newFrameFlag = XDAS_TRUE; | ||
193 | dynamicParams->viddec3DynamicParams.putDataFxn = NULL; | ||
194 | dynamicParams->viddec3DynamicParams.putDataHandle = NULL; | ||
195 | dynamicParams->viddec3DynamicParams.getDataFxn = NULL; | ||
196 | dynamicParams->viddec3DynamicParams.getDataHandle = NULL; | ||
197 | dynamicParams->viddec3DynamicParams.putBufferFxn = NULL; | ||
198 | dynamicParams->viddec3DynamicParams.putBufferHandle = NULL; | ||
199 | return; | ||
200 | } | ||
201 | |||
202 | |||
203 | void OMXMPEG4VD_SetStatus(OMX_HANDLETYPE hComponent, void *decstatus) | ||
204 | { | ||
205 | IMPEG4VDEC_Status *status; | ||
206 | (void)hComponent; | ||
207 | |||
208 | status = (IMPEG4VDEC_Status *)decstatus; | ||
209 | |||
210 | status->viddec3Status.size = sizeof(IMPEG4VDEC_Status); | ||
211 | return; | ||
212 | } | ||
213 | |||
214 | |||
215 | PaddedBuffParams CalculateMPEG4VD_outbuff_details(OMX_HANDLETYPE hComponent, | ||
216 | OMX_U32 width, OMX_U32 height) | ||
217 | { | ||
218 | PaddedBuffParams OutBuffDetails; | ||
219 | (void)hComponent; | ||
220 | |||
221 | OutBuffDetails.nBufferSize = ((((width + PADX + 127) & ~127) * (height + PADY))); | ||
222 | /* Multiply buffer size by 1.5 to account for both luma and chroma */ | ||
223 | OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1; | ||
224 | |||
225 | OutBuffDetails.nBufferCountMin = 4; | ||
226 | OutBuffDetails.nBufferCountActual = 8; | ||
227 | OutBuffDetails.n1DBufferAlignment = 16; | ||
228 | OutBuffDetails.nPaddedWidth = (width + PADX + 127) & ~127; | ||
229 | OutBuffDetails.nPaddedHeight = height + PADY; | ||
230 | OutBuffDetails.n2DBufferYAlignment = 1; | ||
231 | OutBuffDetails.n2DBufferXAlignment = 16; | ||
232 | return (OutBuffDetails); | ||
233 | } | ||
234 | |||
235 | |||
236 | void OMXMPEG4VD_DeInit(OMX_HANDLETYPE hComponent) | ||
237 | { | ||
238 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
239 | OMXVidDecComp *pVidDecComp = NULL; | ||
240 | |||
241 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
242 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
243 | /*! Delete all the memory which was allocated during init of decoder */ | ||
244 | if( pVidDecComp->pDecStaticParams ) { | ||
245 | memplugin_free(pVidDecComp->pDecStaticParams); | ||
246 | pVidDecComp->pDecStaticParams = NULL; | ||
247 | } | ||
248 | if( pVidDecComp->pDecDynParams ) { | ||
249 | memplugin_free(pVidDecComp->pDecDynParams); | ||
250 | pVidDecComp->pDecDynParams = NULL; | ||
251 | } | ||
252 | if( pVidDecComp->pDecStatus ) { | ||
253 | memplugin_free(pVidDecComp->pDecStatus); | ||
254 | pVidDecComp->pDecStatus = NULL; | ||
255 | } | ||
256 | if( pVidDecComp->pDecInArgs ) { | ||
257 | memplugin_free(pVidDecComp->pDecInArgs); | ||
258 | pVidDecComp->pDecInArgs = NULL; | ||
259 | } | ||
260 | if( pVidDecComp->pDecOutArgs ) { | ||
261 | memplugin_free(pVidDecComp->pDecOutArgs); | ||
262 | pVidDecComp->pDecOutArgs = NULL; | ||
263 | } | ||
264 | if( pVidDecComp->pCodecSpecific ) { | ||
265 | OSAL_Free(pVidDecComp->pCodecSpecific); | ||
266 | pVidDecComp->pCodecSpecific = NULL; | ||
267 | } | ||
268 | pHandle->SetParameter = OMXVidDec_SetParameter; | ||
269 | pHandle->GetParameter = OMXVidDec_GetParameter; | ||
270 | pVidDecComp->fpHandle_ExtendedError = NULL; | ||
271 | pVidDecComp->nFrameRateDivisor = 1000; | ||
272 | } | ||
273 | |||
274 | OMX_ERRORTYPE OMXMPEG4VD_SetParameter(OMX_HANDLETYPE hComponent, | ||
275 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) | ||
276 | { | ||
277 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
278 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
279 | OMXVidDecComp *pVidDecComp = NULL; | ||
280 | OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; | ||
281 | OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL; | ||
282 | OMX_VIDEO_PARAM_MPEG4TYPE *pMPEG4VideoParam = NULL; | ||
283 | |||
284 | OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), | ||
285 | OMX_ErrorBadParameter); | ||
286 | |||
287 | /*! Initialize the pointers */ | ||
288 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
289 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
290 | pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; | ||
291 | |||
292 | switch( nIndex ) { | ||
293 | case OMX_IndexParamVideoMpeg4 : | ||
294 | pMPEG4VideoParam = (OMX_VIDEO_PARAM_MPEG4TYPE *) pParamStruct; | ||
295 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
296 | OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || | ||
297 | (pVidDecComp->sBase.pPorts[pMPEG4VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), | ||
298 | OMX_ErrorIncorrectStateOperation); | ||
299 | |||
300 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG4TYPE, eError); | ||
301 | OMX_CHECK(pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileSimple | ||
302 | || pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileMain | ||
303 | || pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileAdvancedSimple, | ||
304 | OMX_ErrorUnsupportedSetting); | ||
305 | if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
306 | pMPEG4VidDecComp->tMPEG4VideoParam = *pMPEG4VideoParam; | ||
307 | } else if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
308 | OSAL_ErrorTrace("OMX_IndexParamVideoMpeg4 supported only on i/p port"); | ||
309 | eError = OMX_ErrorUnsupportedIndex; | ||
310 | } else { | ||
311 | eError = OMX_ErrorBadPortIndex; | ||
312 | } | ||
313 | break; | ||
314 | |||
315 | default : | ||
316 | eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct); | ||
317 | } | ||
318 | |||
319 | EXIT: | ||
320 | return (eError); | ||
321 | } | ||
322 | |||
323 | OMX_ERRORTYPE OMXMPEG4VD_GetParameter(OMX_HANDLETYPE hComponent, | ||
324 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) | ||
325 | { | ||
326 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
327 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
328 | OMXVidDecComp *pVidDecComp = NULL; | ||
329 | OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL; | ||
330 | OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL; | ||
331 | OMX_VIDEO_PARAM_MPEG4TYPE *pMPEG4VideoParam = NULL; | ||
332 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pMPEG4ProfileLevelParam = NULL; | ||
333 | |||
334 | OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), | ||
335 | OMX_ErrorBadParameter); | ||
336 | |||
337 | /*! Initialize the pointers */ | ||
338 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
339 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
340 | /* GetParameter can't be invoked incase the comp is in Invalid State */ | ||
341 | OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, | ||
342 | OMX_ErrorIncorrectStateOperation); | ||
343 | |||
344 | pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific; | ||
345 | |||
346 | switch( nIndex ) { | ||
347 | case OMX_IndexParamVideoMpeg4 : | ||
348 | pMPEG4VideoParam = (OMX_VIDEO_PARAM_MPEG4TYPE *) pParamStruct; | ||
349 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG4TYPE, eError); | ||
350 | if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
351 | *pMPEG4VideoParam = pMPEG4VidDecComp->tMPEG4VideoParam; | ||
352 | } else if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
353 | OSAL_ErrorTrace("OMX_IndexParamVideoMpeg4 supported only on i/p port"); | ||
354 | eError = OMX_ErrorUnsupportedIndex; | ||
355 | } else { | ||
356 | eError = OMX_ErrorBadPortIndex; | ||
357 | } | ||
358 | break; | ||
359 | case OMX_IndexParamVideoProfileLevelQuerySupported : | ||
360 | { | ||
361 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
362 | pMPEG4ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct; | ||
363 | if( pMPEG4ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) { | ||
364 | if( pMPEG4ProfileLevelParam->nProfileIndex == 0 ) { | ||
365 | if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 ) { | ||
366 | pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG4ProfileSimple; | ||
367 | pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG4LevelMax; | ||
368 | } else if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingH263 ) { | ||
369 | pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_H263ProfileBaseline; | ||
370 | pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_H263Level70; | ||
371 | } | ||
372 | } else if( pMPEG4ProfileLevelParam->nProfileIndex == 1 ) { | ||
373 | if(pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 ) { | ||
374 | pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG4ProfileAdvancedSimple; | ||
375 | pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG4LevelMax; | ||
376 | } else if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingH263 ) { | ||
377 | pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_H263ProfileISWV2; | ||
378 | pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_H263Level70; | ||
379 | } | ||
380 | } else { | ||
381 | eError = OMX_ErrorNoMore; | ||
382 | } | ||
383 | } else if( pMPEG4ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
384 | OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port"); | ||
385 | eError = OMX_ErrorUnsupportedIndex; | ||
386 | } else { | ||
387 | eError = OMX_ErrorBadPortIndex; | ||
388 | } | ||
389 | } | ||
390 | break; | ||
391 | default : | ||
392 | eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct); | ||
393 | } | ||
394 | |||
395 | EXIT: | ||
396 | return (eError); | ||
397 | } | ||
398 | |||
399 | |||
400 | OMX_ERRORTYPE OMXMPEG4VD_HandleError(OMX_HANDLETYPE hComponent) | ||
401 | { | ||
402 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
403 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
404 | OMXVidDecComp *pVidDecComp = NULL; | ||
405 | |||
406 | /* Initialize pointers */ | ||
407 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
408 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
409 | /* To send the output buffer to display in case of no valid VOL/VOP header */ | ||
410 | |||
411 | if((!(pVidDecComp->pDecOutArgs->extendedError & 0x8000) | ||
412 | && ((pVidDecComp->pDecOutArgs->extendedError & 0x100000) | ||
413 | || (pVidDecComp->pDecOutArgs->extendedError & 0x80000))) | ||
414 | && (pVidDecComp->pDecInArgs->inputID == pVidDecComp->pDecOutArgs->freeBufID[0] | ||
415 | && pVidDecComp->pDecOutArgs->outputID[0] == 0)) { | ||
416 | pVidDecComp->pDecOutArgs->outputID[0] = pVidDecComp->pDecInArgs->inputID; | ||
417 | pVidDecComp->bSyncFrameReady = OMX_TRUE; | ||
418 | } | ||
419 | |||
420 | return (eError); | ||
421 | } | ||
422 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_VIDEO_DECODER_H_ | ||
18 | #define _OMX_VIDEO_DECODER_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <string.h> | ||
25 | #include <sys/types.h> | ||
26 | #include <sys/stat.h> | ||
27 | #include <fcntl.h> | ||
28 | #include <OMX_Types.h> | ||
29 | #include <omx_base.h> | ||
30 | #include <xdc/std.h> | ||
31 | #include <ti/xdais/xdas.h> | ||
32 | #include <ti/sdo/ce/video3/viddec3.h> | ||
33 | #include <omx_base_utils.h> | ||
34 | |||
35 | #include <hardware/gralloc.h> | ||
36 | #include <hardware/hardware.h> | ||
37 | #include <hal_public.h> | ||
38 | |||
39 | #define OMX_VIDDEC_NUM_OF_PORTS OMX_BASE_NUM_OF_PORTS | ||
40 | #define OMX_VIDDEC_INPUT_PORT OMX_BASE_INPUT_PORT | ||
41 | #define OMX_VIDDEC_OUTPUT_PORT OMX_BASE_OUTPUT_PORT | ||
42 | #define OMX_VIDDEC_DEFAULT_START_PORT_NUM OMX_BASE_DEFAULT_START_PORT_NUM | ||
43 | |||
44 | |||
45 | /*Android Data structures*/ | ||
46 | |||
47 | enum Type { | ||
48 | MEDIA_IMAGE_TYPE_UNKNOWN = 0, | ||
49 | MEDIA_IMAGE_TYPE_YUV, | ||
50 | }; | ||
51 | |||
52 | enum PlaneIndex { | ||
53 | Y = 0, | ||
54 | U, | ||
55 | V, | ||
56 | MAX_NUM_PLANES | ||
57 | }; | ||
58 | |||
59 | typedef struct PlaneInfo { | ||
60 | uint32_t mOffset; // offset of first pixel of the plane in bytes | ||
61 | // from buffer offset | ||
62 | uint32_t mColInc; // column increment in bytes | ||
63 | uint32_t mRowInc; // row increment in bytes | ||
64 | uint32_t mHorizSubsampling; // subsampling compared to the largest plane | ||
65 | uint32_t mVertSubsampling; // subsampling compared to the largest plane | ||
66 | }PlaneInfo; | ||
67 | |||
68 | // Structure describing a media image (frame) | ||
69 | // Currently only supporting YUV | ||
70 | typedef struct MediaImage { | ||
71 | int mType; | ||
72 | uint32_t mNumPlanes; // number of planes | ||
73 | uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) | ||
74 | uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) | ||
75 | uint32_t mBitDepth; // useable bit depth | ||
76 | PlaneInfo mPlane[MAX_NUM_PLANES]; | ||
77 | }MediaImage; | ||
78 | |||
79 | // A pointer to this struct is passed to OMX_GetParameter when the extension | ||
80 | // index for the 'OMX.google.android.index.describeColorFormat' | ||
81 | // extension is given. This method can be called from any component state | ||
82 | // other than invalid. The color-format, frame width/height, and stride/ | ||
83 | // slice-height parameters are ones that are associated with a raw video | ||
84 | // port (input or output), but the stride/slice height parameters may be | ||
85 | // incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will | ||
86 | // be used (while specifying this color format). | ||
87 | // | ||
88 | // The component shall fill out the MediaImage structure that | ||
89 | // corresponds to the described raw video format, and the potentially corrected | ||
90 | // stride and slice-height info. | ||
91 | // | ||
92 | // The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE, | ||
93 | // though most implementations can ignore this difference. When using native buffers, | ||
94 | // the component may change the configured color format to an optimized format. | ||
95 | // Additionally, when allocating these buffers for flexible usecase, the framework | ||
96 | // will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers | ||
97 | // is OMX_TRUE), the component shall fill out the MediaImage information for the | ||
98 | // scenario when these SW-readable/writable buffers are locked using gralloc_lock. | ||
99 | // Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must | ||
100 | // be supported for vendor-specific formats. | ||
101 | // | ||
102 | // For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers | ||
103 | // is OMX_TRUE and the component does not support this color format with native | ||
104 | // buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN. | ||
105 | typedef struct DescribeColorFormatParams { | ||
106 | OMX_U32 nSize; | ||
107 | OMX_VERSIONTYPE nVersion; | ||
108 | // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE | ||
109 | OMX_COLOR_FORMATTYPE eColorFormat; | ||
110 | OMX_U32 nFrameWidth; | ||
111 | OMX_U32 nFrameHeight; | ||
112 | OMX_U32 nStride; | ||
113 | OMX_U32 nSliceHeight; | ||
114 | OMX_BOOL bUsingNativeBuffers; | ||
115 | |||
116 | // output: fill out the MediaImage fields | ||
117 | MediaImage sMediaImage; | ||
118 | }DescribeColorFormatParams; | ||
119 | |||
120 | // A pointer to this struct is passed to OMX_SetParameter() when the extension | ||
121 | // index "OMX.google.android.index.prepareForAdaptivePlayback" is given. | ||
122 | // | ||
123 | // This method is used to signal a video decoder, that the user has requested | ||
124 | // seamless resolution change support (if bEnable is set to OMX_TRUE). | ||
125 | // nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest | ||
126 | // anticipated frames in the video. If bEnable is OMX_FALSE, no resolution | ||
127 | // change is expected, and the nMaxFrameWidth/Height fields are unused. | ||
128 | // | ||
129 | // If the decoder supports dynamic output buffers, it may ignore this | ||
130 | // request. Otherwise, it shall request resources in such a way so that it | ||
131 | // avoids full port-reconfiguration (due to output port-definition change) | ||
132 | // during resolution changes. | ||
133 | // | ||
134 | // DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED. INSTEAD, IMPLEMENT | ||
135 | // METADATA SUPPORT FOR VIDEO DECODERS. | ||
136 | typedef struct PrepareForAdaptivePlaybackParams { | ||
137 | OMX_U32 nSize; | ||
138 | OMX_VERSIONTYPE nVersion; | ||
139 | OMX_U32 nPortIndex; | ||
140 | OMX_BOOL bEnable; | ||
141 | OMX_U32 nMaxFrameWidth; | ||
142 | OMX_U32 nMaxFrameHeight; | ||
143 | }PrepareForAdaptivePlaybackParams; | ||
144 | |||
145 | /* | ||
146 | * Padded Buffer Parameters | ||
147 | */ | ||
148 | typedef struct PaddedBuffParams { | ||
149 | OMX_U32 nBufferSize; /*! Buffer size */ | ||
150 | OMX_U32 nPaddedWidth; /*! Padded Width of the buffer */ | ||
151 | OMX_U32 nPaddedHeight; /*! Padded Height */ | ||
152 | OMX_U32 nBufferCountMin; /*! Min number of buffers required */ | ||
153 | OMX_U32 nBufferCountActual; /*! Actual number of buffers */ | ||
154 | OMX_U32 n1DBufferAlignment; /*! 1D Buffer Alignment value */ | ||
155 | OMX_U32 n2DBufferYAlignment; /*! Y axis alignment value in 2Dbuffer */ | ||
156 | OMX_U32 n2DBufferXAlignment; /*! X Axis alignment value in 2Dbuffer */ | ||
157 | } PaddedBuffParams; | ||
158 | |||
159 | /* | ||
160 | * OMX Video decoder component | ||
161 | */ | ||
162 | typedef struct OMXVideoDecoderComponent { | ||
163 | OMXBaseComp sBase; | ||
164 | /* codec related fields */ | ||
165 | OMX_STRING cDecoderName; | ||
166 | VIDDEC3_Handle pDecHandle; | ||
167 | Engine_Handle ce; | ||
168 | IVIDDEC3_Params *pDecStaticParams; /*! Pointer to Decoder Static Params */ | ||
169 | IVIDDEC3_DynamicParams *pDecDynParams; /*! Pointer to Decoder Dynamic Params */ | ||
170 | IVIDDEC3_Status *pDecStatus; /*! Pointer to Decoder Status struct */ | ||
171 | IVIDDEC3_InArgs *pDecInArgs; /*! Pointer to Decoder InArgs */ | ||
172 | IVIDDEC3_OutArgs *pDecOutArgs; /*! Pointer to Decoder OutArgs */ | ||
173 | XDM2_BufDesc *tInBufDesc; | ||
174 | XDM2_BufDesc *tOutBufDesc; | ||
175 | |||
176 | /* OMX params */ | ||
177 | OMX_VIDEO_PARAM_PORTFORMATTYPE tVideoParams[OMX_VIDDEC_NUM_OF_PORTS]; | ||
178 | OMX_CONFIG_RECTTYPE tCropDimension; | ||
179 | OMX_CONFIG_SCALEFACTORTYPE tScaleParams; | ||
180 | OMX_PARAM_COMPONENTROLETYPE tComponentRole; | ||
181 | OMX_CONFIG_RECTTYPE t2DBufferAllocParams[OMX_VIDDEC_NUM_OF_PORTS]; | ||
182 | |||
183 | /* local params */ | ||
184 | gralloc_module_t const *grallocModule; | ||
185 | OMXBase_CodecConfigBuf sCodecConfig; | ||
186 | OMX_U32 nOutPortReconfigRequired; | ||
187 | OMX_U32 nCodecRecreationRequired; | ||
188 | OMX_U32 bInputBufferCancelled; | ||
189 | |||
190 | OMX_U32 bIsFlushRequired; | ||
191 | OMX_BOOL bUsePortReconfigForCrop; | ||
192 | OMX_BOOL bUsePortReconfigForPadding; | ||
193 | OMX_BOOL bSupportDecodeOrderTimeStamp; | ||
194 | OMX_BOOL bSupportSkipGreyOutputFrames; | ||
195 | OMX_BOOL bEnableDecodeZeroDisplayDelayMode; | ||
196 | |||
197 | OMX_U32 nFrameCounter; | ||
198 | OMX_BOOL bSyncFrameReady; | ||
199 | OMX_U32 nOutbufInUseFlag; | ||
200 | OMX_PTR pCodecSpecific; | ||
201 | OMX_U32 nDecoderMode; | ||
202 | OMX_U32 nFatalErrorGiven; | ||
203 | OMX_PTR pTimeStampStoragePipe; | ||
204 | OMX_U32 nFrameRateDivisor; | ||
205 | OMX_BOOL bFirstFrameHandled; | ||
206 | |||
207 | OMX_BOOL bIPCRecoveryNeeded; | ||
208 | |||
209 | //Parameters for Adaptive video playback | ||
210 | OMX_BOOL bisAdaptivePlayback; | ||
211 | OMX_U32 nAdaptiveMaxFrameWidth; | ||
212 | OMX_U32 nAdaptiveMaxFrameHeight; | ||
213 | |||
214 | void (*fpSet_StaticParams)(OMX_HANDLETYPE hComponent, void *params); | ||
215 | void (*fpSet_DynamicParams)(OMX_HANDLETYPE hComponent, void *dynamicparams); | ||
216 | void (*fpSet_Status)(OMX_HANDLETYPE hComponent, void *status); | ||
217 | void (*fpDeinit_Codec)(OMX_HANDLETYPE hComponent); | ||
218 | OMX_ERRORTYPE (*fpHandle_ExtendedError)(OMX_HANDLETYPE hComponent); | ||
219 | OMX_ERRORTYPE (*fpHandle_CodecGetStatus)(OMX_HANDLETYPE hComponent); | ||
220 | PaddedBuffParams (*fpCalc_OubuffDetails)(OMX_HANDLETYPE hComponent, OMX_U32 width, OMX_U32 height); | ||
221 | MemHeader *pmetaBuffer; | ||
222 | |||
223 | }OMXVidDecComp; | ||
224 | |||
225 | /* Component Entry Method */ | ||
226 | OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent); | ||
227 | OMX_ERRORTYPE OMXVidDec_ComponentInit(OMX_HANDLETYPE hComponent); | ||
228 | OMX_ERRORTYPE OMXVidDec_ComponentDeinit(OMX_HANDLETYPE hComponent); | ||
229 | |||
230 | OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent, | ||
231 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
232 | |||
233 | OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent, | ||
234 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct); | ||
235 | |||
236 | OMX_ERRORTYPE OMXVidDec_GetConfig(OMX_HANDLETYPE hComponent, | ||
237 | OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure); | ||
238 | |||
239 | OMX_ERRORTYPE OMXVidDec_SetConfig(OMX_HANDLETYPE hComponent, | ||
240 | OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure); | ||
241 | |||
242 | OMX_ERRORTYPE OMXVidDec_CommandNotify(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE Cmd, | ||
243 | OMX_U32 nParam, OMX_PTR pCmdData); | ||
244 | |||
245 | OMX_ERRORTYPE OMXVidDec_DataNotify(OMX_HANDLETYPE hComponent); | ||
246 | |||
247 | OMX_ERRORTYPE OMXVidDec_XlateBuffHandle(OMX_HANDLETYPE hComponent, OMX_PTR pBufferHdr, OMX_BOOL bRegister); | ||
248 | |||
249 | OMX_ERRORTYPE OMXVidDec_GetExtensionIndex(OMX_HANDLETYPE hComponent, OMX_STRING cParameterName, | ||
250 | OMX_INDEXTYPE *pIndexType); | ||
251 | |||
252 | |||
253 | #ifdef __cplusplus | ||
254 | } | ||
255 | #endif | ||
256 | |||
257 | #endif /* _OMX_VIDEO_DECODER_H_ */ | ||
258 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_VIDEO_DECODER_COMPONENTTABLE_H_ | ||
18 | #define _OMX_VIDEO_DECODER_COMPONENTTABLE_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <stdio.h> | ||
25 | #include <OMX_Video.h> | ||
26 | |||
27 | typedef struct OMXDecoderComponentList { | ||
28 | /*Component role to be specified here*/ | ||
29 | OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE]; | ||
30 | |||
31 | /*! Video Coding Type Format */ | ||
32 | OMX_VIDEO_CODINGTYPE eCompressionFormat; | ||
33 | |||
34 | /*! Function pointer to the component Init function of decoder */ | ||
35 | OMX_ERRORTYPE (*fpDecoderComponentInit)(OMX_HANDLETYPE hComponent); | ||
36 | |||
37 | } OMXDecoderComponentList; | ||
38 | |||
39 | /* external definition for the Decoder Component List*/ | ||
40 | extern OMXDecoderComponentList DecoderList[]; | ||
41 | |||
42 | #ifdef __cplusplus | ||
43 | } | ||
44 | #endif | ||
45 | |||
46 | #endif /* _OMX_VIDEO_DECODER_COMPONENTTABLE_H_ */ | ||
47 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_VIDEO_DECODER_INTERNAL_H_ | ||
18 | #define _OMX_VIDEO_DECODER_INTERNAL_H_ | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | #include <osal_trace.h> | ||
25 | #include <OMX_Core.h> | ||
26 | #include <OMX_Component.h> | ||
27 | #include <omx_base.h> | ||
28 | #include <OMX_Types.h> | ||
29 | #include <omx_base_utils.h> | ||
30 | #include <omx_video_decoder.h> | ||
31 | #include <omx_video_decoder_componenttable.h> | ||
32 | |||
33 | static OMX_STRING engineName = "ivahd_vidsvr"; | ||
34 | |||
35 | #define OMX_VIDDEC_COMP_VERSION_MAJOR 1 | ||
36 | #define OMX_VIDDEC_COMP_VERSION_MINOR 1 | ||
37 | #define OMX_VIDDEC_COMP_VERSION_REVISION 0 | ||
38 | #define OMX_VIDDEC_COMP_VERSION_STEP 0 | ||
39 | |||
40 | #define OMX_VIDEODECODER_DEFAULT_FRAMERATE 30 | ||
41 | |||
42 | /*! Minimum Input Buffer Count */ | ||
43 | #define OMX_VIDDEC_MIN_IN_BUF_COUNT 1 | ||
44 | /*! Default Input Buffer Count */ | ||
45 | #define OMX_VIDDEC_DEFAULT_IN_BUF_COUNT 2 | ||
46 | /*! Minimum Input Buffer Count in Data Sync mode | ||
47 | * codec releases input buffer of Nth Data Sync call during (N+2)th Data Sync call | ||
48 | * So minimum number of input buffers required is 3 */ | ||
49 | #define OMX_VIDDEC_DATASYNC_MIN_IN_BUF_COUNT 3 | ||
50 | /*! Default Input Buffer Count in Data Sync mode*/ | ||
51 | #define OMX_VIDDEC_DATASYNC_DEFAULT_IN_BUF_COUNT 4 | ||
52 | /*! Default Frame Width */ | ||
53 | #define OMX_VIDDEC_DEFAULT_FRAME_WIDTH 176 | ||
54 | /*! Default Frame Height */ | ||
55 | #define OMX_VIDDEC_DEFAULT_FRAME_HEIGHT 144 | ||
56 | /*! Default 1D-Buffer Alignment */ | ||
57 | #define OMX_VIDDEC_DEFAULT_1D_INPUT_BUFFER_ALIGNMENT 1 | ||
58 | /*! Default Stride value for 2D buffer */ | ||
59 | #define OMX_VIDDEC_DEFAULT_STRIDE OMX_VIDDEC_DEFAULT_FRAME_WIDTH | ||
60 | /*! Max Image Width supported */ | ||
61 | #define OMX_VIDDEC_MAX_WIDTH (2048) | ||
62 | /*! Max Image Height supported */ | ||
63 | #define OMX_VIDDEC_MAX_HEIGHT (2048) | ||
64 | /*! Max Number of MBs supported */ | ||
65 | #define OMX_VIDDEC_MAX_MACROBLOCK (8160) | ||
66 | |||
67 | #define OMX_VIDEODECODER_COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER" | ||
68 | |||
69 | /* external definition for the Video Params Init function */ | ||
70 | extern OMX_ERRORTYPE OMXVidDec_InitFields(OMXVidDecComp *pVidDecComp); | ||
71 | extern void OMXVidDec_InitPortDefs(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp); | ||
72 | extern void OMXVidDec_InitPortParams(OMXVidDecComp *pVidDecComp); | ||
73 | extern void OMXVidDec_InitDecoderParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp); | ||
74 | |||
75 | extern OMX_ERRORTYPE OMXVidDec_HandleFLUSH_EOS(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE *pOutBufHeader, | ||
76 | OMX_BUFFERHEADERTYPE *pInBufHeader); | ||
77 | extern OMX_ERRORTYPE OMXVidDec_SetInPortDef(OMX_HANDLETYPE hComponent, | ||
78 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs); | ||
79 | extern OMX_ERRORTYPE OMXVidDec_SetOutPortDef(OMXVidDecComp *pVidDecComp, | ||
80 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs); | ||
81 | extern OMX_ERRORTYPE OMXVidDec_HandleFirstFrame(OMX_HANDLETYPE hComponent, | ||
82 | OMX_BUFFERHEADERTYPE * *ppInBufHeader); | ||
83 | extern OMX_ERRORTYPE OMXVidDec_HandleCodecProcError(OMX_HANDLETYPE hComponent, | ||
84 | OMX_BUFFERHEADERTYPE * *ppInBufHeader, | ||
85 | OMX_BUFFERHEADERTYPE * *ppOutBufHeader); | ||
86 | extern OMX_ERRORTYPE OMXVidDec_HandleLockedBuffer(OMX_HANDLETYPE hComponent, | ||
87 | OMX_BUFFERHEADERTYPE *pOutBufHeader); | ||
88 | |||
89 | XDAS_Int32 OMXVidDec_DataSync_GetInputData(XDM_DataSyncHandle dataSyncHandle, XDM_DataSyncDesc *dataSyncDesc); | ||
90 | |||
91 | XDAS_Int32 OMXVidDec_DataSync_PutBuffer(XDM_DataSyncHandle dataSyncHandle, XDM_DataSyncDesc *dataSyncDesc); | ||
92 | |||
93 | extern void OMXVidDec_Set2DBuffParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp); | ||
94 | extern OMX_U32 Calc_InbufSize(OMX_U32 width, OMX_U32 height); | ||
95 | |||
96 | #ifdef __cplusplus | ||
97 | } | ||
98 | #endif | ||
99 | |||
100 | #endif /* _OMX_VIDEO_DECODER_H_ */ | ||
101 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_VIDDEC_COMMON" | ||
18 | |||
19 | #include <omx_video_decoder_internal.h> | ||
20 | #include <OMX_TI_Custom.h> | ||
21 | |||
22 | #include <osal_trace.h> | ||
23 | #include <memplugin.h> | ||
24 | #include <libdce.h> | ||
25 | |||
26 | |||
27 | #define HAL_NV12_PADDED_PIXEL_FORMAT HAL_PIXEL_FORMAT_NV12 | ||
28 | |||
29 | #define MAX_REF_FRAMES 16 | ||
30 | |||
31 | /* | ||
32 | * Component Init | ||
33 | */ | ||
34 | OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) | ||
35 | { | ||
36 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
37 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
38 | OMXVidDecComp *pVidDecComp = NULL; | ||
39 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
40 | OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT; | ||
41 | OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; | ||
42 | |||
43 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
44 | |||
45 | /*! Call the Common Decoder Component Init */ | ||
46 | eError = OMXVidDec_ComponentInit(hComponent); | ||
47 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
48 | |||
49 | /*! Call the Decoder Specific Init as default */ | ||
50 | eError = DecoderList[DEFAULT_COMPOENENT].fpDecoderComponentInit(hComponent); | ||
51 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
52 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
53 | OMXVidDec_InitPortDefs(hComponent, pVidDecComp); | ||
54 | OMXVidDec_InitPortParams(pVidDecComp); | ||
55 | OMXVidDec_Set2DBuffParams(hComponent, pVidDecComp); | ||
56 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
57 | p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]); | ||
58 | pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; | ||
59 | |||
60 | /* Call Decoder Specific function to set Static Params */ | ||
61 | pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams); | ||
62 | |||
63 | strcpy((char *)pVidDecComp->tComponentRole.cRole, | ||
64 | (char *)DecoderList[DEFAULT_COMPOENENT].cRole); | ||
65 | /* Set the Parse Header flag to XDM_PARSE_HEADER */ | ||
66 | pVidDecComp->nDecoderMode = XDM_PARSE_HEADER; | ||
67 | |||
68 | EXIT: | ||
69 | return (eError); | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * Video Decoder Component Init | ||
74 | */ | ||
75 | OMX_ERRORTYPE OMXVidDec_ComponentInit(OMX_HANDLETYPE hComponent) | ||
76 | { | ||
77 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
78 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
79 | OMXVidDecComp *pVidDecComp = NULL; | ||
80 | Engine_Error errorCode; | ||
81 | |||
82 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
83 | |||
84 | /* allocate the decoder component */ | ||
85 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
86 | pHandle->pComponentPrivate = (OMXVidDecComp*)OSAL_Malloc(sizeof(OMXVidDecComp)); | ||
87 | OMX_CHECK(pHandle->pComponentPrivate != NULL, OMX_ErrorInsufficientResources); | ||
88 | OSAL_Memset(pHandle->pComponentPrivate, 0x0, sizeof(OMXVidDecComp)); | ||
89 | |||
90 | pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate; | ||
91 | |||
92 | /*! Initialize the fields */ | ||
93 | eError = OMXVidDec_InitFields(pHandle->pComponentPrivate); | ||
94 | OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUndefined); | ||
95 | |||
96 | strcpy(pVidDecComp->sBase.cComponentName, OMX_VIDEODECODER_COMPONENT_NAME); | ||
97 | |||
98 | /* Initialize the base component */ | ||
99 | eError = OMXBase_ComponentInit(hComponent); | ||
100 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
101 | |||
102 | /*Setting default properties. | ||
103 | * PreCondition: NumOfPorts is filled and all pointers allocated*/ | ||
104 | eError = OMXBase_SetDefaultProperties(hComponent); | ||
105 | OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); | ||
106 | |||
107 | /*! Initialize function pointers for Command and Data Notify */ | ||
108 | pVidDecComp->sBase.fpCommandNotify = OMXVidDec_CommandNotify; | ||
109 | pVidDecComp->sBase.fpDataNotify = OMXVidDec_DataNotify; | ||
110 | pVidDecComp->sBase.fpXlateBuffHandle = OMXVidDec_XlateBuffHandle; | ||
111 | |||
112 | /*! Initialize the function parameters for OMX functions */ | ||
113 | pHandle->SetParameter = OMXVidDec_SetParameter; | ||
114 | pHandle->GetParameter = OMXVidDec_GetParameter; | ||
115 | pHandle->GetConfig = OMXVidDec_GetConfig; | ||
116 | pHandle->SetConfig = OMXVidDec_SetConfig; | ||
117 | pHandle->ComponentDeInit = OMXVidDec_ComponentDeinit; | ||
118 | pHandle->GetExtensionIndex = OMXVidDec_GetExtensionIndex; | ||
119 | |||
120 | /*! Open instance of Codec engine */ | ||
121 | pVidDecComp->ce = Engine_open(engineName, NULL, &errorCode); | ||
122 | pVidDecComp->pDecHandle = NULL; | ||
123 | pVidDecComp->nFrameCounter = 0; | ||
124 | pVidDecComp->bSyncFrameReady = OMX_FALSE; | ||
125 | pVidDecComp->nOutbufInUseFlag = 0; | ||
126 | pVidDecComp->nCodecRecreationRequired = 0; | ||
127 | pVidDecComp->nOutPortReconfigRequired = 0; | ||
128 | pVidDecComp->nFatalErrorGiven = 0; | ||
129 | pVidDecComp->bInputBufferCancelled = 0; | ||
130 | pVidDecComp->bIPCRecoveryNeeded = OMX_FALSE; | ||
131 | /*! Initialize the Framerate divisor to 1000 as codec is supposed provide framerate after by multiplying with 1000 */ | ||
132 | pVidDecComp->nFrameRateDivisor = 1000; | ||
133 | pVidDecComp->tCropDimension.nTop = 0; | ||
134 | pVidDecComp->tCropDimension.nLeft = 0; | ||
135 | pVidDecComp->tScaleParams.xWidth = 0x10000; | ||
136 | pVidDecComp->tScaleParams.xHeight = 0x10000; | ||
137 | pVidDecComp->bUsePortReconfigForCrop = OMX_TRUE; | ||
138 | pVidDecComp->bUsePortReconfigForPadding = OMX_TRUE; | ||
139 | pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_FALSE; | ||
140 | pVidDecComp->bSupportSkipGreyOutputFrames = OMX_TRUE; | ||
141 | pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_FALSE; | ||
142 | |||
143 | /*Optimize this pipe to be created only if decode timestamps is requested. */ | ||
144 | OSAL_CreatePipe(&(pVidDecComp->pTimeStampStoragePipe), MAX_REF_FRAMES * sizeof(OMX_TICKS), | ||
145 | sizeof(OMX_TICKS), 1); | ||
146 | |||
147 | pVidDecComp->tInBufDesc = (XDM2_BufDesc*)memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0); | ||
148 | OMX_CHECK(pVidDecComp->tInBufDesc != NULL, OMX_ErrorInsufficientResources); | ||
149 | OSAL_Memset(pVidDecComp->tInBufDesc, 0x0, sizeof(XDM2_BufDesc)); | ||
150 | |||
151 | pVidDecComp->tOutBufDesc = (XDM2_BufDesc*)memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0); | ||
152 | OMX_CHECK(pVidDecComp->tOutBufDesc != NULL, OMX_ErrorInsufficientResources); | ||
153 | OSAL_Memset(pVidDecComp->tOutBufDesc, 0x0, sizeof(XDM2_BufDesc)); | ||
154 | |||
155 | EXIT: | ||
156 | if( eError != OMX_ErrorNone ) { | ||
157 | if( pHandle != NULL ) { | ||
158 | OMXVidDec_ComponentDeinit(hComponent); | ||
159 | } | ||
160 | } | ||
161 | return (eError); | ||
162 | } | ||
163 | |||
164 | |||
165 | /* | ||
166 | * Video decoder setParameter | ||
167 | */ | ||
168 | OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent, | ||
169 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) | ||
170 | { | ||
171 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
172 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
173 | OMXVidDecComp *pVidDecComp = NULL; | ||
174 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs = NULL; | ||
175 | OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoParams = NULL; | ||
176 | OMX_CONFIG_RECTTYPE *p2DBufferAllocParams = NULL; | ||
177 | OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; | ||
178 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
179 | OMX_VIDEO_PARAM_PORTFORMATTYPE *pInPortFmtType = NULL; | ||
180 | OMX_VIDEO_PARAM_PORTFORMATTYPE *pOutPortFmtType = NULL; | ||
181 | OMX_CONFIG_RECTTYPE *pOut2DBufAllocParam = NULL; | ||
182 | OMX_CONFIG_RECTTYPE *pIn2DBufAllocParam = NULL; | ||
183 | OMX_U32 i=0; | ||
184 | OMX_U32 bFound = 0; | ||
185 | OMX_U32 nFrameHeight = 0; | ||
186 | OMX_U32 nFrameWidth = 0; | ||
187 | struct PrepareForAdaptivePlaybackParams *pPrepareForAdaptivePlaybackParams; | ||
188 | OMX_U32 framesize = 0; | ||
189 | OMX_U32 metasize = 0; | ||
190 | |||
191 | OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), OMX_ErrorBadParameter); | ||
192 | |||
193 | /*! Initialize the pointers */ | ||
194 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
195 | pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate; | ||
196 | |||
197 | switch( (int) nIndex ) { | ||
198 | case OMX_IndexParamPortDefinition : | ||
199 | { | ||
200 | /*! To set the Port Definition */ | ||
201 | OMX_BASE_CHK_VERSION(pParamStruct, | ||
202 | OMX_PARAM_PORTDEFINITIONTYPE, eError); | ||
203 | |||
204 | pPortDefs = (OMX_PARAM_PORTDEFINITIONTYPE *) pParamStruct; | ||
205 | pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); | ||
206 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
207 | |||
208 | //Check if an invalid port index is not sent | ||
209 | OMX_CHECK(pPortDefs->nPortIndex >= pVidDecComp->sBase.nMinStartPortIndex | ||
210 | && pPortDefs->nPortIndex < (pVidDecComp->sBase.nNumPorts + pVidDecComp->sBase.nMinStartPortIndex), | ||
211 | OMX_ErrorBadPortIndex); | ||
212 | |||
213 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
214 | // OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || | ||
215 | // (pVidDecComp->sBase.pPorts[pPortDefs->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), | ||
216 | // OMX_ErrorIncorrectStateOperation); | ||
217 | // If Input Port Parameters have to be changed | ||
218 | if( pPortDefs->nPortIndex == pInputPortDef->nPortIndex ) { | ||
219 | /*! Check for correct resolution of the stream */ | ||
220 | nFrameWidth = pPortDefs->format.video.nFrameWidth; | ||
221 | nFrameHeight = pPortDefs->format.video.nFrameHeight; | ||
222 | |||
223 | OMX_CHECK((nFrameWidth <= OMX_VIDDEC_MAX_WIDTH), | ||
224 | OMX_ErrorUnsupportedSetting); | ||
225 | OMX_CHECK((nFrameHeight <= OMX_VIDDEC_MAX_HEIGHT), | ||
226 | OMX_ErrorUnsupportedSetting); | ||
227 | OMX_CHECK((((nFrameWidth * nFrameHeight) >> 16) <= OMX_VIDDEC_MAX_MACROBLOCK), | ||
228 | OMX_ErrorUnsupportedSetting); | ||
229 | |||
230 | /*! Call function to set input port definition */ | ||
231 | eError = OMXVidDec_SetInPortDef(hComponent, pPortDefs); | ||
232 | if( eError != OMX_ErrorNone ) { | ||
233 | goto EXIT; | ||
234 | } | ||
235 | if( pVidDecComp->sBase.tCurState != OMX_StateLoaded ) { | ||
236 | pVidDecComp->nCodecRecreationRequired = 1; | ||
237 | } | ||
238 | } | ||
239 | // If Output Port Parameters have to be changed | ||
240 | else if( pPortDefs->nPortIndex == pOutputPortDef->nPortIndex ) { | ||
241 | // Check the buffer cnt is greater than min required | ||
242 | // buffer count | ||
243 | OMX_CHECK((pPortDefs->nBufferCountActual | ||
244 | >= pOutputPortDef->nBufferCountMin), | ||
245 | OMX_ErrorUnsupportedSetting); | ||
246 | // Check if Resolution being set at output port is same | ||
247 | // as the input port | ||
248 | OMX_CHECK((pOutputPortDef->format.video.nFrameHeight | ||
249 | == pPortDefs->format.video.nFrameHeight) | ||
250 | && (pOutputPortDef->format.video.nFrameWidth | ||
251 | == pPortDefs->format.video.nFrameWidth), | ||
252 | OMX_ErrorUnsupportedSetting); | ||
253 | |||
254 | OMX_CHECK((OMX_U32)pPortDefs->format.video.nStride >= | ||
255 | pOutputPortDef->format.video.nFrameWidth, | ||
256 | OMX_ErrorUnsupportedSetting); | ||
257 | if( (OMX_U32)pPortDefs->format.video.nStride > | ||
258 | pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) { | ||
259 | //Supported values of stride are only multiples of 128 | ||
260 | OMX_CHECK((pPortDefs->format.video.nStride & 0x7F) == 0, | ||
261 | OMX_ErrorUnsupportedSetting); | ||
262 | } | ||
263 | //Check for the supported Color-fromat | ||
264 | //and compression format. | ||
265 | |||
266 | if (pVidDecComp->sBase.pPorts[pOutputPortDef->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) { | ||
267 | //OMX_CHECK((pOutputPortDef->format.video.eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT), | ||
268 | // OMX_ErrorUnsupportedSetting); | ||
269 | } else { | ||
270 | OMX_CHECK((pOutputPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar), | ||
271 | OMX_ErrorUnsupportedSetting); | ||
272 | } | ||
273 | |||
274 | OMX_CHECK((pOutputPortDef->format.video.eCompressionFormat == | ||
275 | OMX_VIDEO_CodingUnused), | ||
276 | OMX_ErrorUnsupportedSetting); | ||
277 | |||
278 | /*! Call function to set output port definition */ | ||
279 | eError = OMXVidDec_SetOutPortDef(pVidDecComp, pPortDefs); | ||
280 | if( eError != OMX_ErrorNone ) { | ||
281 | goto EXIT; | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | |||
286 | /* If MPEG2 and Error Concealment; then memplugin_alloc for pOutBufDescPtr->descs[2] one time allocation only.*/ | ||
287 | if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) { | ||
288 | if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment) { | ||
289 | /* It's MPEG2 and ErrorConcealment is ON; calculate metadata buffer size based on formula described in MPEG2 User Guide */ | ||
290 | framesize = (((pInputPortDef->format.video.nFrameWidth + 15) / 16) * 16) * (((pInputPortDef->format.video.nFrameHeight + 15) / 16) * 16); | ||
291 | metasize = ((framesize >> 8) * 112) + framesize; | ||
292 | if (pVidDecComp->pmetaBuffer && pVidDecComp->pmetaBuffer->size < metasize) { | ||
293 | memplugin_free((void*)H2P(pVidDecComp->pmetaBuffer)); | ||
294 | pVidDecComp->pmetaBuffer = NULL; | ||
295 | } | ||
296 | if (pVidDecComp->pmetaBuffer == NULL) { | ||
297 | pVidDecComp->pmetaBuffer = P2H(memplugin_alloc(metasize, 1, MEM_CARVEOUT, 0, 0)); | ||
298 | OMX_CHECK(pVidDecComp->pmetaBuffer != NULL, OMX_ErrorInsufficientResources); | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | break; | ||
303 | |||
304 | case OMX_IndexParamVideoPortFormat : | ||
305 | { | ||
306 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError); | ||
307 | pVideoParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *) pParamStruct; | ||
308 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
309 | OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) || | ||
310 | (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sPortDef.bEnabled == OMX_FALSE), | ||
311 | OMX_ErrorIncorrectStateOperation); | ||
312 | |||
313 | pInPortFmtType = &(pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT]); | ||
314 | pOutPortFmtType = &(pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT]); | ||
315 | // If Input Port Format type has to be changed | ||
316 | if( pVideoParams->nPortIndex == pInPortFmtType->nPortIndex ) { | ||
317 | // Change Compression type and frame-rate | ||
318 | pInPortFmtType->eCompressionFormat | ||
319 | = pVideoParams->eCompressionFormat; | ||
320 | pInPortFmtType->xFramerate = pVideoParams->xFramerate; | ||
321 | } | ||
322 | // In case Output Port Format type has to be changed | ||
323 | else if( pVideoParams->nPortIndex == pOutPortFmtType->nPortIndex ) { | ||
324 | //Check for the supported Color-fromat | ||
325 | //and compression format. | ||
326 | if (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) { | ||
327 | // OMX_CHECK((pVideoParams->eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT), | ||
328 | // OMX_ErrorUnsupportedSetting); | ||
329 | } else { | ||
330 | OMX_CHECK((pVideoParams->eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar), | ||
331 | OMX_ErrorUnsupportedSetting); | ||
332 | } | ||
333 | OMX_CHECK((pVideoParams->eCompressionFormat == | ||
334 | OMX_VIDEO_CodingUnused), OMX_ErrorUnsupportedSetting); | ||
335 | |||
336 | pOutputPortDef->format.video.eColorFormat | ||
337 | = pVideoParams->eColorFormat; | ||
338 | |||
339 | // Change Compression type, color format and frame-rate | ||
340 | pOutPortFmtType->eCompressionFormat | ||
341 | = pVideoParams->eCompressionFormat; | ||
342 | pOutPortFmtType->eColorFormat = pVideoParams->eColorFormat; | ||
343 | pOutPortFmtType->xFramerate = pVideoParams->xFramerate; | ||
344 | } | ||
345 | } | ||
346 | break; | ||
347 | |||
348 | case OMX_IndexParamStandardComponentRole : | ||
349 | { | ||
350 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_COMPONENTROLETYPE, eError); | ||
351 | |||
352 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
353 | OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, | ||
354 | OMX_ErrorIncorrectStateOperation); | ||
355 | /*! In case there is change in Role */ | ||
356 | if( strcmp((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole, | ||
357 | (char *)pVidDecComp->tComponentRole.cRole)) { | ||
358 | /* De-initialize the current codec */ | ||
359 | pVidDecComp->fpDeinit_Codec(hComponent); | ||
360 | |||
361 | /* Call specific component init depending upon the | ||
362 | cRole set. */ | ||
363 | i=0; | ||
364 | while( NULL != DecoderList[i].cRole[0] ) { | ||
365 | if( strcmp((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole, | ||
366 | (char *)DecoderList[i].cRole) == 0 ) { | ||
367 | /* Component found */ | ||
368 | bFound = 1; | ||
369 | break; | ||
370 | } | ||
371 | i++; | ||
372 | } | ||
373 | |||
374 | if( bFound == 0 ) { | ||
375 | OSAL_ErrorTrace("Unsupported Role set"); | ||
376 | eError = OMX_ErrorUnsupportedSetting; | ||
377 | goto EXIT; | ||
378 | } | ||
379 | /* Call the Specific Decoder Init function and Initialize Params */ | ||
380 | eError = DecoderList[i].fpDecoderComponentInit(hComponent); | ||
381 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
382 | OMXVidDec_InitDecoderParams(hComponent, pHandle->pComponentPrivate); | ||
383 | |||
384 | strcpy((char *)pVidDecComp->tComponentRole.cRole, | ||
385 | (char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole); | ||
386 | } | ||
387 | } | ||
388 | break; | ||
389 | |||
390 | case OMX_TI_IndexParamTimeStampInDecodeOrder : | ||
391 | { | ||
392 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER, eError); | ||
393 | |||
394 | /* SetParameter can be invoked in Loaded State or on Disabled ports only*/ | ||
395 | OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, | ||
396 | OMX_ErrorIncorrectStateOperation); | ||
397 | if(((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled == OMX_TRUE ) { | ||
398 | pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_TRUE; | ||
399 | } else { | ||
400 | pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_FALSE; | ||
401 | } | ||
402 | } | ||
403 | break; | ||
404 | |||
405 | case (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode : | ||
406 | { | ||
407 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE, eError); | ||
408 | |||
409 | /* This SetParameter can be invoked in Loaded State only as it needs codec recreate.*/ | ||
410 | OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, | ||
411 | OMX_ErrorIncorrectStateOperation); | ||
412 | if(((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled == OMX_TRUE ) { | ||
413 | pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_TRUE; | ||
414 | } else { | ||
415 | pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_FALSE; | ||
416 | } | ||
417 | } | ||
418 | break; | ||
419 | |||
420 | case (OMX_INDEXTYPE) OMX_TI_IndexPrepareForAdaptivePlayback: | ||
421 | { | ||
422 | OMX_BASE_CHK_VERSION(pParamStruct, PrepareForAdaptivePlaybackParams, eError); | ||
423 | /* This SetParameter can be invoked in Loaded State only as it needs codec recreate.*/ | ||
424 | OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded, | ||
425 | OMX_ErrorIncorrectStateOperation); | ||
426 | pPrepareForAdaptivePlaybackParams = (PrepareForAdaptivePlaybackParams *) pParamStruct; | ||
427 | pVidDecComp->bisAdaptivePlayback = pPrepareForAdaptivePlaybackParams->bEnable; | ||
428 | pVidDecComp->nAdaptiveMaxFrameWidth = pPrepareForAdaptivePlaybackParams->nMaxFrameWidth; | ||
429 | pVidDecComp->nAdaptiveMaxFrameHeight = pPrepareForAdaptivePlaybackParams->nMaxFrameHeight; | ||
430 | } | ||
431 | break; | ||
432 | |||
433 | |||
434 | default : | ||
435 | eError = OMXBase_SetParameter(hComponent, nIndex, pParamStruct); | ||
436 | } | ||
437 | |||
438 | EXIT: | ||
439 | return (eError); | ||
440 | } | ||
441 | |||
442 | /* | ||
443 | * Video Decoder Get Parameter | ||
444 | */ | ||
445 | OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent, | ||
446 | OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct) | ||
447 | { | ||
448 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
449 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
450 | OMXVidDecComp *pVidDecComp = NULL; | ||
451 | OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoParams = NULL; | ||
452 | OMX_CONFIG_RECTTYPE *p2DBufferAllocParams = NULL; | ||
453 | OMX_VIDEO_PARAM_PORTFORMATTYPE inPortParam; | ||
454 | OMX_VIDEO_PARAM_PORTFORMATTYPE outPortParam; | ||
455 | OMX_TI_PARAMNATIVEBUFFERUSAGE *pUsage = NULL; | ||
456 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | ||
457 | OMX_U32 nStartPortNumber, nPorts, nPortIndex; | ||
458 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
459 | struct DescribeColorFormatParams *Colorparams; | ||
460 | |||
461 | OMX_CHECK((hComponent != NULL) && | ||
462 | (pParamStruct != NULL), OMX_ErrorBadParameter); | ||
463 | |||
464 | // Initialize the local variables | ||
465 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
466 | pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate; | ||
467 | |||
468 | /* GetParameter can't be invoked incase the comp is in Invalid State */ | ||
469 | OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, | ||
470 | OMX_ErrorIncorrectStateOperation); | ||
471 | |||
472 | switch( (int) nIndex ) { | ||
473 | case OMX_IndexParamPortDefinition: | ||
474 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, | ||
475 | eError); | ||
476 | pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; | ||
477 | |||
478 | nPorts = pVidDecComp->sBase.nNumPorts; | ||
479 | nStartPortNumber = pVidDecComp->sBase.nMinStartPortIndex; | ||
480 | |||
481 | nPortIndex = pPortDef->nPortIndex - nStartPortNumber; | ||
482 | /* check for valid port index */ | ||
483 | OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex); | ||
484 | *pPortDef = pVidDecComp->sBase.pPorts[nPortIndex]->sPortDef; | ||
485 | if (pPortDef->eDir == OMX_DirOutput && | ||
486 | pVidDecComp->sBase.pPorts[nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) { | ||
487 | pPortDef->format.video.eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT; | ||
488 | } | ||
489 | break; | ||
490 | |||
491 | case OMX_IndexParamVideoPortFormat : | ||
492 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError); | ||
493 | // Initialize Port Params | ||
494 | pVideoParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *) pParamStruct; | ||
495 | inPortParam = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT]; | ||
496 | outPortParam = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT]; | ||
497 | if( pVideoParams->nPortIndex == inPortParam.nPortIndex ) { | ||
498 | if( pVideoParams->nIndex > inPortParam.nIndex ) { | ||
499 | return (OMX_ErrorNoMore); | ||
500 | } | ||
501 | pVideoParams->eCompressionFormat = inPortParam.eCompressionFormat; | ||
502 | pVideoParams->eColorFormat = inPortParam.eColorFormat; | ||
503 | pVideoParams->xFramerate = inPortParam.xFramerate; | ||
504 | if(pVideoParams->eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) | ||
505 | pVideoParams->eColorFormat = OMX_COLOR_FormatYUV420Flexible; // OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; | ||
506 | } else if( pVideoParams->nPortIndex == outPortParam.nPortIndex ) { | ||
507 | if( pVideoParams->nIndex == 0 ) { | ||
508 | if (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) { | ||
509 | pVideoParams->eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT; | ||
510 | } else { | ||
511 | pVideoParams->eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; | ||
512 | } | ||
513 | } else if( pVideoParams->nIndex > outPortParam.nIndex ) { | ||
514 | return (OMX_ErrorNoMore); | ||
515 | } | ||
516 | pVideoParams->eCompressionFormat = outPortParam.eCompressionFormat; | ||
517 | pVideoParams->xFramerate = outPortParam.xFramerate; | ||
518 | } | ||
519 | break; | ||
520 | |||
521 | case OMX_IndexParamStandardComponentRole : | ||
522 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_COMPONENTROLETYPE, eError); | ||
523 | strcpy((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole, | ||
524 | (char *)pVidDecComp->tComponentRole.cRole); | ||
525 | break; | ||
526 | |||
527 | case (OMX_INDEXTYPE) OMX_TI_IndexAndroidNativeBufferUsage: | ||
528 | pUsage = (OMX_TI_PARAMNATIVEBUFFERUSAGE*)pParamStruct; | ||
529 | pUsage->nUsage = GRALLOC_USAGE_HW_RENDER; | ||
530 | break; | ||
531 | |||
532 | case (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat: | ||
533 | Colorparams = (struct DescribeColorFormatParams*)(pParamStruct); | ||
534 | |||
535 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
536 | |||
537 | struct MediaImage *image = &(Colorparams->sMediaImage); | ||
538 | memset(image, 0, sizeof(MediaImage)); | ||
539 | |||
540 | image->mWidth = pOutputPortDef->format.video.nFrameWidth; | ||
541 | image->mHeight = pOutputPortDef->format.video.nFrameHeight; | ||
542 | |||
543 | image->mType = MEDIA_IMAGE_TYPE_YUV; | ||
544 | image->mNumPlanes = 3; | ||
545 | image->mBitDepth = 8; | ||
546 | /* The crop left and top calculation is not needed here. | ||
547 | Stagefright will add pBuffer->nOffset to this Y offset. */ | ||
548 | image->mPlane[Y].mOffset = 0; | ||
549 | image->mPlane[Y].mColInc = 1; | ||
550 | image->mPlane[Y].mRowInc = pOutputPortDef->format.video.nStride; | ||
551 | image->mPlane[Y].mHorizSubsampling = 1; | ||
552 | image->mPlane[Y].mVertSubsampling = 1; | ||
553 | |||
554 | /* Since the position of the Buffer is at the starting of Y buffer (UV offset from base - Y offset), | ||
555 | UV offset = (Stride*Height + (Top/2)*Stride + Left )- (Top*Stride + Left) | ||
556 | on simplification | ||
557 | UV offset = Stride*Height - (Top/2)*Stride */ | ||
558 | image->mPlane[U].mOffset = pOutputPortDef->format.video.nStride * pOutputPortDef->format.video.nFrameHeight; | ||
559 | image->mPlane[U].mColInc = 2; | ||
560 | image->mPlane[U].mRowInc = pOutputPortDef->format.video.nStride; | ||
561 | image->mPlane[U].mHorizSubsampling = 2; | ||
562 | image->mPlane[U].mVertSubsampling = 2; | ||
563 | |||
564 | image->mPlane[V].mOffset = image->mPlane[U].mOffset + 1; | ||
565 | image->mPlane[V].mColInc = 2; | ||
566 | image->mPlane[V].mRowInc = pOutputPortDef->format.video.nStride; | ||
567 | image->mPlane[V].mHorizSubsampling = 2; | ||
568 | image->mPlane[V].mVertSubsampling = 2; | ||
569 | |||
570 | break; | ||
571 | |||
572 | case (OMX_INDEXTYPE) OMX_TI_IndexParamTimeStampInDecodeOrder : | ||
573 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER, eError); | ||
574 | if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { | ||
575 | ((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled = OMX_TRUE; | ||
576 | } else { | ||
577 | ((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled = OMX_FALSE; | ||
578 | } | ||
579 | break; | ||
580 | |||
581 | case (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode : | ||
582 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE, eError); | ||
583 | if( pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE ) { | ||
584 | ((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled = OMX_TRUE; | ||
585 | } else { | ||
586 | ((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled = OMX_FALSE; | ||
587 | } | ||
588 | break; | ||
589 | |||
590 | default : | ||
591 | eError = OMXBase_GetParameter(hComponent, nIndex, pParamStruct); | ||
592 | } | ||
593 | |||
594 | EXIT: | ||
595 | return (eError); | ||
596 | } | ||
597 | |||
598 | /* | ||
599 | * Video decoder GetConfig | ||
600 | */ | ||
601 | OMX_ERRORTYPE OMXVidDec_GetConfig(OMX_HANDLETYPE hComponent, | ||
602 | OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure) { | ||
603 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
604 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
605 | OMXVidDecComp *pVidDecComp = NULL; | ||
606 | OMX_CONFIG_RECTTYPE *pCropParams = NULL; | ||
607 | OMX_CONFIG_SCALEFACTORTYPE *pScaleParams = NULL; | ||
608 | |||
609 | OMX_CHECK((hComponent != NULL) && | ||
610 | (pComponentConfigStructure != NULL), OMX_ErrorBadParameter); | ||
611 | |||
612 | // Initialize the local variables | ||
613 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
614 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
615 | |||
616 | /* GetConfig can't be invoked incase the comp is in Invalid State */ | ||
617 | OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, | ||
618 | OMX_ErrorIncorrectStateOperation); | ||
619 | |||
620 | switch( nIndex ) { | ||
621 | case OMX_IndexConfigCommonOutputCrop : | ||
622 | { | ||
623 | OMX_BASE_CHK_VERSION(pComponentConfigStructure, OMX_CONFIG_RECTTYPE, eError); | ||
624 | pCropParams = (OMX_CONFIG_RECTTYPE *) pComponentConfigStructure; | ||
625 | if( pCropParams->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
626 | pCropParams->nWidth = pVidDecComp->tCropDimension.nWidth; | ||
627 | pCropParams->nHeight = pVidDecComp->tCropDimension.nHeight; | ||
628 | pCropParams->nTop = pVidDecComp->tCropDimension.nTop; | ||
629 | pCropParams->nLeft = pVidDecComp->tCropDimension.nLeft; | ||
630 | } else { | ||
631 | eError = OMX_ErrorBadParameter; | ||
632 | OSAL_ErrorTrace("OMX_IndexConfigCommonOutputCrop called on i/p port. Not Supported."); | ||
633 | } | ||
634 | } | ||
635 | break; | ||
636 | |||
637 | case OMX_IndexConfigCommonScale : | ||
638 | { | ||
639 | OMX_BASE_CHK_VERSION(pComponentConfigStructure, OMX_CONFIG_SCALEFACTORTYPE, eError); | ||
640 | pScaleParams = (OMX_CONFIG_SCALEFACTORTYPE *) pComponentConfigStructure; | ||
641 | if( pScaleParams->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) { | ||
642 | pScaleParams->xWidth = pVidDecComp->tScaleParams.xWidth; | ||
643 | pScaleParams->xHeight = pVidDecComp->tScaleParams.xHeight; | ||
644 | OSAL_ErrorTrace("OMX_IndexConfigCommonScale called on o/p port."); | ||
645 | } else { | ||
646 | eError = OMX_ErrorBadParameter; | ||
647 | OSAL_ErrorTrace("OMX_IndexConfigCommonOutputCrop called on i/p port. Not Supported."); | ||
648 | } | ||
649 | } | ||
650 | break; | ||
651 | |||
652 | default : | ||
653 | eError = OMXBase_GetConfig(hComponent, nIndex, pComponentConfigStructure); | ||
654 | } | ||
655 | |||
656 | EXIT: | ||
657 | return (eError); | ||
658 | } | ||
659 | |||
660 | /* | ||
661 | * Video Decoder SetConfig | ||
662 | */ | ||
663 | OMX_ERRORTYPE OMXVidDec_SetConfig(OMX_HANDLETYPE hComponent, | ||
664 | OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure) { | ||
665 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
666 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
667 | OMXVidDecComp *pVidDecComp = NULL; | ||
668 | |||
669 | OMX_CHECK((hComponent != NULL) && | ||
670 | (pComponentConfigStructure != NULL), OMX_ErrorBadParameter); | ||
671 | |||
672 | // Initialize the local variables | ||
673 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
674 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
675 | |||
676 | /* SetConfig can't be invoked incase the comp is in Invalid State */ | ||
677 | OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid, | ||
678 | OMX_ErrorIncorrectStateOperation); | ||
679 | |||
680 | switch( nIndex ) { | ||
681 | default : | ||
682 | eError = OMXBase_SetConfig(hComponent, nIndex, pComponentConfigStructure); | ||
683 | } | ||
684 | |||
685 | EXIT: | ||
686 | return (eError); | ||
687 | } | ||
688 | |||
689 | /* | ||
690 | * Video Decoder xlateBuffer Handles | ||
691 | */ | ||
692 | OMX_ERRORTYPE OMXVidDec_XlateBuffHandle(OMX_HANDLETYPE hComponent, | ||
693 | OMX_PTR pBufferHdr, OMX_BOOL bRegister) | ||
694 | { | ||
695 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
696 | OMX_COMPONENTTYPE *pComp = NULL; | ||
697 | OMXVidDecComp *pVidDecComp = NULL; | ||
698 | OMX_BUFFERHEADERTYPE *pOMXBufHeader; | ||
699 | OMXBase_Port *pPort; | ||
700 | OMX_U32 nPortIndex; | ||
701 | int32_t tRetVal; | ||
702 | int i; | ||
703 | |||
704 | pComp = (OMX_COMPONENTTYPE *)(hComponent); | ||
705 | pVidDecComp = (OMXVidDecComp *)pComp->pComponentPrivate; | ||
706 | |||
707 | pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) (pBufferHdr); | ||
708 | nPortIndex = (pOMXBufHeader->nInputPortIndex == OMX_NOPORT) ? | ||
709 | pOMXBufHeader->nOutputPortIndex : | ||
710 | pOMXBufHeader->nInputPortIndex; | ||
711 | |||
712 | pPort = pVidDecComp->sBase.pPorts[nPortIndex]; | ||
713 | |||
714 | /* Non a buffer allocator, then check if any xlation is needed */ | ||
715 | if (pPort->sProps.eBufMemoryType == MEM_GRALLOC) { | ||
716 | //populate the DMA BUFF_FDs from the gralloc pointers | ||
717 | for ( i = 0; i < MAX_PLANES_PER_BUFFER; i++ ) { | ||
718 | ((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd = (OMX_U32)(((IMG_native_handle_t*)(pOMXBufHeader->pBuffer))->fd[i]); | ||
719 | if (((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd > 0) { | ||
720 | if (bRegister) { | ||
721 | dce_buf_lock(1, (size_t *)&(((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd)); | ||
722 | } else { | ||
723 | dce_buf_unlock(1, (size_t *)&(((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd)); | ||
724 | } | ||
725 | } | ||
726 | } | ||
727 | } | ||
728 | |||
729 | EXIT: | ||
730 | return (eError); | ||
731 | } | ||
732 | |||
733 | /* | ||
734 | * video decoder Command Notify | ||
735 | */ | ||
736 | OMX_ERRORTYPE OMXVidDec_CommandNotify(OMX_HANDLETYPE hComponent, | ||
737 | OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData) | ||
738 | { | ||
739 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
740 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
741 | OMXVidDecComp *pVidDecComp = NULL; | ||
742 | XDAS_Int32 status; | ||
743 | OMX_U32 ReturnCmdCompletionCallBack = 1, i; | ||
744 | OMX_PTR pDecStaticParams; | ||
745 | OMX_PTR pDecDynamicParams; | ||
746 | OMX_PTR pDecStatus; | ||
747 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef; | ||
748 | OMX_U32 nFrameWidth, nFrameHeight; | ||
749 | OMX_U32 nFrameWidthOrig; | ||
750 | (void) pCmdData; | ||
751 | |||
752 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
753 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
754 | pVidDecComp = pHandle->pComponentPrivate; | ||
755 | |||
756 | switch( Cmd ) { | ||
757 | case OMX_CommandStateSet : | ||
758 | if( pVidDecComp->sBase.tCurState == OMX_StateLoaded && | ||
759 | pVidDecComp->sBase.tNewState == OMX_StateIdle ) { | ||
760 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
761 | // Check the buffer cnt is greater than min required | ||
762 | // buffer count | ||
763 | if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) { | ||
764 | OSAL_ErrorTrace("Number of actual buffers on o/p port less than the minmum required by componenet as set on o/p port defs"); | ||
765 | eError = OMX_ErrorUnsupportedSetting; | ||
766 | goto EXIT; | ||
767 | } | ||
768 | |||
769 | // Transitioning from Loaded to Idle state | ||
770 | if(pVidDecComp->pDecHandle == NULL ) { | ||
771 | pDecStaticParams = pVidDecComp->pDecStaticParams; | ||
772 | // Call the Video Decoder Create Call | ||
773 | pVidDecComp->pDecHandle | ||
774 | = VIDDEC3_create(pVidDecComp->ce, | ||
775 | pVidDecComp->cDecoderName, | ||
776 | (VIDDEC3_Params *) pDecStaticParams); | ||
777 | |||
778 | if( pVidDecComp->pDecHandle == NULL ) { | ||
779 | OSAL_ErrorTrace("VIDDEC3_create failed ....! \n"); | ||
780 | eError = OMX_ErrorInsufficientResources; | ||
781 | pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE; | ||
782 | goto EXIT; | ||
783 | } | ||
784 | pVidDecComp->nCodecRecreationRequired = 0; | ||
785 | pVidDecComp->nOutPortReconfigRequired = 0; | ||
786 | |||
787 | // Populate Dynamic Params and the Status structures | ||
788 | pVidDecComp->fpSet_DynamicParams(hComponent, pVidDecComp->pDecDynParams); | ||
789 | pVidDecComp->fpSet_Status(hComponent, pVidDecComp->pDecStatus); | ||
790 | //This is to handle Arbitrary stride requirement given by IL client. | ||
791 | if((OMX_U32)pOutputPortDef->format.video.nStride > | ||
792 | pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth) { | ||
793 | pVidDecComp->pDecDynParams->displayWidth = | ||
794 | pOutputPortDef->format.video.nStride; | ||
795 | } | ||
796 | pDecDynamicParams = pVidDecComp->pDecDynParams; | ||
797 | pDecStatus = pVidDecComp->pDecStatus; | ||
798 | |||
799 | OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); | ||
800 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
801 | if( status != VIDDEC3_EOK ) { | ||
802 | OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed! \n"); | ||
803 | eError = OMX_ErrorInsufficientResources; | ||
804 | goto EXIT; | ||
805 | } | ||
806 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
807 | |||
808 | // Call the Decoder Control function | ||
809 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETBUFINFO, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
810 | if( status != VIDDEC3_EOK ) { | ||
811 | OSAL_ErrorTrace("VIDDEC3_control XDM_GETBUFINFO failed! \n"); | ||
812 | eError = OMX_ErrorInsufficientResources; | ||
813 | goto EXIT; | ||
814 | } | ||
815 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
816 | } | ||
817 | } else if( pVidDecComp->sBase.tCurState == OMX_StateIdle && | ||
818 | pVidDecComp->sBase.tNewState == OMX_StateLoaded ) { | ||
819 | // Transitioning from Idle to Loaded | ||
820 | if( pVidDecComp->pDecHandle != NULL ) { | ||
821 | // Delete the Decoder Component Private Handle | ||
822 | pVidDecComp->nFrameCounter = 0; | ||
823 | if( pVidDecComp->bSupportSkipGreyOutputFrames ) { | ||
824 | pVidDecComp->bSyncFrameReady = OMX_FALSE; | ||
825 | } | ||
826 | |||
827 | pVidDecComp->nOutbufInUseFlag = 0; | ||
828 | VIDDEC3_delete(pVidDecComp->pDecHandle); | ||
829 | pVidDecComp->pDecHandle = NULL; | ||
830 | } | ||
831 | |||
832 | } else if(((pVidDecComp->sBase.tCurState == OMX_StateExecuting) && | ||
833 | (pVidDecComp->sBase.tNewState == OMX_StateIdle)) || | ||
834 | ((pVidDecComp->sBase.tCurState == OMX_StatePause) && | ||
835 | (pVidDecComp->sBase.tNewState == OMX_StateIdle))) { | ||
836 | OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL); | ||
837 | } | ||
838 | |||
839 | break; | ||
840 | |||
841 | case OMX_CommandPortDisable : | ||
842 | // In case of Port Disable Command | ||
843 | // Loaded state implies codec is deleted. so no need to delete again | ||
844 | if( pVidDecComp->sBase.tCurState != OMX_StateLoaded | ||
845 | && pVidDecComp->pDecHandle != NULL ) { | ||
846 | // Call Decoder Flush function | ||
847 | OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL); | ||
848 | } | ||
849 | break; | ||
850 | |||
851 | case OMX_CommandPortEnable : | ||
852 | if( nParam == OMX_VIDDEC_OUTPUT_PORT ) { | ||
853 | // Check the buffer cnt is greater than min required | ||
854 | // buffer count | ||
855 | pOutputPortDef = | ||
856 | &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
857 | if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) { | ||
858 | OSAL_ErrorTrace("Number of actual buffers on o/p port less than the minmum required by componenet as set on o/p port defs"); | ||
859 | eError = OMX_ErrorUnsupportedSetting; | ||
860 | goto EXIT; | ||
861 | } | ||
862 | if( (OMX_U32)pOutputPortDef->format.video.nStride < | ||
863 | pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) { | ||
864 | OSAL_ErrorTrace("Unsupported Stride set on o/p port defs"); | ||
865 | eError = OMX_ErrorUnsupportedSetting; | ||
866 | goto EXIT; | ||
867 | } | ||
868 | } | ||
869 | if( pVidDecComp->sBase.tCurState != OMX_StateLoaded ) { | ||
870 | if( pVidDecComp->nCodecRecreationRequired == 1 | ||
871 | && pVidDecComp->pDecHandle != NULL ) { | ||
872 | pVidDecComp->nCodecRecreationRequired = 0; | ||
873 | pVidDecComp->nFrameCounter = 0; | ||
874 | pVidDecComp->tScaleParams.xWidth = 0x10000; | ||
875 | pVidDecComp->tScaleParams.xHeight = 0x10000; | ||
876 | if( pVidDecComp->bSupportSkipGreyOutputFrames ) { | ||
877 | pVidDecComp->bSyncFrameReady = OMX_FALSE; | ||
878 | } | ||
879 | pVidDecComp->nOutbufInUseFlag = 0; | ||
880 | VIDDEC3_delete(pVidDecComp->pDecHandle); | ||
881 | pVidDecComp->pDecHandle = NULL; | ||
882 | |||
883 | pOutputPortDef = | ||
884 | &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
885 | // Set the Static Params | ||
886 | pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams); | ||
887 | if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE | ||
888 | && pVidDecComp->pDecStatus->outputWidth != 0 | ||
889 | && pVidDecComp->pDecStatus->outputHeight != 0 ) { | ||
890 | nFrameWidth = pVidDecComp->pDecStatus->outputWidth; | ||
891 | nFrameHeight = pVidDecComp->pDecStatus->outputHeight; | ||
892 | } else { | ||
893 | nFrameWidth = pOutputPortDef->format.video.nFrameWidth; | ||
894 | nFrameHeight = pOutputPortDef->format.video.nFrameHeight; | ||
895 | } | ||
896 | if( nFrameWidth & 0x0F ) { | ||
897 | nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); | ||
898 | } | ||
899 | if( nFrameHeight & 0x1F ) { | ||
900 | nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); | ||
901 | } | ||
902 | nFrameWidthOrig = pOutputPortDef->format.video.nFrameWidth; | ||
903 | if( nFrameWidthOrig & 0x0F ) { | ||
904 | nFrameWidthOrig = nFrameWidthOrig + 16 - (nFrameWidthOrig & 0x0F); | ||
905 | } | ||
906 | pVidDecComp->pDecStaticParams->maxHeight = nFrameHeight; | ||
907 | pVidDecComp->pDecStaticParams->maxWidth = nFrameWidth; | ||
908 | |||
909 | /* Check whether the displayWidth already accounts for any | ||
910 | * difference between the current and new frame width and | ||
911 | * set maxWidth accordingly */ | ||
912 | if ( nFrameWidth != nFrameWidthOrig && | ||
913 | nFrameWidthOrig == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) { | ||
914 | pVidDecComp->pDecStaticParams->maxWidth = nFrameWidthOrig; | ||
915 | } | ||
916 | |||
917 | // And Call the Codec Create | ||
918 | pVidDecComp->pDecHandle = VIDDEC3_create(pVidDecComp->ce, | ||
919 | pVidDecComp->cDecoderName, | ||
920 | (VIDDEC3_Params *) | ||
921 | pVidDecComp->pDecStaticParams); | ||
922 | if( pVidDecComp->pDecHandle == NULL ) { | ||
923 | OSAL_ErrorTrace("VIDDEC3_create failed ....! \n"); | ||
924 | eError = OMX_ErrorInsufficientResources; | ||
925 | pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE; | ||
926 | goto EXIT; | ||
927 | } | ||
928 | |||
929 | // Populate Dynamic Params and the Status structures | ||
930 | pVidDecComp->fpSet_DynamicParams(hComponent, pVidDecComp->pDecDynParams); | ||
931 | pVidDecComp->fpSet_Status(hComponent, pVidDecComp->pDecStatus); | ||
932 | //This is to handle Arbitrary stride requirement given by IL client. | ||
933 | if((OMX_U32)pOutputPortDef->format.video.nStride != | ||
934 | pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth) { | ||
935 | pVidDecComp->pDecDynParams->displayWidth = | ||
936 | pOutputPortDef->format.video.nStride; | ||
937 | } | ||
938 | pDecDynamicParams = pVidDecComp->pDecDynParams; | ||
939 | pDecStatus = pVidDecComp->pDecStatus; | ||
940 | |||
941 | // Call the Decoder Control function | ||
942 | OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); | ||
943 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
944 | if( status != VIDDEC3_EOK ) { | ||
945 | OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed! \n"); | ||
946 | eError = OMX_ErrorInsufficientResources; | ||
947 | goto EXIT; | ||
948 | } | ||
949 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
950 | } | ||
951 | pVidDecComp->nOutPortReconfigRequired = 0; | ||
952 | } | ||
953 | |||
954 | break; | ||
955 | |||
956 | case OMX_CommandFlush : | ||
957 | { | ||
958 | // In case of Flush Command | ||
959 | // In case all ports have to be flushed or the output port | ||
960 | // has to be flushed | ||
961 | if( nParam == OMX_ALL || nParam == OMX_VIDDEC_OUTPUT_PORT ) { | ||
962 | // Only then flush the port | ||
963 | OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL); | ||
964 | } | ||
965 | } | ||
966 | break; | ||
967 | |||
968 | case OMX_CommandMarkBuffer : | ||
969 | ReturnCmdCompletionCallBack = 0; | ||
970 | break; | ||
971 | |||
972 | default: | ||
973 | OSAL_ErrorTrace("Invalid command"); | ||
974 | } | ||
975 | |||
976 | if( ReturnCmdCompletionCallBack == 1 ) { | ||
977 | eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, | ||
978 | OMX_EventCmdComplete, Cmd, nParam, NULL); | ||
979 | } | ||
980 | |||
981 | EXIT: | ||
982 | return (eError); | ||
983 | |||
984 | } | ||
985 | |||
986 | /* | ||
987 | * Video Decoder DataNotify | ||
988 | */ | ||
989 | OMX_ERRORTYPE OMXVidDec_DataNotify(OMX_HANDLETYPE hComponent) | ||
990 | { | ||
991 | OMX_ERRORTYPE eError = OMX_ErrorNone, eRMError = OMX_ErrorNone; | ||
992 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
993 | OMX_BUFFERHEADERTYPE sInBufHeader; | ||
994 | OMXVidDecComp *pVidDecComp = NULL; | ||
995 | OMX_BUFFERHEADERTYPE *pInBufHeader = NULL; | ||
996 | OMX_BUFFERHEADERTYPE *pOutBufHeader = NULL; | ||
997 | OMX_BUFFERHEADERTYPE *pDupBufHeader = NULL; | ||
998 | OMX_BUFFERHEADERTYPE *pFreeBufHeader = NULL; | ||
999 | OMX_U32 nInMsgCount = 0; | ||
1000 | OMX_U32 nOutMsgCount = 0; | ||
1001 | OMX_U32 Buffer_locked = 1; | ||
1002 | OMX_U32 ii = 0, i, jj = 0; | ||
1003 | OMX_U32 nStride = 0; | ||
1004 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
1005 | OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; | ||
1006 | OMX_BOOL nIsDioReady = OMX_FALSE; | ||
1007 | XDAS_Int32 status; | ||
1008 | XDM2_BufDesc *pInBufDescPtr = NULL; | ||
1009 | XDM2_BufDesc *pOutBufDescPtr = NULL; | ||
1010 | OMX_CONFIG_RECTTYPE out2DAllocParam; | ||
1011 | IVIDDEC3_OutArgs *pDecOutArgs = NULL; | ||
1012 | IVIDDEC3_Status *pDecStatus = NULL; | ||
1013 | XDM_Rect activeFrameRegion[2]; | ||
1014 | OMX_U32 nNewInBufferRequired = 0; | ||
1015 | OMX_BOOL bSendPortReconfigForScale = OMX_FALSE; | ||
1016 | OMX_U32 nScale, nScaleRem, nScaleQ16Low, nScaleWidth, nScaleHeight; | ||
1017 | OMX_U64 nScaleQ16 = 0; | ||
1018 | uint32_t nActualSize; | ||
1019 | OMX_BOOL went_thru_loop = OMX_FALSE; | ||
1020 | OMX_BOOL duped_IPbuffer = OMX_TRUE; | ||
1021 | IMG_native_handle_t* grallocHandle; | ||
1022 | OMX_U32 nLockedCount = 0; | ||
1023 | |||
1024 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
1025 | |||
1026 | //! Initialize pointers | ||
1027 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
1028 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
1029 | OMX_CHECK(pVidDecComp != NULL, OMX_ErrorBadParameter); | ||
1030 | |||
1031 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
1032 | pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); | ||
1033 | out2DAllocParam = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]; | ||
1034 | |||
1035 | /*! Ensure that the stride on output portdef structure is more than | ||
1036 | the padded width. This is needed in the case where application | ||
1037 | sets the Stride less than padded width */ | ||
1038 | if( (OMX_U32)pOutputPortDef->format.video.nStride >= | ||
1039 | pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) { | ||
1040 | nStride = pOutputPortDef->format.video.nStride; | ||
1041 | } else { | ||
1042 | nStride = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; | ||
1043 | } | ||
1044 | if((pVidDecComp->sBase.tCurState != OMX_StateExecuting) || | ||
1045 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.bEnabled == OMX_FALSE) || | ||
1046 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.bEnabled == OMX_FALSE)) { | ||
1047 | goto EXIT; | ||
1048 | } | ||
1049 | nIsDioReady = OMXBase_IsDioReady(hComponent, OMX_VIDDEC_OUTPUT_PORT); | ||
1050 | if( nIsDioReady == OMX_FALSE ) { | ||
1051 | goto EXIT; | ||
1052 | } | ||
1053 | //! Get the number of input and output buffers | ||
1054 | pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, | ||
1055 | OMX_VIDDEC_INPUT_PORT, | ||
1056 | (OMX_PTR)&nInMsgCount); | ||
1057 | pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, | ||
1058 | OMX_VIDDEC_OUTPUT_PORT, | ||
1059 | (OMX_PTR)&nOutMsgCount); | ||
1060 | |||
1061 | // Loop until input or output buffers are exhausted | ||
1062 | while((nInMsgCount > 0) && (nOutMsgCount > 0)) { | ||
1063 | // Only if Cur-State is Execute proceed. | ||
1064 | if((pVidDecComp->sBase.tCurState != OMX_StateExecuting) || | ||
1065 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.bEnabled == OMX_FALSE) || | ||
1066 | (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.bEnabled == OMX_FALSE)) { | ||
1067 | break; | ||
1068 | } | ||
1069 | if( OMXBase_IsCmdPending(hComponent) && pVidDecComp->nOutbufInUseFlag == 0 ) { | ||
1070 | OSAL_ErrorTrace("Exiting dataNotify because command is pending"); | ||
1071 | goto EXIT; | ||
1072 | } | ||
1073 | if( pVidDecComp->nOutPortReconfigRequired == 1 ) { | ||
1074 | OSAL_ErrorTrace("Port disable/reconfiguration needed"); | ||
1075 | goto EXIT; | ||
1076 | } | ||
1077 | if( pVidDecComp->nFatalErrorGiven == 1 ) { | ||
1078 | OSAL_ErrorTrace("Fatal error given to IL client"); | ||
1079 | goto EXIT; | ||
1080 | } | ||
1081 | // Buffer is locked by the codec by default. | ||
1082 | // It can be freed only if mentioned in freeBufId[] field. | ||
1083 | Buffer_locked = 1; | ||
1084 | ii=0; | ||
1085 | went_thru_loop = OMX_TRUE; | ||
1086 | if( nNewInBufferRequired == 0 && pVidDecComp->sCodecConfig.sBuffer == NULL ) { | ||
1087 | duped_IPbuffer = OMX_FALSE; | ||
1088 | //! Get Input and Output Buffer header from Queue | ||
1089 | eError = pVidDecComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_VIDDEC_INPUT_PORT, | ||
1090 | (OMX_PTR*)(&pInBufHeader)); | ||
1091 | if( eError == OMX_TI_WarningAttributePending ) { | ||
1092 | pVidDecComp->sCodecConfig.sBuffer = P2H(memplugin_alloc(2, 1, MEM_CARVEOUT, 0, 0)); | ||
1093 | OMX_CHECK(pVidDecComp->sCodecConfig.sBuffer != NULL, OMX_ErrorInsufficientResources); | ||
1094 | eError = pVidDecComp->sBase.pPvtData->fpDioControl(hComponent, OMX_VIDDEC_INPUT_PORT, | ||
1095 | OMX_DIO_CtrlCmd_GetCtrlAttribute, (OMX_PTR)&(pVidDecComp->sCodecConfig)); | ||
1096 | if( eError == OMX_TI_WarningInsufficientAttributeSize ) { | ||
1097 | /*Allocate the data pointer again with correct size*/ | ||
1098 | uint32_t new_size = pVidDecComp->sCodecConfig.sBuffer->size; | ||
1099 | memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer)); | ||
1100 | pVidDecComp->sCodecConfig.sBuffer = P2H(memplugin_alloc(new_size, 1, MEM_CARVEOUT, 0, 0)); | ||
1101 | OMX_CHECK(pVidDecComp->sCodecConfig.sBuffer != NULL, OMX_ErrorInsufficientResources); | ||
1102 | eError = pVidDecComp->sBase.pPvtData->fpDioControl(hComponent, OMX_VIDDEC_INPUT_PORT, | ||
1103 | OMX_DIO_CtrlCmd_GetCtrlAttribute, (OMX_PTR)&(pVidDecComp->sCodecConfig)); | ||
1104 | if( eError != OMX_ErrorNone ) { | ||
1105 | OSAL_ErrorTrace("Codec config test failed because DIO Control returned buffer"); | ||
1106 | goto EXIT; | ||
1107 | } | ||
1108 | } | ||
1109 | pVidDecComp->pDecDynParams->decodeHeader = pVidDecComp->nDecoderMode; | ||
1110 | pInBufHeader = NULL; | ||
1111 | // Call the Decoder Control function | ||
1112 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
1113 | if( status != VIDDEC3_EOK ) { | ||
1114 | OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n"); | ||
1115 | eError = OMX_ErrorInsufficientResources; | ||
1116 | goto EXIT; | ||
1117 | } | ||
1118 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1119 | } else if( pVidDecComp->nOutbufInUseFlag == 0 ) { | ||
1120 | if( pVidDecComp->pDecDynParams->decodeHeader != XDM_DECODE_AU ) { | ||
1121 | pVidDecComp->pDecDynParams->decodeHeader = XDM_DECODE_AU; | ||
1122 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
1123 | if( status != VIDDEC3_EOK ) { | ||
1124 | OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n"); | ||
1125 | eError = OMX_ErrorInsufficientResources; | ||
1126 | goto EXIT; | ||
1127 | } | ||
1128 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1129 | } | ||
1130 | if( pInBufHeader ) { | ||
1131 | if(!(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) && (pInBufHeader->nFilledLen - pInBufHeader->nOffset == 0)) { | ||
1132 | // Send Input buffer back to base | ||
1133 | pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, | ||
1134 | OMX_VIDDEC_INPUT_PORT, | ||
1135 | pInBufHeader); | ||
1136 | |||
1137 | //! Get the number of input and output buffers | ||
1138 | pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, | ||
1139 | OMX_VIDDEC_INPUT_PORT, | ||
1140 | (OMX_PTR)&nInMsgCount); | ||
1141 | if( nInMsgCount ) { | ||
1142 | continue; | ||
1143 | } else { | ||
1144 | break; | ||
1145 | } | ||
1146 | } | ||
1147 | } | ||
1148 | nLockedCount = 0; | ||
1149 | while (nLockedCount < nOutMsgCount) { | ||
1150 | eError = pVidDecComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_VIDDEC_OUTPUT_PORT, | ||
1151 | (OMX_PTR*)(&pOutBufHeader)); | ||
1152 | if (pOutBufHeader) { | ||
1153 | // check locked flag | ||
1154 | if (((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bIsLocked) { | ||
1155 | nLockedCount++; | ||
1156 | // Send the buffer to the back of the queue | ||
1157 | pVidDecComp->sBase.pPvtData->fpDioQueue(hComponent, | ||
1158 | OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); | ||
1159 | pOutBufHeader = NULL; | ||
1160 | // Get the number of output buffers | ||
1161 | pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, | ||
1162 | OMX_VIDDEC_OUTPUT_PORT, | ||
1163 | (OMX_PTR)&nOutMsgCount); | ||
1164 | continue; | ||
1165 | } | ||
1166 | } | ||
1167 | // if we get here we have our buffer, or it is an error | ||
1168 | break; | ||
1169 | } | ||
1170 | if (pOutBufHeader == NULL) { | ||
1171 | // Cancel input buffer and continue | ||
1172 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
1173 | OMX_VIDDEC_INPUT_PORT, | ||
1174 | pInBufHeader); | ||
1175 | |||
1176 | goto EXIT; | ||
1177 | } | ||
1178 | } | ||
1179 | } | ||
1180 | pOutBufDescPtr = pVidDecComp->tOutBufDesc; | ||
1181 | pInBufDescPtr = pVidDecComp->tInBufDesc; | ||
1182 | if( pVidDecComp->sCodecConfig.sBuffer != NULL && | ||
1183 | (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) { | ||
1184 | pVidDecComp->pDecDynParams->decodeHeader = pVidDecComp->nDecoderMode; | ||
1185 | // Call the Decoder Control function | ||
1186 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, | ||
1187 | pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
1188 | if( status != VIDDEC3_EOK ) { | ||
1189 | OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n"); | ||
1190 | eError = OMX_ErrorInsufficientResources; | ||
1191 | goto EXIT; | ||
1192 | } | ||
1193 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1194 | } | ||
1195 | pInBufDescPtr->numBufs = 1; | ||
1196 | if( pInBufHeader != NULL && pVidDecComp->nOutbufInUseFlag == 1 ) { | ||
1197 | pVidDecComp->pDecInArgs->numBytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset; | ||
1198 | //Sending the same input ID for second field | ||
1199 | pVidDecComp->pDecInArgs->inputID = (OMX_S32) pOutBufHeader; | ||
1200 | if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) { | ||
1201 | (((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = pInBufHeader->nOffset; | ||
1202 | pInBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]); | ||
1203 | pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE; | ||
1204 | pInBufDescPtr->descs[0].bufSize.bytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset; | ||
1205 | pInBufDescPtr->descs[0].bufSize.tileMem.height = 1; | ||
1206 | } | ||
1207 | } else if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader == pVidDecComp->nDecoderMode ) { | ||
1208 | pVidDecComp->pDecInArgs->numBytes = pVidDecComp->sCodecConfig.sBuffer->size; | ||
1209 | pVidDecComp->pDecInArgs->inputID = 1; | ||
1210 | pVidDecComp->sCodecConfig.sBuffer->offset = sizeof(MemHeader); | ||
1211 | pInBufDescPtr->descs[0].buf = (XDAS_Int8*)(pVidDecComp->sCodecConfig.sBuffer); | ||
1212 | pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE; | ||
1213 | pInBufDescPtr->descs[0].bufSize.bytes = pVidDecComp->sCodecConfig.sBuffer->size; | ||
1214 | pInBufDescPtr->descs[0].bufSize.tileMem.height = 1; | ||
1215 | pOutBufDescPtr->numBufs = 0; | ||
1216 | } else if( pInBufHeader != NULL && pVidDecComp->pDecDynParams->decodeHeader == XDM_DECODE_AU ) { | ||
1217 | // In case EOS and Number of Input bytes=0. Flush Decoder and exit | ||
1218 | if( pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS ) { | ||
1219 | if( pInBufHeader->nFilledLen == 0 ) { | ||
1220 | pOutBufHeader->nFilledLen = 0; | ||
1221 | eError = OMXVidDec_HandleFLUSH_EOS(hComponent, pOutBufHeader, pInBufHeader); | ||
1222 | goto EXIT; | ||
1223 | } else { | ||
1224 | pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; | ||
1225 | } | ||
1226 | } | ||
1227 | if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { | ||
1228 | if( pOutputPortDef->format.video.nFrameWidth < out2DAllocParam.nWidth | ||
1229 | || pOutputPortDef->format.video.nFrameHeight < out2DAllocParam.nHeight ) { | ||
1230 | |||
1231 | if (pVidDecComp->nFrameCounter) { | ||
1232 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
1233 | OMX_VIDDEC_INPUT_PORT, pInBufHeader); | ||
1234 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
1235 | OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); | ||
1236 | |||
1237 | OMXVidDec_HandleFirstFrame(hComponent, NULL); | ||
1238 | } else { | ||
1239 | pOutputPortDef->format.video.nFrameWidth = out2DAllocParam.nWidth; | ||
1240 | pOutputPortDef->format.video.nFrameHeight = out2DAllocParam.nHeight; | ||
1241 | pOutputPortDef->format.video.nStride = pOutputPortDef->format.video.nFrameWidth; | ||
1242 | pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * | ||
1243 | ((pOutputPortDef->format.video.nFrameHeight * 3) >> 1); | ||
1244 | pInputPortDef->format.video.nFrameWidth = out2DAllocParam.nWidth; | ||
1245 | pInputPortDef->format.video.nFrameHeight = out2DAllocParam.nHeight; | ||
1246 | |||
1247 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
1248 | OMX_VIDDEC_INPUT_PORT, pInBufHeader); | ||
1249 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
1250 | OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); | ||
1251 | |||
1252 | /*! Notify to Client change in output port settings */ | ||
1253 | eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, | ||
1254 | OMX_EventPortSettingsChanged, OMX_VIDDEC_OUTPUT_PORT, 0, NULL); | ||
1255 | pVidDecComp->nOutPortReconfigRequired = 1; | ||
1256 | } | ||
1257 | goto EXIT; | ||
1258 | } | ||
1259 | } | ||
1260 | /*! Populate xDM structure */ | ||
1261 | pVidDecComp->pDecInArgs->numBytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset; | ||
1262 | pVidDecComp->pDecInArgs->inputID = (OMX_S32) pOutBufHeader; | ||
1263 | if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) { | ||
1264 | /* Fill Input Buffer Descriptor */ | ||
1265 | (((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = pInBufHeader->nOffset; | ||
1266 | pInBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]); | ||
1267 | pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE; | ||
1268 | pInBufDescPtr->descs[0].bufSize.bytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset; | ||
1269 | pInBufDescPtr->descs[0].bufSize.tileMem.height = 1; | ||
1270 | } | ||
1271 | /* Initialize Number of Buffers for input and output */ | ||
1272 | pInBufDescPtr->numBufs = 1; | ||
1273 | pOutBufDescPtr->numBufs = 2; | ||
1274 | |||
1275 | /* Fill Output Buffer Descriptor */ | ||
1276 | /* if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sProps.eBufMemoryType == MEM_GRALLOC) { | ||
1277 | pOutBufDescPtr->descs[0].bufSize.tileMem.width = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; | ||
1278 | pOutBufDescPtr->descs[0].bufSize.tileMem.height = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight; | ||
1279 | (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = 0; | ||
1280 | pOutBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]); | ||
1281 | pOutBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILED8; | ||
1282 | (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]).offset = 0; | ||
1283 | pOutBufDescPtr->descs[1].bufSize.tileMem.width =pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; | ||
1284 | pOutBufDescPtr->descs[1].bufSize.tileMem.height = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight / 2; | ||
1285 | pOutBufDescPtr->descs[1].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]); | ||
1286 | pOutBufDescPtr->descs[1].memType = XDM_MEMTYPE_TILED16; | ||
1287 | } else*/ { | ||
1288 | pOutBufDescPtr->descs[0].bufSize.bytes = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth * | ||
1289 | pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight; | ||
1290 | pOutBufDescPtr->descs[0].bufSize.tileMem.height = 1; | ||
1291 | pOutBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]); | ||
1292 | pOutBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE; | ||
1293 | |||
1294 | memcpy(&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]), &(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]), sizeof(MemHeader)); | ||
1295 | |||
1296 | (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]).offset = pOutBufDescPtr->descs[0].bufSize.bytes; | ||
1297 | |||
1298 | pOutBufDescPtr->descs[1].bufSize.bytes = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth * | ||
1299 | pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight/2; | ||
1300 | pOutBufDescPtr->descs[1].bufSize.tileMem.height = 1; | ||
1301 | pOutBufDescPtr->descs[1].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]); | ||
1302 | pOutBufDescPtr->descs[1].memType = XDM_MEMTYPE_TILEDPAGE; | ||
1303 | nStride = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; | ||
1304 | } | ||
1305 | |||
1306 | if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) { | ||
1307 | if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment) { | ||
1308 | /* provide metaBuffer to codec because it's MPEG2 with Error Concealment */ | ||
1309 | pOutBufDescPtr->numBufs = 3; | ||
1310 | pVidDecComp->pmetaBuffer->offset = sizeof(MemHeader); | ||
1311 | pOutBufDescPtr->descs[2].buf = (XDAS_Int8*)(pVidDecComp->pmetaBuffer); | ||
1312 | pOutBufDescPtr->descs[2].memType = XDM_MEMTYPE_RAW; | ||
1313 | pOutBufDescPtr->descs[2].bufSize.bytes = pVidDecComp->pmetaBuffer->size; | ||
1314 | pOutBufDescPtr->descs[2].bufSize.tileMem.height = 1; | ||
1315 | } | ||
1316 | } | ||
1317 | |||
1318 | pOutBufHeader->nTimeStamp = pInBufHeader->nTimeStamp; | ||
1319 | if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE && pVidDecComp->bInputBufferCancelled == 0 ) { | ||
1320 | OSAL_WriteToPipe(pVidDecComp->pTimeStampStoragePipe, &(pInBufHeader->nTimeStamp), | ||
1321 | sizeof(OMX_TICKS), OSAL_NO_SUSPEND); | ||
1322 | } | ||
1323 | } | ||
1324 | /*Copy OMX_BUFFERFLAG_DECODEONLY from input buffer header to output buffer header*/ | ||
1325 | if (pOutBufHeader && pInBufHeader) { | ||
1326 | pOutBufHeader->nFlags |= (pInBufHeader->nFlags & OMX_BUFFERFLAG_DECODEONLY); | ||
1327 | ((OMXBase_BufHdrPvtData *)(pInBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC; | ||
1328 | ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC; | ||
1329 | } | ||
1330 | |||
1331 | if (pOutBufHeader) { | ||
1332 | grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); | ||
1333 | pVidDecComp->grallocModule->lock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
1334 | (buffer_handle_t)grallocHandle, GRALLOC_USAGE_HW_RENDER, | ||
1335 | 0,0,pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
1336 | pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight,NULL); | ||
1337 | ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bIsLocked = OMX_TRUE; | ||
1338 | } | ||
1339 | |||
1340 | status = VIDDEC3_process(pVidDecComp->pDecHandle, pInBufDescPtr, pOutBufDescPtr, | ||
1341 | (VIDDEC3_InArgs *)pVidDecComp->pDecInArgs, (VIDDEC3_OutArgs *)pVidDecComp->pDecOutArgs); | ||
1342 | |||
1343 | pDecOutArgs = pVidDecComp->pDecOutArgs; | ||
1344 | |||
1345 | /*! In case this is an IPC failure */ | ||
1346 | if(status == DCE_EIPC_CALL_FAIL) { | ||
1347 | ALOGE("\n Remote Core Communication Failure... \n"); | ||
1348 | eError = OMX_ErrorHardware; | ||
1349 | pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE; | ||
1350 | goto EXIT; | ||
1351 | } | ||
1352 | /*! In case Process returns error */ | ||
1353 | if(status == XDM_EFAIL ){ | ||
1354 | ALOGE("\n Process function returned an Error... \n"); | ||
1355 | ALOGE("Codec Extended - 0x%x", (OMX_U32)pVidDecComp->pDecOutArgs->extendedError); | ||
1356 | ALOGE("Input Buffer Size provided to codec is : %d", (int)pInBufDescPtr->descs[0].bufSize.bytes); | ||
1357 | ALOGE("Frame count is : %d", pVidDecComp->nFrameCounter + 1); | ||
1358 | ALOGE("Bytes consumed - %d", (int)pVidDecComp->pDecOutArgs->bytesConsumed); | ||
1359 | |||
1360 | if( !(pVidDecComp->bInputBufferCancelled == 1 && pVidDecComp->pDecOutArgs->extendedError & 0x8000)) { | ||
1361 | /*! Call function to handle Codec Error */ | ||
1362 | eError = OMXVidDec_HandleCodecProcError(hComponent, &(pInBufHeader), &(pOutBufHeader)); | ||
1363 | } | ||
1364 | if( eError != OMX_ErrorNone ) { | ||
1365 | goto EXIT; | ||
1366 | } | ||
1367 | if( pVidDecComp->nOutPortReconfigRequired == 1 ) { | ||
1368 | goto EXIT; | ||
1369 | } | ||
1370 | } | ||
1371 | if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader == pVidDecComp->nDecoderMode ) { | ||
1372 | eError = OMXVidDec_HandleFirstFrame(hComponent, NULL); | ||
1373 | //we have to loop once again if we duplicated any input buffer | ||
1374 | if(duped_IPbuffer && nInMsgCount) { | ||
1375 | if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer && pVidDecComp->nOutPortReconfigRequired == 0 && went_thru_loop) { | ||
1376 | memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer)); | ||
1377 | pVidDecComp->sCodecConfig.sBuffer = NULL; | ||
1378 | } | ||
1379 | continue; | ||
1380 | } | ||
1381 | goto EXIT; | ||
1382 | } | ||
1383 | // Increment the FrameCounter value | ||
1384 | pVidDecComp->nFrameCounter++; | ||
1385 | if( pDecOutArgs->outBufsInUseFlag && pVidDecComp->nOutbufInUseFlag == 1 ) { | ||
1386 | pVidDecComp->nFrameCounter--; | ||
1387 | } | ||
1388 | if( pDecOutArgs->outBufsInUseFlag ) { | ||
1389 | pVidDecComp->nOutbufInUseFlag = 1; | ||
1390 | /* Check for any output buffer which is freed by codec*/ | ||
1391 | ii = 0; | ||
1392 | while( pDecOutArgs->freeBufID[ii] ) { | ||
1393 | if( pDecOutArgs->outputID[0] == 0 && pDecOutArgs->freeBufID[ii] == pVidDecComp->pDecInArgs->inputID ) { | ||
1394 | pVidDecComp->nOutbufInUseFlag = 0; | ||
1395 | pVidDecComp->nFrameCounter--; | ||
1396 | } | ||
1397 | pFreeBufHeader = (OMX_BUFFERHEADERTYPE *) pDecOutArgs->freeBufID[ii]; | ||
1398 | ((OMXBase_BufHdrPvtData *)(pFreeBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; | ||
1399 | grallocHandle = (IMG_native_handle_t*)(pFreeBufHeader->pBuffer); | ||
1400 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle); | ||
1401 | |||
1402 | /* Send the Freed buffer back to base component */ | ||
1403 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
1404 | OMX_VIDDEC_OUTPUT_PORT, pFreeBufHeader); | ||
1405 | ii++; | ||
1406 | } | ||
1407 | |||
1408 | if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) { | ||
1409 | ii = 0; | ||
1410 | if( pInBufHeader != NULL ) { | ||
1411 | if((pInBufHeader->nFilledLen - pInBufHeader->nOffset) != (OMX_U32)pDecOutArgs->bytesConsumed ) { | ||
1412 | nNewInBufferRequired = 1; | ||
1413 | pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed; | ||
1414 | continue; | ||
1415 | } | ||
1416 | nNewInBufferRequired = 0; | ||
1417 | pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed; | ||
1418 | if( !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS)) { | ||
1419 | // Send Input buffer back to base | ||
1420 | pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, | ||
1421 | OMX_VIDDEC_INPUT_PORT, pInBufHeader); | ||
1422 | } else if( pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS ) { | ||
1423 | OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, pInBufHeader); | ||
1424 | if( eError != OMX_ErrorNone ) { | ||
1425 | goto EXIT; | ||
1426 | } | ||
1427 | } | ||
1428 | } | ||
1429 | pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, | ||
1430 | OMX_VIDDEC_INPUT_PORT, (OMX_PTR)&nInMsgCount); | ||
1431 | if( nInMsgCount > 0 ) { | ||
1432 | continue; | ||
1433 | } else { | ||
1434 | break; | ||
1435 | } | ||
1436 | } | ||
1437 | } | ||
1438 | |||
1439 | // Check for the width/height after first frame | ||
1440 | if((pVidDecComp->nFrameCounter == 1) || (pVidDecComp->nOutbufInUseFlag == 1 && pVidDecComp->nFrameCounter == 2)) { | ||
1441 | eError = OMXVidDec_HandleFirstFrame(hComponent, &(pInBufHeader)); | ||
1442 | if( eError != OMX_ErrorNone ) { | ||
1443 | goto EXIT; | ||
1444 | } | ||
1445 | if( pVidDecComp->nOutPortReconfigRequired == 1 | ||
1446 | && pVidDecComp->pDecStaticParams->displayDelay | ||
1447 | != IVIDDEC3_DECODE_ORDER ) { | ||
1448 | /*! In case Port reconfiguration is required | ||
1449 | * output buffer */ | ||
1450 | goto EXIT; | ||
1451 | } | ||
1452 | } // End of if condition from nFrameCounter = 1 | ||
1453 | |||
1454 | if( pVidDecComp->nOutbufInUseFlag == 1 ) { | ||
1455 | pVidDecComp->nOutbufInUseFlag = 0; | ||
1456 | nNewInBufferRequired = 0; | ||
1457 | } | ||
1458 | ii = 0; | ||
1459 | while( pDecOutArgs->outputID[ii] ) { | ||
1460 | pOutBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[ii]; | ||
1461 | if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { | ||
1462 | OSAL_ReadFromPipe(pVidDecComp->pTimeStampStoragePipe, &(pOutBufHeader->nTimeStamp), | ||
1463 | sizeof(OMX_TICKS), &(nActualSize), OSAL_NO_SUSPEND); | ||
1464 | } | ||
1465 | |||
1466 | activeFrameRegion[0] = pDecOutArgs->displayBufs.bufDesc[0].activeFrameRegion; | ||
1467 | activeFrameRegion[1].bottomRight.y = (activeFrameRegion[0].bottomRight.y) / 2; | ||
1468 | activeFrameRegion[1].bottomRight.x = activeFrameRegion[0].bottomRight.x; | ||
1469 | |||
1470 | //Crop rectangle handles the offsets for Y and UV buffers | ||
1471 | pOutBufHeader->nOffset = 0; | ||
1472 | pOutBufHeader->nFilledLen = (pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * nStride * 3) / 2; | ||
1473 | |||
1474 | if((pVidDecComp->tCropDimension.nTop != activeFrameRegion[0].topLeft.y | ||
1475 | || pVidDecComp->tCropDimension.nLeft != activeFrameRegion[0].topLeft.x) | ||
1476 | || (pVidDecComp->tCropDimension.nWidth != (OMX_U32)(activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x) | ||
1477 | || pVidDecComp->tCropDimension.nHeight != (OMX_U32)(activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y))) { | ||
1478 | pVidDecComp->tCropDimension.nTop = activeFrameRegion[0].topLeft.y; | ||
1479 | pVidDecComp->tCropDimension.nLeft = activeFrameRegion[0].topLeft.x; | ||
1480 | pVidDecComp->tCropDimension.nWidth = activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x; | ||
1481 | pVidDecComp->tCropDimension.nHeight = activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y; | ||
1482 | if( pVidDecComp->bUsePortReconfigForCrop == OMX_TRUE ) { | ||
1483 | eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventPortSettingsChanged, | ||
1484 | OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonOutputCrop, NULL); | ||
1485 | if( eError != OMX_ErrorNone ) { | ||
1486 | OSAL_ErrorTrace("Port reconfig callback returned error, trying to continue"); | ||
1487 | } | ||
1488 | } | ||
1489 | } | ||
1490 | |||
1491 | if( pVidDecComp->bSupportSkipGreyOutputFrames ) { | ||
1492 | if( pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_I_FRAME || | ||
1493 | pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IDR_FRAME || | ||
1494 | pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IP_FRAME || | ||
1495 | pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IB_FRAME ) { | ||
1496 | pVidDecComp->bSyncFrameReady = OMX_TRUE; | ||
1497 | } | ||
1498 | } | ||
1499 | grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); | ||
1500 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle); | ||
1501 | |||
1502 | if( pVidDecComp->bSyncFrameReady == OMX_TRUE ) { | ||
1503 | if( !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) || !(pVidDecComp->bIsFlushRequired)) { | ||
1504 | // Send the Output buffer to Base component | ||
1505 | pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, | ||
1506 | OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); | ||
1507 | } | ||
1508 | } else { | ||
1509 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
1510 | OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); | ||
1511 | } | ||
1512 | pDecOutArgs->outputID[ii] = 0; | ||
1513 | ii++; | ||
1514 | } | ||
1515 | |||
1516 | jj = 0; | ||
1517 | while(pDecOutArgs->freeBufID[jj]) { | ||
1518 | // update locked flag of buffer to "unlocked" | ||
1519 | pFreeBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->freeBufID[jj]; | ||
1520 | ((OMXBase_BufHdrPvtData *)(pFreeBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; | ||
1521 | if (!ii && pDecOutArgs->freeBufID[jj] == pVidDecComp->pDecInArgs->inputID) { | ||
1522 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
1523 | OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); | ||
1524 | break; | ||
1525 | } | ||
1526 | jj++; | ||
1527 | } | ||
1528 | |||
1529 | if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) { | ||
1530 | if( pInBufHeader && pDecOutArgs && | ||
1531 | (pVidDecComp->pDecDynParams->decodeHeader == XDM_DECODE_AU && pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE)) { | ||
1532 | if((pVidDecComp->bInputBufferCancelled == 1) && (((pDecOutArgs->bytesConsumed == 0) || (((OMX_S32)pInBufHeader->nFilledLen) | ||
1533 | <= ((OMX_S32)pInBufHeader->nOffset + pDecOutArgs->bytesConsumed + 3))) || | ||
1534 | (pVidDecComp->pDecOutArgs->extendedError & 0x8000))) { | ||
1535 | pVidDecComp->bInputBufferCancelled = 0; | ||
1536 | } else if((((OMX_S32)pInBufHeader->nFilledLen) > ((OMX_S32)pInBufHeader->nOffset + pDecOutArgs->bytesConsumed + 3)) && | ||
1537 | ((pDecOutArgs->bytesConsumed != 0) && !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS))) { | ||
1538 | pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed; | ||
1539 | pVidDecComp->bInputBufferCancelled = 1; | ||
1540 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_VIDDEC_INPUT_PORT, pInBufHeader); | ||
1541 | } | ||
1542 | } | ||
1543 | /* Currently the assumption is that the entire input buffer is consumed | ||
1544 | * going forward we might have to handle cases where partial buffer is | ||
1545 | * consumed */ | ||
1546 | if( pVidDecComp->bInputBufferCancelled == 0 ) { | ||
1547 | if( pInBufHeader != NULL && | ||
1548 | !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) && | ||
1549 | pVidDecComp->nOutPortReconfigRequired != 1 ) { | ||
1550 | pInBufHeader->nFilledLen | ||
1551 | = pInBufHeader->nFilledLen - pDecOutArgs->bytesConsumed - pInBufHeader->nOffset; | ||
1552 | pInBufHeader->nOffset = 0; | ||
1553 | // Send Input buffer back to base | ||
1554 | pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, | ||
1555 | OMX_VIDDEC_INPUT_PORT, pInBufHeader); | ||
1556 | } | ||
1557 | else if( pInBufHeader != NULL && (pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) && | ||
1558 | pVidDecComp->nOutPortReconfigRequired != 1 ) { | ||
1559 | pInBufHeader->nFilledLen | ||
1560 | = pInBufHeader->nFilledLen - pDecOutArgs->bytesConsumed - pInBufHeader->nOffset; | ||
1561 | pInBufHeader->nOffset = 0; | ||
1562 | if( Buffer_locked == 1 ) { | ||
1563 | OMXVidDec_HandleFLUSH_EOS(hComponent, pDupBufHeader, pInBufHeader); | ||
1564 | } else { | ||
1565 | OMXVidDec_HandleFLUSH_EOS(hComponent, pOutBufHeader, pInBufHeader); | ||
1566 | } | ||
1567 | if( eError != OMX_ErrorNone ) { | ||
1568 | goto EXIT; | ||
1569 | } | ||
1570 | } | ||
1571 | } | ||
1572 | } | ||
1573 | nIsDioReady = OMXBase_IsDioReady(hComponent, OMX_VIDDEC_OUTPUT_PORT); | ||
1574 | if( nIsDioReady == OMX_FALSE ) { | ||
1575 | goto EXIT; | ||
1576 | } | ||
1577 | // Get the number of buffers in Input and Output port | ||
1578 | pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, | ||
1579 | OMX_VIDDEC_INPUT_PORT, (OMX_PTR)&nInMsgCount); | ||
1580 | pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent, | ||
1581 | OMX_VIDDEC_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount); | ||
1582 | |||
1583 | } // End of while loop for input and output buffers | ||
1584 | |||
1585 | EXIT: | ||
1586 | if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer && pVidDecComp->nOutPortReconfigRequired == 0 && went_thru_loop) { | ||
1587 | memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer)); | ||
1588 | pVidDecComp->sCodecConfig.sBuffer = NULL; | ||
1589 | } | ||
1590 | |||
1591 | return (eError); | ||
1592 | } | ||
1593 | |||
1594 | /* | ||
1595 | * Video Decoder DeInit | ||
1596 | */ | ||
1597 | OMX_ERRORTYPE OMXVidDec_ComponentDeinit(OMX_HANDLETYPE hComponent) | ||
1598 | { | ||
1599 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1600 | OMX_COMPONENTTYPE *pComp; | ||
1601 | OMXVidDecComp *pVidDecComp = NULL; | ||
1602 | OMX_U32 i; | ||
1603 | OMXBase_PortProps *pOutPortProperties = NULL; | ||
1604 | |||
1605 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
1606 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1607 | pVidDecComp = (OMXVidDecComp *)pComp->pComponentPrivate; | ||
1608 | |||
1609 | // For MPEG2 with Error Concealment ON, need to free the metadata buffer. | ||
1610 | if ((pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) && (pVidDecComp->pmetaBuffer)) { | ||
1611 | memplugin_free((void*)H2P(pVidDecComp->pmetaBuffer)); | ||
1612 | pVidDecComp->pmetaBuffer = NULL; | ||
1613 | } | ||
1614 | |||
1615 | // Free sBuffer if it hasn't already been freed | ||
1616 | if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer ) { | ||
1617 | memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer)); | ||
1618 | pVidDecComp->sCodecConfig.sBuffer = NULL; | ||
1619 | } | ||
1620 | |||
1621 | OSAL_DeletePipe(pVidDecComp->pTimeStampStoragePipe); | ||
1622 | |||
1623 | OMXBase_UtilCleanupIfError(hComponent); | ||
1624 | |||
1625 | // Call to Specific Decoder De-init routine | ||
1626 | pVidDecComp->fpDeinit_Codec(hComponent); | ||
1627 | // Close Codec-Engine | ||
1628 | if( pVidDecComp->ce ) { | ||
1629 | Engine_close(pVidDecComp->ce); | ||
1630 | } | ||
1631 | |||
1632 | if( pVidDecComp->sBase.cComponentName ) { | ||
1633 | OSAL_Free(pVidDecComp->sBase.cComponentName); | ||
1634 | pVidDecComp->sBase.cComponentName = NULL; | ||
1635 | } | ||
1636 | if( pVidDecComp->sBase.pVideoPortParams ) { | ||
1637 | OSAL_Free(pVidDecComp->sBase.pVideoPortParams); | ||
1638 | pVidDecComp->sBase.pVideoPortParams = NULL; | ||
1639 | } | ||
1640 | |||
1641 | if (pVidDecComp->tInBufDesc) { | ||
1642 | memplugin_free(pVidDecComp->tInBufDesc); | ||
1643 | pVidDecComp->tInBufDesc = NULL; | ||
1644 | } | ||
1645 | |||
1646 | if (pVidDecComp->tOutBufDesc) { | ||
1647 | memplugin_free(pVidDecComp->tOutBufDesc); | ||
1648 | pVidDecComp->tOutBufDesc = NULL; | ||
1649 | } | ||
1650 | |||
1651 | // Call to base Component De-init routine | ||
1652 | eError = OMXBase_ComponentDeinit(hComponent); | ||
1653 | |||
1654 | if (pVidDecComp->bIPCRecoveryNeeded) { | ||
1655 | dce_ipc_recover(); | ||
1656 | } | ||
1657 | |||
1658 | OSAL_Free(pVidDecComp); | ||
1659 | pVidDecComp = NULL; | ||
1660 | |||
1661 | EXIT: | ||
1662 | return (eError); | ||
1663 | } | ||
1664 | |||
1665 | /* | ||
1666 | * GetExtension Index | ||
1667 | */ | ||
1668 | OMX_ERRORTYPE OMXVidDec_GetExtensionIndex(OMX_HANDLETYPE hComponent, | ||
1669 | OMX_STRING cParameterName, OMX_INDEXTYPE *pIndexType) | ||
1670 | { | ||
1671 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1672 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
1673 | OMXVidDecComp *pVidDecComp = NULL; | ||
1674 | |||
1675 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
1676 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
1677 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
1678 | // Check for NULL Parameters | ||
1679 | if((cParameterName == NULL) || (pIndexType == NULL)) { | ||
1680 | eError = OMX_ErrorBadParameter; | ||
1681 | goto EXIT; | ||
1682 | } | ||
1683 | // Check for Valid State | ||
1684 | if( pVidDecComp->sBase.tCurState == OMX_StateInvalid ) { | ||
1685 | eError = OMX_ErrorInvalidState; | ||
1686 | goto EXIT; | ||
1687 | } | ||
1688 | // Ensure that String length is not greater than Max allowed length | ||
1689 | if( strlen(cParameterName) > 127 ) { | ||
1690 | //strlen does not include \0 size, hence 127 | ||
1691 | eError = OMX_ErrorBadParameter; | ||
1692 | goto EXIT; | ||
1693 | } | ||
1694 | |||
1695 | if(strcmp(cParameterName, "OMX.google.android.index.enableAndroidNativeBuffers") == 0) { | ||
1696 | // If Index type is 2D Buffer Allocated Dimension | ||
1697 | *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexUseNativeBuffers; | ||
1698 | goto EXIT; | ||
1699 | } else if (strcmp(cParameterName, "OMX.google.android.index.useAndroidNativeBuffer2") == 0) { | ||
1700 | //This is call just a dummy for android to support backward compatibility | ||
1701 | *pIndexType = (OMX_INDEXTYPE) NULL; | ||
1702 | goto EXIT; | ||
1703 | } else if (strcmp(cParameterName, "OMX.google.android.index.getAndroidNativeBufferUsage") == 0) { | ||
1704 | *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexAndroidNativeBufferUsage; | ||
1705 | } else if( strcmp(cParameterName, "OMX.google.android.index.describeColorFormat") == 0 ) { | ||
1706 | // If Index type is Time Stamp In Decode Order | ||
1707 | *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat; | ||
1708 | } else if( strcmp(cParameterName, "OMX_TI_IndexParamTimeStampInDecodeOrder") == 0 ) { | ||
1709 | // If Index type is Time Stamp In Decode Order | ||
1710 | *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexParamTimeStampInDecodeOrder; | ||
1711 | } else if( strcmp(cParameterName, "OMX_TI_IndexEnableDecoderZeroDisplayDelayMode") == 0 ) { | ||
1712 | // If Index type is Enable Decoder Zero Display Delay Mode | ||
1713 | *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode; | ||
1714 | } else if( strcmp(cParameterName, "OMX.google.android.index.prepareForAdaptivePlayback") == 0 ) { | ||
1715 | // If Index type is Enable Decoder Zero Display Delay Mode | ||
1716 | *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexPrepareForAdaptivePlayback; | ||
1717 | } else { | ||
1718 | //does not match any custom index | ||
1719 | eError = OMX_ErrorUnsupportedIndex; | ||
1720 | } | ||
1721 | |||
1722 | EXIT: | ||
1723 | return (eError); | ||
1724 | } | ||
1725 | |||
1726 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <omx_video_decoder_componenttable.h> | ||
18 | |||
19 | |||
20 | extern OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent); | ||
21 | extern OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent); | ||
22 | extern OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent); | ||
23 | extern OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent); | ||
24 | |||
25 | OMXDecoderComponentList DecoderList[] = | ||
26 | { | ||
27 | { "video_decoder.avc", OMX_VIDEO_CodingAVC, OMXH264VD_Init }, /*! H264 Decoder */ | ||
28 | {"video_decoder.mpeg4", OMX_VIDEO_CodingMPEG4, OMXMPEG4VD_Init}, | ||
29 | { "video_decoder.h263", OMX_VIDEO_CodingH263, OMXH263VD_Init }, /*! H263 Decoder */ | ||
30 | { "video_decoder.mpeg2", OMX_VIDEO_CodingMPEG2, OMXMPEG2VD_Init }, /*! MPEG2 Decoder */ | ||
31 | { "NULL", 0, NULL } | ||
32 | }; | ||
33 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_VIDDEC_INTERNAL" | ||
18 | |||
19 | #include <omx_video_decoder_internal.h> | ||
20 | #include <libdce.h> | ||
21 | |||
22 | #define OMX_VIDDEC_DEFAULT_INBUF_WIDTH 1024 | ||
23 | #define OMX_VIDDEC_DEFAULT_INBUF_HEIGHT 1024 | ||
24 | |||
25 | OMX_ERRORTYPE OMXVidDec_InitFields(OMXVidDecComp *pVidDecComp) | ||
26 | { | ||
27 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
28 | hw_module_t const* module; | ||
29 | OMX_U32 i = 0; | ||
30 | |||
31 | pVidDecComp->sBase.cComponentName = (OMX_STRING )OSAL_Malloc(sizeof(OMX_U8) * OMX_MAX_STRINGNAME_SIZE); | ||
32 | OMX_CHECK(pVidDecComp->sBase.cComponentName != NULL, OMX_ErrorInsufficientResources); | ||
33 | |||
34 | /* Initialize Video Port parameters */ | ||
35 | pVidDecComp->sBase.pVideoPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); | ||
36 | |||
37 | OMX_BASE_INIT_STRUCT_PTR(pVidDecComp->sBase.pVideoPortParams, OMX_PORT_PARAM_TYPE); | ||
38 | pVidDecComp->sBase.pVideoPortParams->nPorts = OMX_VIDDEC_NUM_OF_PORTS; | ||
39 | pVidDecComp->sBase.pVideoPortParams->nStartPortNumber = OMX_VIDDEC_DEFAULT_START_PORT_NUM; | ||
40 | pVidDecComp->sBase.nNumPorts = OMX_VIDDEC_NUM_OF_PORTS; | ||
41 | pVidDecComp->sBase.nMinStartPortIndex = OMX_VIDDEC_DEFAULT_START_PORT_NUM; | ||
42 | |||
43 | pVidDecComp->sBase.nComponentVersion.s.nVersionMajor = OMX_VIDDEC_COMP_VERSION_MAJOR; | ||
44 | pVidDecComp->sBase.nComponentVersion.s.nVersionMinor = OMX_VIDDEC_COMP_VERSION_MINOR; | ||
45 | pVidDecComp->sBase.nComponentVersion.s.nRevision = OMX_VIDDEC_COMP_VERSION_REVISION; | ||
46 | pVidDecComp->sBase.nComponentVersion.s.nStep = OMX_VIDDEC_COMP_VERSION_STEP; | ||
47 | |||
48 | eError = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); | ||
49 | if (eError == 0) { | ||
50 | pVidDecComp->grallocModule = (gralloc_module_t const *)module; | ||
51 | } else { | ||
52 | eError = OMX_ErrorInsufficientResources; | ||
53 | } | ||
54 | |||
55 | EXIT: | ||
56 | return (eError); | ||
57 | } | ||
58 | |||
59 | /* | ||
60 | */ | ||
61 | void OMXVidDec_InitPortDefs(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp) | ||
62 | { | ||
63 | OMXBaseComp *pBaseComp = &(pVidDecComp->sBase); | ||
64 | |||
65 | OMX_PARAM_PORTDEFINITIONTYPE *inPortDefs = &(pBaseComp->pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); | ||
66 | OMX_PARAM_PORTDEFINITIONTYPE *outPortDefs= &(pBaseComp->pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
67 | |||
68 | /* set the default/Actual values of an Input port */ | ||
69 | inPortDefs->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); | ||
70 | inPortDefs->nVersion = pBaseComp->nComponentVersion; | ||
71 | inPortDefs->bEnabled = OMX_TRUE; | ||
72 | inPortDefs->bPopulated = OMX_FALSE; | ||
73 | inPortDefs->eDir = OMX_DirInput; | ||
74 | inPortDefs->nPortIndex = OMX_VIDDEC_INPUT_PORT; | ||
75 | inPortDefs->nBufferCountMin = OMX_VIDDEC_MIN_IN_BUF_COUNT; | ||
76 | inPortDefs->nBufferCountActual = OMX_VIDDEC_DEFAULT_IN_BUF_COUNT; | ||
77 | inPortDefs->nBufferSize = Calc_InbufSize(OMX_VIDDEC_DEFAULT_INBUF_WIDTH, | ||
78 | OMX_VIDDEC_DEFAULT_INBUF_HEIGHT); | ||
79 | |||
80 | inPortDefs->eDomain = OMX_PortDomainVideo; | ||
81 | inPortDefs->bBuffersContiguous = OMX_TRUE; | ||
82 | inPortDefs->nBufferAlignment = OMX_VIDDEC_DEFAULT_1D_INPUT_BUFFER_ALIGNMENT; | ||
83 | inPortDefs->format.video.cMIMEType= NULL; | ||
84 | inPortDefs->format.video.pNativeRender = NULL; | ||
85 | inPortDefs->format.video.nFrameWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH; | ||
86 | inPortDefs->format.video.nFrameHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT; | ||
87 | inPortDefs->format.video.nStride = 0; | ||
88 | inPortDefs->format.video.nSliceHeight = 0; | ||
89 | inPortDefs->format.video.nBitrate = 0; | ||
90 | inPortDefs->format.video.xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE << 16; | ||
91 | inPortDefs->format.video.bFlagErrorConcealment = OMX_TRUE; | ||
92 | inPortDefs->format.video.eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat; | ||
93 | inPortDefs->format.video.eColorFormat = OMX_COLOR_FormatUnused; | ||
94 | |||
95 | /* set the default/Actual values of an output port */ | ||
96 | outPortDefs->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); | ||
97 | outPortDefs->nVersion = pVidDecComp->sBase.nComponentVersion; | ||
98 | outPortDefs->bEnabled = OMX_TRUE; | ||
99 | outPortDefs->bPopulated = OMX_FALSE; | ||
100 | outPortDefs->eDir = OMX_DirOutput; | ||
101 | outPortDefs->nPortIndex = OMX_VIDDEC_OUTPUT_PORT; | ||
102 | outPortDefs->nBufferCountMin = pVidDecComp->fpCalc_OubuffDetails(hComponent, | ||
103 | OMX_VIDDEC_DEFAULT_FRAME_WIDTH, | ||
104 | OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferCountMin; | ||
105 | outPortDefs->nBufferCountActual = pVidDecComp->fpCalc_OubuffDetails(hComponent, | ||
106 | OMX_VIDDEC_DEFAULT_FRAME_WIDTH, | ||
107 | OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferCountActual; | ||
108 | |||
109 | outPortDefs->nBufferSize = pVidDecComp->fpCalc_OubuffDetails(hComponent, | ||
110 | OMX_VIDDEC_DEFAULT_FRAME_WIDTH, | ||
111 | OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferSize; | ||
112 | outPortDefs->eDomain = OMX_PortDomainVideo; | ||
113 | outPortDefs->bBuffersContiguous = OMX_TRUE; | ||
114 | outPortDefs->nBufferAlignment = pVidDecComp->fpCalc_OubuffDetails(hComponent, | ||
115 | OMX_VIDDEC_DEFAULT_FRAME_WIDTH, | ||
116 | OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).n1DBufferAlignment; | ||
117 | outPortDefs->format.video.cMIMEType = NULL; | ||
118 | outPortDefs->format.video.pNativeRender = NULL; | ||
119 | outPortDefs->format.video.nFrameWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH; | ||
120 | outPortDefs->format.video.nFrameHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT; | ||
121 | outPortDefs->format.video.nStride = OMX_VIDDEC_DEFAULT_STRIDE; | ||
122 | outPortDefs->format.video.nSliceHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT; | ||
123 | outPortDefs->format.video.nBitrate = 0; | ||
124 | outPortDefs->format.video.xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE << 16; | ||
125 | outPortDefs->format.video.bFlagErrorConcealment = OMX_TRUE; | ||
126 | outPortDefs->format.video.eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat; | ||
127 | outPortDefs->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; | ||
128 | } | ||
129 | |||
130 | |||
131 | void OMXVidDec_InitPortParams(OMXVidDecComp *pVidDecComp) | ||
132 | { | ||
133 | OMX_VIDEO_PARAM_PORTFORMATTYPE *tInPortVideoParam | ||
134 | = &(pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT]); | ||
135 | OMX_VIDEO_PARAM_PORTFORMATTYPE *tOutPortVideoParam | ||
136 | = &(pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT]); | ||
137 | |||
138 | // Initialize Input Video Port Param | ||
139 | tInPortVideoParam->nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE); | ||
140 | tInPortVideoParam->nVersion = pVidDecComp->sBase.nComponentVersion; | ||
141 | tInPortVideoParam->nPortIndex = OMX_VIDDEC_INPUT_PORT; | ||
142 | tInPortVideoParam->nIndex = 0; | ||
143 | tInPortVideoParam->eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat; | ||
144 | tInPortVideoParam->eColorFormat = OMX_COLOR_FormatUnused; | ||
145 | tInPortVideoParam->xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE; | ||
146 | |||
147 | // Initialize Output Video Port Param | ||
148 | tOutPortVideoParam->nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE); | ||
149 | tOutPortVideoParam->nVersion = pVidDecComp->sBase.nComponentVersion; | ||
150 | tOutPortVideoParam->nPortIndex = OMX_VIDDEC_OUTPUT_PORT; | ||
151 | tOutPortVideoParam->nIndex = 1; | ||
152 | tOutPortVideoParam->eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat; | ||
153 | tOutPortVideoParam->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar; | ||
154 | tOutPortVideoParam->xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE; | ||
155 | } | ||
156 | |||
157 | void OMXVidDec_InitDecoderParams(OMX_HANDLETYPE hComponent, | ||
158 | OMXVidDecComp *pVidDecComp) | ||
159 | { | ||
160 | OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT; | ||
161 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = &(pVidDecComp->sBase.pPorts[outPort]->sPortDef); | ||
162 | OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]); | ||
163 | |||
164 | OMXVidDec_InitPortDefs(hComponent, pVidDecComp); | ||
165 | OMXVidDec_InitPortParams(pVidDecComp); | ||
166 | OMXVidDec_Set2DBuffParams(hComponent, pVidDecComp); | ||
167 | pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; | ||
168 | |||
169 | pVidDecComp->pDecStaticParams->maxHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT; | ||
170 | pVidDecComp->pDecStaticParams->maxWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH; | ||
171 | |||
172 | /* Call Decoder Specific function to set Static Params */ | ||
173 | pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams); | ||
174 | return; | ||
175 | } | ||
176 | |||
177 | |||
178 | void OMXVidDec_Set2DBuffParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp) | ||
179 | { | ||
180 | OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT; | ||
181 | OMX_U32 inPort = (OMX_U32)OMX_VIDDEC_INPUT_PORT; | ||
182 | OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]); | ||
183 | OMX_CONFIG_RECTTYPE *p2DInBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[inPort]); | ||
184 | |||
185 | PaddedBuffParams outBuffParams; | ||
186 | OMX_U32 nFrameWidth, nFrameHeight; | ||
187 | |||
188 | p2DOutBufAllocParam->nSize = sizeof(OMX_CONFIG_RECTTYPE); | ||
189 | p2DOutBufAllocParam->nVersion = pVidDecComp->sBase.nComponentVersion; | ||
190 | p2DOutBufAllocParam->nPortIndex = outPort; | ||
191 | |||
192 | nFrameWidth = pVidDecComp->sBase.pPorts[inPort]->sPortDef.format.video.nFrameWidth; | ||
193 | nFrameHeight = pVidDecComp->sBase.pPorts[inPort]->sPortDef.format.video.nFrameHeight; | ||
194 | if( nFrameWidth & 0x0F ) { | ||
195 | nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); | ||
196 | } | ||
197 | if( nFrameHeight & 0x1F ) { | ||
198 | nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); | ||
199 | } | ||
200 | outBuffParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, nFrameWidth, nFrameHeight); | ||
201 | |||
202 | p2DOutBufAllocParam->nWidth = outBuffParams.nPaddedWidth; | ||
203 | p2DOutBufAllocParam->nHeight = outBuffParams.nPaddedHeight; | ||
204 | p2DOutBufAllocParam->nLeft = outBuffParams.n2DBufferXAlignment; | ||
205 | p2DOutBufAllocParam->nTop = outBuffParams.n2DBufferYAlignment; | ||
206 | |||
207 | p2DInBufAllocParam->nSize = sizeof(OMX_CONFIG_RECTTYPE); | ||
208 | p2DInBufAllocParam->nVersion = pVidDecComp->sBase.nComponentVersion; | ||
209 | p2DInBufAllocParam->nPortIndex = OMX_VIDDEC_INPUT_PORT; | ||
210 | p2DInBufAllocParam->nWidth = pVidDecComp->sBase.pPorts[inPort]->sPortDef.nBufferSize; | ||
211 | p2DInBufAllocParam->nHeight = 1; //On input port only 1D buffers supported. | ||
212 | p2DInBufAllocParam->nLeft = pVidDecComp->sBase.pPorts[inPort]->sPortDef.nBufferAlignment; | ||
213 | p2DInBufAllocParam->nTop = 1; | ||
214 | } | ||
215 | |||
216 | |||
217 | OMX_ERRORTYPE OMXVidDec_HandleFLUSH_EOS(OMX_HANDLETYPE hComponent, | ||
218 | OMX_BUFFERHEADERTYPE *pLastOutBufHeader, | ||
219 | OMX_BUFFERHEADERTYPE *pInBufHeader) | ||
220 | { | ||
221 | OMX_ERRORTYPE eError = OMX_ErrorNone, eRMError = OMX_ErrorNone; | ||
222 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
223 | OMX_BUFFERHEADERTYPE *pDupBufHeader = NULL; | ||
224 | OMXVidDecComp *pVidDecComp = NULL; | ||
225 | OMX_U32 i = 0; | ||
226 | OMX_U32 nStride; | ||
227 | IVIDDEC3_OutArgs *pDecOutArgs = NULL; | ||
228 | OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT; | ||
229 | OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; | ||
230 | XDAS_Int32 status; | ||
231 | uint32_t nActualSize; | ||
232 | IMG_native_handle_t* grallocHandle; | ||
233 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
234 | XDM_Rect activeFrameRegion[2]; | ||
235 | |||
236 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
237 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
238 | pDecOutArgs = pVidDecComp->pDecOutArgs; | ||
239 | p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]); | ||
240 | |||
241 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[outPort]->sPortDef); | ||
242 | /*! Ensure that the stride on output portdef structure is more than | ||
243 | the padded width. This is needed in the case where application | ||
244 | sets the Stride less than padded width */ | ||
245 | if( (OMX_U32)pOutputPortDef->format.video.nStride >= | ||
246 | p2DOutBufAllocParam->nWidth ) { | ||
247 | nStride = pOutputPortDef->format.video.nStride; | ||
248 | } else { | ||
249 | nStride = p2DOutBufAllocParam->nWidth; | ||
250 | } | ||
251 | |||
252 | if( pVidDecComp->nFrameCounter > 0 ) { | ||
253 | /* Call codec flush and call process call until error */ | ||
254 | OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); | ||
255 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_FLUSH, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
256 | if( status != VIDDEC3_EOK ) { | ||
257 | OSAL_ErrorTrace("VIDDEC3_control XDM_FLUSH failed ....! \n"); | ||
258 | eError = OMX_ErrorInsufficientResources; | ||
259 | goto EXIT; | ||
260 | } | ||
261 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
262 | do { | ||
263 | pVidDecComp->tOutBufDesc->numBufs = 0; | ||
264 | pVidDecComp->tInBufDesc->numBufs = 0; | ||
265 | status = VIDDEC3_process(pVidDecComp->pDecHandle, (XDM2_BufDesc *)pVidDecComp->tInBufDesc, | ||
266 | (XDM2_BufDesc *)pVidDecComp->tOutBufDesc, | ||
267 | (VIDDEC3_InArgs *)pVidDecComp->pDecInArgs, | ||
268 | (VIDDEC3_OutArgs *)pVidDecComp->pDecOutArgs); | ||
269 | |||
270 | /*! In case this is an IPC failure */ | ||
271 | if(status == DCE_EIPC_CALL_FAIL) { | ||
272 | ALOGE("\n Remote Core Communication Failure... \n"); | ||
273 | eError = OMX_ErrorHardware; | ||
274 | pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE; | ||
275 | goto EXIT; | ||
276 | } | ||
277 | |||
278 | if( status != XDM_EFAIL ) { | ||
279 | /* Send the buffers out */ | ||
280 | i = 0; | ||
281 | while( pDecOutArgs->outputID[i] ) { | ||
282 | pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[i]; | ||
283 | if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { | ||
284 | OSAL_ReadFromPipe(pVidDecComp->pTimeStampStoragePipe, &(pDupBufHeader->nTimeStamp), | ||
285 | sizeof(OMX_TICKS), &(nActualSize), OSAL_NO_SUSPEND); | ||
286 | } | ||
287 | |||
288 | activeFrameRegion[0] = pDecOutArgs->displayBufs.bufDesc[0].activeFrameRegion; | ||
289 | activeFrameRegion[1].bottomRight.y = (activeFrameRegion[0].bottomRight.y) / 2; | ||
290 | activeFrameRegion[1].bottomRight.x = activeFrameRegion[0].bottomRight.x; | ||
291 | |||
292 | // Crop rectangle handles the Y and UV buffer offsets | ||
293 | pDupBufHeader->nOffset = 0; | ||
294 | pDupBufHeader->nFilledLen = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3 ) / 2; | ||
295 | |||
296 | if((pVidDecComp->tCropDimension.nTop != activeFrameRegion[0].topLeft.y | ||
297 | || pVidDecComp->tCropDimension.nLeft != activeFrameRegion[0].topLeft.x) | ||
298 | || (pVidDecComp->tCropDimension.nWidth != (OMX_U32)(activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x) | ||
299 | || pVidDecComp->tCropDimension.nHeight != (OMX_U32)(activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y))) { | ||
300 | pVidDecComp->tCropDimension.nTop = activeFrameRegion[0].topLeft.y; | ||
301 | pVidDecComp->tCropDimension.nLeft = activeFrameRegion[0].topLeft.x; | ||
302 | pVidDecComp->tCropDimension.nWidth = activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x; | ||
303 | pVidDecComp->tCropDimension.nHeight = activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y; | ||
304 | if( pVidDecComp->bUsePortReconfigForCrop == OMX_TRUE ) { | ||
305 | eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventPortSettingsChanged, | ||
306 | OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonOutputCrop, NULL); | ||
307 | if( eError != OMX_ErrorNone ) { | ||
308 | OSAL_ErrorTrace("Port reconfig callback returned error, trying to continue"); | ||
309 | } | ||
310 | } | ||
311 | } | ||
312 | |||
313 | if( pVidDecComp->bSupportSkipGreyOutputFrames ) { | ||
314 | if( pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_I_FRAME || | ||
315 | pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IDR_FRAME || | ||
316 | pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IP_FRAME || | ||
317 | pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IB_FRAME ) { | ||
318 | pVidDecComp->bSyncFrameReady = OMX_TRUE; | ||
319 | } | ||
320 | } | ||
321 | grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer); | ||
322 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle); | ||
323 | |||
324 | if( pVidDecComp->bSyncFrameReady == OMX_TRUE ) { | ||
325 | // Send the Output buffer to Base component | ||
326 | pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, | ||
327 | OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader); | ||
328 | } | ||
329 | pDecOutArgs->outputID[i] = 0; | ||
330 | i++; | ||
331 | } | ||
332 | i = 0; | ||
333 | while( pDecOutArgs->freeBufID[i] != 0 ) { | ||
334 | pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->freeBufID[i]; | ||
335 | ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; | ||
336 | if( pDupBufHeader ) { | ||
337 | grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer); | ||
338 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
339 | (buffer_handle_t)grallocHandle); | ||
340 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
341 | OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader); | ||
342 | } | ||
343 | i++; | ||
344 | } | ||
345 | } | ||
346 | } while( status != XDM_EFAIL ); | ||
347 | } | ||
348 | if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { | ||
349 | OSAL_ClearPipe(pVidDecComp->pTimeStampStoragePipe); | ||
350 | } | ||
351 | if( pLastOutBufHeader != NULL ) { | ||
352 | pLastOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; | ||
353 | grallocHandle = (IMG_native_handle_t*)(pLastOutBufHeader->pBuffer); | ||
354 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
355 | (buffer_handle_t)grallocHandle); | ||
356 | pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_OUTPUT_PORT, pLastOutBufHeader); | ||
357 | } | ||
358 | if( pInBufHeader != NULL ) { | ||
359 | pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_INPUT_PORT, pInBufHeader); | ||
360 | /* Send the EOS event to client */ | ||
361 | pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventBufferFlag, | ||
362 | OMX_VIDDEC_OUTPUT_PORT, OMX_BUFFERFLAG_EOS, NULL); | ||
363 | } | ||
364 | pVidDecComp->nFrameCounter = 0; | ||
365 | if( pVidDecComp->bSupportSkipGreyOutputFrames ) { | ||
366 | pVidDecComp->bSyncFrameReady = OMX_FALSE; | ||
367 | } | ||
368 | pVidDecComp->nOutbufInUseFlag = 0; | ||
369 | pVidDecComp->nFatalErrorGiven = 0; | ||
370 | |||
371 | EXIT: | ||
372 | if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) { | ||
373 | //Clear the pipe, to discard the stale messages | ||
374 | OSAL_ERROR err = OSAL_ClearPipe(pVidDecComp->pTimeStampStoragePipe); | ||
375 | if( err != OSAL_ErrNone ) { | ||
376 | /* if pipe clear fails, nothing can be done, just put error trace */ | ||
377 | OSAL_ErrorTrace("\npipe clear failed"); | ||
378 | } | ||
379 | } | ||
380 | return (eError); | ||
381 | } | ||
382 | |||
383 | /* ==========================================================================*/ | ||
384 | /** | ||
385 | * @fn Calc_InbufSize() | ||
386 | * This method Calcullates Buffer size given width and | ||
387 | * height of buffer | ||
388 | * | ||
389 | * @param [in] width : Width of the buffer | ||
390 | * @param [in] height : Height of the buffer | ||
391 | * | ||
392 | */ | ||
393 | /* ==========================================================================*/ | ||
394 | OMX_U32 Calc_InbufSize(OMX_U32 width, OMX_U32 height) | ||
395 | { | ||
396 | return ((width * height * 3) / 2); | ||
397 | } | ||
398 | |||
399 | OMX_ERRORTYPE OMXVidDec_SetInPortDef(OMX_HANDLETYPE hComponent, | ||
400 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs) | ||
401 | { | ||
402 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
403 | OMX_VIDEO_CODINGTYPE currentCompressionType, desiredCompressionType; | ||
404 | OMX_U32 nFrameWidth, nFrameHeight; | ||
405 | OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; | ||
406 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
407 | PaddedBuffParams tOutBufParams; | ||
408 | OMX_U32 i=0; | ||
409 | OMX_U32 bFound = 0; | ||
410 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
411 | OMXVidDecComp *pVidDecComp = NULL; | ||
412 | |||
413 | /*! Initialize pointers and variables */ | ||
414 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
415 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
416 | pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); | ||
417 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
418 | nFrameWidth = pPortDefs->format.video.nFrameWidth; | ||
419 | nFrameHeight = pPortDefs->format.video.nFrameHeight; | ||
420 | if( nFrameWidth & 0x0F ) { | ||
421 | nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); | ||
422 | } | ||
423 | if( nFrameHeight & 0x1F ) { | ||
424 | nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); | ||
425 | } | ||
426 | currentCompressionType = pInputPortDef->format.video.eCompressionFormat; | ||
427 | desiredCompressionType = pPortDefs->format.video.eCompressionFormat; | ||
428 | /*! In case there is change in Compression type */ | ||
429 | if( currentCompressionType != desiredCompressionType ) { | ||
430 | /* De-initialize the current codec */ | ||
431 | pVidDecComp->fpDeinit_Codec(hComponent); | ||
432 | /* Call specific component init depending upon the | ||
433 | eCompressionFormat set. */ | ||
434 | i=0; | ||
435 | while( NULL != DecoderList[i].eCompressionFormat ) { | ||
436 | if( DecoderList[i].eCompressionFormat | ||
437 | == desiredCompressionType ) { | ||
438 | /* Component found */ | ||
439 | bFound = 1; | ||
440 | break; | ||
441 | } | ||
442 | i++; | ||
443 | } | ||
444 | if( bFound == 0 ) { | ||
445 | OSAL_ErrorTrace("Unsupported Compression format given in port definition"); | ||
446 | eError = OMX_ErrorUnsupportedSetting; | ||
447 | goto EXIT; | ||
448 | } | ||
449 | /* Call the Specific Decoder Init function and Initialize Params */ | ||
450 | eError = DecoderList[i].fpDecoderComponentInit(hComponent); | ||
451 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
452 | OMXVidDec_InitDecoderParams(hComponent, pHandle->pComponentPrivate); | ||
453 | strcpy((char *)pVidDecComp->tComponentRole.cRole, | ||
454 | (char *)DecoderList[i].cRole); | ||
455 | } /* End of if condition for change in codec type */ | ||
456 | |||
457 | /*! set the Actual values of an Input port */ | ||
458 | pInputPortDef->nBufferCountActual = pPortDefs->nBufferCountActual; | ||
459 | pInputPortDef->format = pPortDefs->format; | ||
460 | pInputPortDef->nBufferSize = Calc_InbufSize(nFrameWidth, nFrameHeight); | ||
461 | pVidDecComp->tCropDimension.nTop = 0; | ||
462 | pVidDecComp->tCropDimension.nLeft = 0; | ||
463 | pVidDecComp->tCropDimension.nWidth = pInputPortDef->format.video.nFrameWidth; | ||
464 | pVidDecComp->tCropDimension.nHeight = pInputPortDef->format.video.nFrameHeight; | ||
465 | |||
466 | /*! Set o/p port details according to width/height set at i/p Port. */ | ||
467 | pOutputPortDef->format.video.nFrameWidth = pInputPortDef->format.video.nFrameWidth; | ||
468 | pOutputPortDef->format.video.nFrameHeight = pInputPortDef->format.video.nFrameHeight; | ||
469 | pOutputPortDef->format.video.nStride = pInputPortDef->format.video.nFrameWidth; | ||
470 | OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate); | ||
471 | pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * | ||
472 | ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1); | ||
473 | |||
474 | tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, nFrameWidth, nFrameHeight); | ||
475 | pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin; | ||
476 | pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual; | ||
477 | |||
478 | /*! Set the Static Params (Decoder Specific) */ | ||
479 | pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams); | ||
480 | pVidDecComp->pDecStaticParams->maxHeight = nFrameHeight; | ||
481 | pVidDecComp->pDecStaticParams->maxWidth = nFrameWidth; | ||
482 | if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) { | ||
483 | pVidDecComp->pDecStaticParams->maxWidth = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth; | ||
484 | } | ||
485 | if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) { | ||
486 | pOutputPortDef->nBufferCountActual = pOutputPortDef->nBufferCountMin; | ||
487 | } | ||
488 | |||
489 | EXIT: | ||
490 | return (eError); | ||
491 | |||
492 | } | ||
493 | |||
494 | OMX_ERRORTYPE OMXVidDec_SetOutPortDef(OMXVidDecComp *pVidDecComp, | ||
495 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs) | ||
496 | { | ||
497 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
498 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
499 | OMX_PTR *pBufParams = NULL; | ||
500 | OMX_U32 nOutPort = OMX_VIDDEC_OUTPUT_PORT; | ||
501 | OMX_U32 nNumBuffers = 0; | ||
502 | |||
503 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[nOutPort]->sPortDef); | ||
504 | |||
505 | /*! Set Values to output port based on input parameter */ | ||
506 | pOutputPortDef->nBufferCountActual = pPortDefs->nBufferCountActual; | ||
507 | pOutputPortDef->format = pPortDefs->format; | ||
508 | pOutputPortDef->format.video.nSliceHeight | ||
509 | = pOutputPortDef->format.video.nFrameHeight; | ||
510 | pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * | ||
511 | ((pVidDecComp->t2DBufferAllocParams[nOutPort].nHeight * 3) >> 1); | ||
512 | |||
513 | EXIT: | ||
514 | return (eError); | ||
515 | } | ||
516 | |||
517 | |||
518 | OMX_ERRORTYPE OMXVidDec_HandleFirstFrame(OMX_HANDLETYPE hComponent, | ||
519 | OMX_BUFFERHEADERTYPE * *ppInBufHeader) | ||
520 | { | ||
521 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
522 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
523 | OMX_U32 nFrameWidth, nFrameHeight, nFrameWidthNew, nFrameHeightNew, nFrameRate, nFrameRateNew; | ||
524 | OMXVidDecComp *pVidDecComp = NULL; | ||
525 | XDAS_Int32 status = 0; | ||
526 | IVIDDEC3_Status *pDecStatus = NULL; | ||
527 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
528 | OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; | ||
529 | PaddedBuffParams tOutBufParams; | ||
530 | OMX_BUFFERHEADERTYPE *pInBufHeader; | ||
531 | OMX_BOOL bPortReconfigRequiredForPadding = OMX_FALSE; | ||
532 | OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; | ||
533 | |||
534 | OMX_BOOL bSendPortReconfigForScale = OMX_FALSE; | ||
535 | OMX_U32 nScale, nScaleRem, nScaleQ16Low, nScaleWidth, nScaleHeight; | ||
536 | OMX_U64 nScaleQ16 = 0; | ||
537 | |||
538 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
539 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
540 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
541 | pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); | ||
542 | pVidDecComp->nOutPortReconfigRequired = 0; | ||
543 | p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]); | ||
544 | |||
545 | /*! Call the Codec Control call to get Status from Codec */ | ||
546 | OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); | ||
547 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETSTATUS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
548 | if( status != VIDDEC3_EOK ) { | ||
549 | OSAL_ErrorTrace("Error in Codec Control Call for GETSTATUS"); | ||
550 | eError = OMX_ErrorInsufficientResources; | ||
551 | goto EXIT; | ||
552 | } | ||
553 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
554 | if( pVidDecComp->fpHandle_CodecGetStatus != NULL ) { | ||
555 | eError = pVidDecComp->fpHandle_CodecGetStatus(hComponent); | ||
556 | } | ||
557 | pDecStatus = (IVIDDEC3_Status *)(pVidDecComp->pDecStatus); | ||
558 | nFrameWidth = pOutputPortDef->format.video.nFrameWidth; | ||
559 | nFrameHeight = pOutputPortDef->format.video.nFrameHeight; | ||
560 | nFrameWidthNew = (OMX_U32)pDecStatus->outputWidth; | ||
561 | nFrameHeightNew = (OMX_U32)pDecStatus->outputHeight; | ||
562 | nFrameRate = pOutputPortDef->format.video.xFramerate >> 16; | ||
563 | |||
564 | OMX_CHECK(pVidDecComp->nFrameRateDivisor != 0, OMX_ErrorBadParameter); | ||
565 | nFrameRateNew = (OMX_U32)(pDecStatus->frameRate / pVidDecComp->nFrameRateDivisor); | ||
566 | /*Set 200 as max cap, as if clip with incorrect setting is present in sdcard | ||
567 | it breaks havoc on thumbnail generation */ | ||
568 | if((nFrameRateNew == 0) || (nFrameRateNew > 200)) { | ||
569 | OSAL_ErrorTrace("Codec Returned spurious FrameRate Value - %d Setting Back to - %d", | ||
570 | nFrameRateNew, nFrameRate); | ||
571 | nFrameRateNew = nFrameRate; | ||
572 | } | ||
573 | |||
574 | if( nFrameWidth & 0x0F ) { | ||
575 | nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); | ||
576 | } | ||
577 | if( nFrameHeight & 0x1F ) { | ||
578 | nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); | ||
579 | } | ||
580 | if( nFrameWidthNew & 0x0F ) { | ||
581 | nFrameWidthNew = nFrameWidthNew + 16 - (nFrameWidthNew & 0x0F); | ||
582 | } | ||
583 | if( nFrameHeightNew & 0x1F ) { | ||
584 | nFrameHeightNew = nFrameHeightNew + 32 - (nFrameHeightNew & 0x1F); | ||
585 | } | ||
586 | if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { | ||
587 | if( pOutputPortDef->format.video.nFrameWidth != p2DOutBufAllocParam->nWidth | ||
588 | || pOutputPortDef->format.video.nFrameHeight != p2DOutBufAllocParam->nHeight ) { | ||
589 | bPortReconfigRequiredForPadding = OMX_TRUE; | ||
590 | } | ||
591 | nFrameWidth = pVidDecComp->pDecStaticParams->maxWidth; | ||
592 | nFrameHeight = pVidDecComp->pDecStaticParams->maxHeight; | ||
593 | } | ||
594 | |||
595 | /*! Check whether the displayWidth already accounts for any | ||
596 | * difference between the current and new frame width */ | ||
597 | if ( nFrameWidth != nFrameWidthNew && | ||
598 | nFrameWidth == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) { | ||
599 | nFrameWidthNew = nFrameWidth; | ||
600 | } | ||
601 | |||
602 | tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, | ||
603 | (OMX_U32)pDecStatus->outputWidth, (OMX_U32)pDecStatus->outputHeight); | ||
604 | |||
605 | /*! Check whether the height and width reported by codec matches | ||
606 | * that of output port */ | ||
607 | if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth | ||
608 | || bPortReconfigRequiredForPadding == OMX_TRUE || | ||
609 | pOutputPortDef->nBufferCountMin < tOutBufParams.nBufferCountMin || | ||
610 | nFrameRate < nFrameRateNew ) { /* Compare the min againt the older min buffer count | ||
611 | since parameters like display delay also gets set according to ref frame. */ | ||
612 | /*! Since the dimensions does not match trigger port reconfig */ | ||
613 | pVidDecComp->nOutPortReconfigRequired = 1; | ||
614 | pVidDecComp->nCodecRecreationRequired = 1; | ||
615 | /* Return back the Input buffer headers Note that the output header | ||
616 | * will be cancelled later so no need to cancel it here */ | ||
617 | if( ppInBufHeader != NULL ) { | ||
618 | pInBufHeader = *(ppInBufHeader); | ||
619 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_VIDDEC_INPUT_PORT, | ||
620 | pInBufHeader); | ||
621 | pInBufHeader = NULL; | ||
622 | } | ||
623 | /*! Change port definition to match with what codec reports */ | ||
624 | pInputPortDef->format.video.nFrameHeight = (OMX_U32)pDecStatus->outputHeight; | ||
625 | pInputPortDef->format.video.nFrameWidth = (OMX_U32)pDecStatus->outputWidth; | ||
626 | pOutputPortDef->format.video.nFrameHeight = (OMX_U32)pDecStatus->outputHeight; | ||
627 | pOutputPortDef->format.video.nFrameWidth = (OMX_U32)pDecStatus->outputWidth; | ||
628 | pOutputPortDef->format.video.nStride = (OMX_U32)pDecStatus->outputWidth; | ||
629 | pOutputPortDef->format.video.nSliceHeight = (OMX_U32)pDecStatus->outputHeight; | ||
630 | if( nFrameRate < nFrameRateNew ) { | ||
631 | pOutputPortDef->format.video.xFramerate = nFrameRateNew << 16; | ||
632 | pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].xFramerate = nFrameRateNew; | ||
633 | } | ||
634 | pVidDecComp->tCropDimension.nWidth = (OMX_U32)pDecStatus->outputWidth; | ||
635 | pVidDecComp->tCropDimension.nHeight = (OMX_U32)pDecStatus->outputHeight; | ||
636 | tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, | ||
637 | (OMX_U32)pDecStatus->outputWidth, | ||
638 | (OMX_U32)pDecStatus->outputHeight); | ||
639 | pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin; | ||
640 | pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual; | ||
641 | OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate); | ||
642 | |||
643 | pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; | ||
644 | pOutputPortDef->format.video.nSliceHeight = p2DOutBufAllocParam->nHeight; | ||
645 | |||
646 | pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * | ||
647 | ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1); | ||
648 | if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { | ||
649 | pInputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight; | ||
650 | pInputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth; | ||
651 | pOutputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight; | ||
652 | pOutputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | if( pVidDecComp->nOutPortReconfigRequired == 1 ) { | ||
657 | /*! Notify to Client change in output port settings */ | ||
658 | eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, | ||
659 | OMX_EventPortSettingsChanged, | ||
660 | OMX_VIDDEC_OUTPUT_PORT, 0, NULL); | ||
661 | } else if( pDecStatus->sampleAspectRatioHeight != 0 && pDecStatus->sampleAspectRatioWidth != 0 ) { | ||
662 | nScaleWidth = (OMX_U32)pDecStatus->sampleAspectRatioWidth; | ||
663 | nScaleHeight = (OMX_U32)pDecStatus->sampleAspectRatioHeight; | ||
664 | nScale = nScaleWidth / nScaleHeight; | ||
665 | if( nScale >= 1 ) { | ||
666 | nScaleRem = nScaleWidth % nScaleHeight; | ||
667 | nScaleQ16Low = 0xFFFF * nScaleRem / nScaleHeight; | ||
668 | nScaleQ16 = nScale << 16; | ||
669 | nScaleQ16 |= nScaleQ16Low; | ||
670 | if( (OMX_U64)pVidDecComp->tScaleParams.xWidth != nScaleQ16 | ||
671 | || pVidDecComp->tScaleParams.xHeight != 0x10000 ) { | ||
672 | pVidDecComp->tScaleParams.xWidth = nScaleQ16; | ||
673 | pVidDecComp->tScaleParams.xHeight = 0x10000; | ||
674 | bSendPortReconfigForScale = OMX_TRUE; | ||
675 | } | ||
676 | } else { | ||
677 | nScale = nScaleHeight / nScaleWidth; | ||
678 | nScaleRem = nScaleHeight % nScaleWidth; | ||
679 | nScaleQ16Low = 0xFFFF * nScaleRem / nScaleWidth; | ||
680 | nScaleQ16 = nScale << 16; | ||
681 | nScaleQ16 |= nScaleQ16Low; | ||
682 | if( pVidDecComp->tScaleParams.xWidth != 0x10000 | ||
683 | || (OMX_U64)pVidDecComp->tScaleParams.xHeight != nScaleQ16 ) { | ||
684 | pVidDecComp->tScaleParams.xWidth = 0x10000; | ||
685 | pVidDecComp->tScaleParams.xHeight = nScaleQ16; | ||
686 | bSendPortReconfigForScale = OMX_TRUE; | ||
687 | } | ||
688 | } | ||
689 | if( bSendPortReconfigForScale == OMX_TRUE ) { | ||
690 | /*! Notify to Client change in output port settings */ | ||
691 | eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, | ||
692 | OMX_EventPortSettingsChanged, OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonScale, NULL); | ||
693 | bSendPortReconfigForScale = OMX_FALSE; | ||
694 | } | ||
695 | } | ||
696 | |||
697 | EXIT: | ||
698 | return (eError); | ||
699 | |||
700 | } | ||
701 | |||
702 | OMX_ERRORTYPE OMXVidDec_HandleCodecProcError(OMX_HANDLETYPE hComponent, | ||
703 | OMX_BUFFERHEADERTYPE * *ppInBufHeader, | ||
704 | OMX_BUFFERHEADERTYPE * *ppOutBufHeader) | ||
705 | { | ||
706 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
707 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
708 | OMX_U32 nFrameWidth, nFrameHeight, nFrameWidthNew, nFrameHeightNew; | ||
709 | OMXVidDecComp *pVidDecComp = NULL; | ||
710 | XDAS_Int32 status = 0; | ||
711 | IVIDDEC3_Status *pDecStatus = NULL; | ||
712 | OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL; | ||
713 | OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL; | ||
714 | PaddedBuffParams tOutBufParams; | ||
715 | OMX_BUFFERHEADERTYPE *pInBufHeader = *(ppInBufHeader); | ||
716 | OMX_BUFFERHEADERTYPE *pDupBufHeader; | ||
717 | OMX_BUFFERHEADERTYPE *pNewOutBufHeader = NULL; | ||
718 | OMX_BUFFERHEADERTYPE *pOutBufHeader = *(ppOutBufHeader); | ||
719 | OMX_U32 ii=0; | ||
720 | OMX_U32 nStride =0; | ||
721 | OMX_BOOL bPortReconfigRequiredForPadding = OMX_FALSE; | ||
722 | OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL; | ||
723 | IMG_native_handle_t* grallocHandle; | ||
724 | |||
725 | /* Initialize pointers */ | ||
726 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
727 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
728 | pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef); | ||
729 | pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef); | ||
730 | p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]); | ||
731 | |||
732 | /*! Call the Codec Status function to know cause of error */ | ||
733 | OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter); | ||
734 | status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETSTATUS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus); | ||
735 | |||
736 | /* Check whether the Codec Status call was succesful */ | ||
737 | if( status != VIDDEC3_EOK ) { | ||
738 | OSAL_ErrorTrace("VIDDEC3_control XDM_GETSTATUS failed"); | ||
739 | if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader | ||
740 | != pVidDecComp->nDecoderMode ) { | ||
741 | // Return the Input and Output buffer header | ||
742 | grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); | ||
743 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
744 | (buffer_handle_t)grallocHandle); | ||
745 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
746 | OMX_VIDDEC_OUTPUT_PORT, | ||
747 | pOutBufHeader); | ||
748 | |||
749 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
750 | OMX_VIDDEC_INPUT_PORT, | ||
751 | pInBufHeader); | ||
752 | /*! Make Input buffer header pointer NULL */ | ||
753 | pInBufHeader = NULL; | ||
754 | } | ||
755 | eError = OMX_ErrorInsufficientResources; | ||
756 | goto EXIT; | ||
757 | } | ||
758 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
759 | |||
760 | pDecStatus = (IVIDDEC3_Status *)(pVidDecComp->pDecStatus); | ||
761 | nFrameWidth = pOutputPortDef->format.video.nFrameWidth; | ||
762 | nFrameHeight = pOutputPortDef->format.video.nFrameHeight; | ||
763 | nFrameWidthNew = pDecStatus->outputWidth; | ||
764 | nFrameHeightNew = pDecStatus->outputHeight; | ||
765 | |||
766 | if( nFrameWidth & 0x0F ) { | ||
767 | nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F); | ||
768 | } | ||
769 | if( nFrameHeight & 0x1F ) { | ||
770 | nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F); | ||
771 | } | ||
772 | if( nFrameWidthNew & 0x0F ) { | ||
773 | nFrameWidthNew = nFrameWidthNew + 16 - (nFrameWidthNew & 0x0F); | ||
774 | } | ||
775 | if( nFrameHeightNew & 0x1F ) { | ||
776 | nFrameHeightNew = nFrameHeightNew + 32 - (nFrameHeightNew & 0x1F); | ||
777 | } | ||
778 | |||
779 | if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { | ||
780 | if( pOutputPortDef->format.video.nFrameWidth != p2DOutBufAllocParam->nWidth | ||
781 | || pOutputPortDef->format.video.nFrameHeight != p2DOutBufAllocParam->nHeight ) { | ||
782 | bPortReconfigRequiredForPadding = OMX_TRUE; | ||
783 | } | ||
784 | nFrameWidth = pVidDecComp->pDecStaticParams->maxWidth; | ||
785 | nFrameHeight = pVidDecComp->pDecStaticParams->maxHeight; | ||
786 | } | ||
787 | |||
788 | /*! Check whether the displayWidth already accounts for any | ||
789 | * difference between the current and new frame width */ | ||
790 | if ( nFrameWidth != nFrameWidthNew && | ||
791 | nFrameWidth == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) { | ||
792 | nFrameWidthNew = nFrameWidth; | ||
793 | } | ||
794 | |||
795 | /*! Check whether the height and width reported by codec matches | ||
796 | * that of output port */ | ||
797 | if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth | ||
798 | || bPortReconfigRequiredForPadding == OMX_TRUE ) { | ||
799 | pVidDecComp->nOutPortReconfigRequired = 1; | ||
800 | pVidDecComp->nCodecRecreationRequired = 1; | ||
801 | } | ||
802 | |||
803 | if( pVidDecComp->fpHandle_ExtendedError != NULL ) { | ||
804 | eError = pVidDecComp->fpHandle_ExtendedError(hComponent); | ||
805 | } | ||
806 | |||
807 | if( pVidDecComp->nOutPortReconfigRequired == 1 ) { | ||
808 | pNewOutBufHeader = (OMX_BUFFERHEADERTYPE *) pVidDecComp->pDecOutArgs->outputID[0]; | ||
809 | if( pNewOutBufHeader != NULL ) { | ||
810 | pVidDecComp->tCropDimension.nWidth = pDecStatus->outputWidth; | ||
811 | pVidDecComp->tCropDimension.nHeight = pDecStatus->outputHeight; | ||
812 | nStride = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nStride; | ||
813 | // Crop rect handles the offsets for Y and UV buffers | ||
814 | pNewOutBufHeader->nOffset = 0; | ||
815 | // FilledLen | ||
816 | pNewOutBufHeader->nFilledLen | ||
817 | = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) / 2; | ||
818 | grallocHandle = (IMG_native_handle_t*)(pNewOutBufHeader->pBuffer); | ||
819 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
820 | (buffer_handle_t)grallocHandle); | ||
821 | pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_OUTPUT_PORT, | ||
822 | pNewOutBufHeader); | ||
823 | } | ||
824 | |||
825 | if( pVidDecComp->nOutbufInUseFlag == 0 | ||
826 | && (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) { | ||
827 | grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); | ||
828 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
829 | (buffer_handle_t)grallocHandle); | ||
830 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
831 | OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); // This buffer header is freed afterwards. | ||
832 | } else { | ||
833 | pOutBufHeader = NULL; | ||
834 | } | ||
835 | if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) { | ||
836 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
837 | OMX_VIDDEC_INPUT_PORT, pInBufHeader); | ||
838 | |||
839 | while( pVidDecComp->pDecOutArgs->freeBufID[ii] != 0 ) { | ||
840 | pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pVidDecComp->pDecOutArgs->freeBufID[ii++]; | ||
841 | ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; | ||
842 | if( pDupBufHeader != pOutBufHeader && pDupBufHeader != pNewOutBufHeader ) { | ||
843 | grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer); | ||
844 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
845 | (buffer_handle_t)grallocHandle); | ||
846 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
847 | OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader); | ||
848 | } | ||
849 | } | ||
850 | } | ||
851 | |||
852 | /*! Notify to Client change in output port settings */ | ||
853 | eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, | ||
854 | OMX_EventPortSettingsChanged, | ||
855 | OMX_VIDDEC_OUTPUT_PORT, 0, NULL); | ||
856 | } | ||
857 | if( pVidDecComp->nOutPortReconfigRequired == 0 ) { | ||
858 | if( pVidDecComp->pDecOutArgs->extendedError & 0x8000 ) { | ||
859 | eError = OMX_ErrorFormatNotDetected; | ||
860 | if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) { | ||
861 | if( pVidDecComp->nOutbufInUseFlag == 0 ) { | ||
862 | grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer); | ||
863 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
864 | (buffer_handle_t)grallocHandle); | ||
865 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
866 | OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); // This buffer header is freed afterwards. | ||
867 | } | ||
868 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
869 | OMX_VIDDEC_INPUT_PORT, pInBufHeader); | ||
870 | while( pVidDecComp->pDecOutArgs->freeBufID[ii] != 0 ) { | ||
871 | pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pVidDecComp->pDecOutArgs->freeBufID[ii++]; | ||
872 | ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE; | ||
873 | if( pOutBufHeader != pDupBufHeader ) { | ||
874 | grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer); | ||
875 | pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, | ||
876 | (buffer_handle_t)grallocHandle); | ||
877 | pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, | ||
878 | OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader); | ||
879 | } | ||
880 | } | ||
881 | } | ||
882 | pVidDecComp->nFatalErrorGiven = 1; | ||
883 | } | ||
884 | } | ||
885 | |||
886 | if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth | ||
887 | || bPortReconfigRequiredForPadding == OMX_TRUE ) { | ||
888 | /*Return back the locked buffers before changing the port definition */ | ||
889 | OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL); | ||
890 | /*! Change Port Definition */ | ||
891 | pInputPortDef->format.video.nFrameHeight = pDecStatus->outputHeight; | ||
892 | pInputPortDef->format.video.nFrameWidth = pDecStatus->outputWidth; | ||
893 | |||
894 | pOutputPortDef->format.video.nFrameHeight = pDecStatus->outputHeight; | ||
895 | pOutputPortDef->format.video.nFrameWidth = pDecStatus->outputWidth; | ||
896 | pOutputPortDef->format.video.nSliceHeight = pDecStatus->outputHeight; | ||
897 | pVidDecComp->tCropDimension.nWidth = pDecStatus->outputWidth; | ||
898 | pVidDecComp->tCropDimension.nHeight = pDecStatus->outputHeight; | ||
899 | tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, | ||
900 | pDecStatus->outputWidth, | ||
901 | pDecStatus->outputHeight); | ||
902 | pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin; | ||
903 | pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual; | ||
904 | OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate); | ||
905 | |||
906 | pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; | ||
907 | |||
908 | pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride * | ||
909 | ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1); | ||
910 | if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) { | ||
911 | pInputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight; | ||
912 | pInputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth; | ||
913 | pOutputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight; | ||
914 | pOutputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth; | ||
915 | pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth; | ||
916 | pOutputPortDef->format.video.nSliceHeight = p2DOutBufAllocParam->nHeight; | ||
917 | } | ||
918 | } | ||
919 | |||
920 | EXIT: | ||
921 | return (eError); | ||
922 | } | ||
923 | |||
924 | void OMXVidDec_CalcFilledLen(OMX_HANDLETYPE hComponent, | ||
925 | IVIDDEC3_OutArgs *pDecOutArgs, | ||
926 | OMX_U32 nStride) | ||
927 | { | ||
928 | OMX_BUFFERHEADERTYPE *pOutBufHeader; | ||
929 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
930 | OMXVidDecComp *pVidDecComp = NULL; | ||
931 | |||
932 | /* Initialize the pointers */ | ||
933 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
934 | pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate; | ||
935 | |||
936 | pOutBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[0]; | ||
937 | /*Crop rectangle handles the offsets for Y and UV buffers */ | ||
938 | pOutBufHeader->nOffset = 0; | ||
939 | |||
940 | /*! Calcullate the Total Filled length */ | ||
941 | pOutBufHeader->nFilledLen = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) / 2; | ||
942 | |||
943 | return; | ||
944 | } | ||
945 | |||
946 | |||
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 @@ | |||
1 | LOCAL_PATH:= $(call my-dir) | ||
2 | |||
3 | # | ||
4 | # libOMX.TI.DUCATI1.VIDEO.H264E | ||
5 | # | ||
6 | |||
7 | include $(CLEAR_VARS) | ||
8 | |||
9 | LOCAL_C_INCLUDES += \ | ||
10 | frameworks/native/include/media/openmax \ | ||
11 | frameworks/native/include/media/hardware \ | ||
12 | $(LOCAL_PATH)/../base/omx_core/inc \ | ||
13 | $(LOCAL_PATH)/../osal/inc \ | ||
14 | $(LOCAL_PATH)/../base/omx_base_comp/inc \ | ||
15 | $(LOCAL_PATH)/../base/omx_base_dio_plugin/inc \ | ||
16 | hardware/ti/dra7xx/hwcomposer/ \ | ||
17 | hardware/ti/dce/ \ | ||
18 | system/core/include/cutils \ | ||
19 | $(LOCAL_PATH)/omx_h264_enc/inc \ | ||
20 | hardware/ti/dce/packages/codec_engine/ \ | ||
21 | hardware/ti/dce/packages/framework_components/ \ | ||
22 | hardware/ti/dce/packages/ivahd_codecs/ \ | ||
23 | hardware/ti/dce/packages/xdais/ \ | ||
24 | hardware/ti/dce/packages/xdctools | ||
25 | |||
26 | LOCAL_HEADER_LIBRARIES += libutils_headers | ||
27 | |||
28 | LOCAL_SHARED_LIBRARIES := \ | ||
29 | libosal \ | ||
30 | libc \ | ||
31 | liblog \ | ||
32 | libOMX \ | ||
33 | libhardware \ | ||
34 | libdce | ||
35 | |||
36 | LOCAL_CFLAGS += -Dxdc_target_types__=google/targets/arm/std.h -DSUPPORT_ANDROID_FRAMEBUFFER_HAL -DSUPPORT_ANDROID_MEMTRACK_HAL -DBUILDOS_ANDROID -Dxdc__deprecated_types | ||
37 | |||
38 | LOCAL_MODULE_TAGS:= optional | ||
39 | LOCAL_VENDOR_MODULE := true | ||
40 | |||
41 | LOCAL_SRC_FILES:= omx_h264_enc/src/omx_H264videoencoder.c \ | ||
42 | omx_h264_enc/src/omx_H264videoencoderutils.c | ||
43 | |||
44 | LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.H264E | ||
45 | |||
46 | 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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef _OMX_H264VE_COMPONENT_H | ||
18 | #define _OMX_H264VE_COMPONENT_H | ||
19 | |||
20 | #ifdef _cplusplus | ||
21 | extern "C" { | ||
22 | #endif /* _cplusplus */ | ||
23 | |||
24 | #include "native_handle.h" | ||
25 | #include <hal_public.h> | ||
26 | |||
27 | #include "omx_H264videoencoderutils.h" | ||
28 | |||
29 | #define OMX_VIDENC_NUM_PORTS (2) | ||
30 | |||
31 | #define OMX_ENGINE_NAME "ivahd_vidsvr" | ||
32 | |||
33 | typedef struct OMX_H264_LVL_BITRATE { | ||
34 | OMX_VIDEO_AVCLEVELTYPE eLevel; | ||
35 | OMX_U32 nMaxBitRateSupport; | ||
36 | }OMX_H264_LVL_BITRATE; | ||
37 | |||
38 | typedef struct OMX_MetaDataBuffer { | ||
39 | int type; | ||
40 | void *handle; | ||
41 | //int offset; | ||
42 | }OMX_MetaDataBuffer; | ||
43 | |||
44 | typedef struct OMX_StoreMetaDataInBuffersParams { | ||
45 | OMX_U32 nSize; | ||
46 | OMX_VERSIONTYPE nVersion; | ||
47 | OMX_U32 nPortIndex; | ||
48 | OMX_BOOL bStoreMetaData; | ||
49 | }OMX_StoreMetaDataInBuffersParams; | ||
50 | |||
51 | |||
52 | /*Android Data structures*/ | ||
53 | |||
54 | enum Type { | ||
55 | MEDIA_IMAGE_TYPE_UNKNOWN = 0, | ||
56 | MEDIA_IMAGE_TYPE_YUV, | ||
57 | }; | ||
58 | |||
59 | enum PlaneIndex { | ||
60 | Y = 0, | ||
61 | U, | ||
62 | V, | ||
63 | MAX_NUM_PLANES | ||
64 | }; | ||
65 | |||
66 | typedef struct PlaneInfo { | ||
67 | uint32_t mOffset; // offset of first pixel of the plane in bytes | ||
68 | // from buffer offset | ||
69 | uint32_t mColInc; // column increment in bytes | ||
70 | uint32_t mRowInc; // row increment in bytes | ||
71 | uint32_t mHorizSubsampling; // subsampling compared to the largest plane | ||
72 | uint32_t mVertSubsampling; // subsampling compared to the largest plane | ||
73 | }PlaneInfo; | ||
74 | |||
75 | // Structure describing a media image (frame) | ||
76 | // Currently only supporting YUV | ||
77 | typedef struct MediaImage { | ||
78 | int mType; | ||
79 | uint32_t mNumPlanes; // number of planes | ||
80 | uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) | ||
81 | uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) | ||
82 | uint32_t mBitDepth; // useable bit depth | ||
83 | PlaneInfo mPlane[MAX_NUM_PLANES]; | ||
84 | }MediaImage; | ||
85 | |||
86 | // A pointer to this struct is passed to OMX_GetParameter when the extension | ||
87 | // index for the 'OMX.google.android.index.describeColorFormat' | ||
88 | // extension is given. This method can be called from any component state | ||
89 | // other than invalid. The color-format, frame width/height, and stride/ | ||
90 | // slice-height parameters are ones that are associated with a raw video | ||
91 | // port (input or output), but the stride/slice height parameters may be | ||
92 | // incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will | ||
93 | // be used (while specifying this color format). | ||
94 | // | ||
95 | // The component shall fill out the MediaImage structure that | ||
96 | // corresponds to the described raw video format, and the potentially corrected | ||
97 | // stride and slice-height info. | ||
98 | // | ||
99 | // The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE, | ||
100 | // though most implementations can ignore this difference. When using native buffers, | ||
101 | // the component may change the configured color format to an optimized format. | ||
102 | // Additionally, when allocating these buffers for flexible usecase, the framework | ||
103 | // will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers | ||
104 | // is OMX_TRUE), the component shall fill out the MediaImage information for the | ||
105 | // scenario when these SW-readable/writable buffers are locked using gralloc_lock. | ||
106 | // Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must | ||
107 | // be supported for vendor-specific formats. | ||
108 | // | ||
109 | // For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers | ||
110 | // is OMX_TRUE and the component does not support this color format with native | ||
111 | // buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN. | ||
112 | typedef struct DescribeColorFormatParams { | ||
113 | OMX_U32 nSize; | ||
114 | OMX_VERSIONTYPE nVersion; | ||
115 | // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE | ||
116 | OMX_COLOR_FORMATTYPE eColorFormat; | ||
117 | OMX_U32 nFrameWidth; | ||
118 | OMX_U32 nFrameHeight; | ||
119 | OMX_U32 nStride; | ||
120 | OMX_U32 nSliceHeight; | ||
121 | OMX_BOOL bUsingNativeBuffers; | ||
122 | |||
123 | // output: fill out the MediaImage fields | ||
124 | MediaImage sMediaImage; | ||
125 | }DescribeColorFormatParams; | ||
126 | |||
127 | |||
128 | /* OMX H264 Encoder Component */ | ||
129 | typedef struct OMXH264VideoEncoderComponent { | ||
130 | /* base component handle */ | ||
131 | OMXBaseComp sBase; | ||
132 | |||
133 | /* codec and engine handles */ | ||
134 | Engine_Handle pCEhandle; | ||
135 | Engine_Error tCEerror; | ||
136 | VIDENC2_Handle pVidEncHandle; | ||
137 | OMX_BOOL bCodecCreate; | ||
138 | OMX_BOOL bCodecCreateSettingsChange; | ||
139 | |||
140 | /* Encoder static/dynamic/buf args */ | ||
141 | IH264ENC_Params *pVidEncStaticParams; | ||
142 | IH264ENC_DynamicParams *pVidEncDynamicParams; | ||
143 | IH264ENC_Status *pVidEncStatus; | ||
144 | IH264ENC_InArgs *pVidEncInArgs; | ||
145 | IH264ENC_OutArgs *pVidEncOutArgs; | ||
146 | IVIDEO2_BufDesc *pVedEncInBufs; | ||
147 | XDM2_BufDesc *pVedEncOutBufs; | ||
148 | |||
149 | /* omx component statemachine variables */ | ||
150 | OMX_BOOL bInputPortDisable; | ||
151 | OMX_BOOL bCodecFlush; | ||
152 | PARAMS_UPDATE_STATUS bCallxDMSetParams; | ||
153 | OMX_BOOL bAfterEOSReception; | ||
154 | OMX_BOOL bNotifyEOSEventToClient; | ||
155 | OMX_BOOL bPropagateEOSToOutputBuffer; | ||
156 | OMX_BOOL bSetParamInputIsDone; | ||
157 | |||
158 | /* codec config handling variables*/ | ||
159 | OMXBase_CodecConfigBuf sCodecConfigData; | ||
160 | OMX_BOOL bSendCodecConfig; | ||
161 | OMX_U32 nCodecConfigSize; | ||
162 | OMX_BOOL bAfterGenHeader; | ||
163 | |||
164 | /* internal buffer tracking arrays */ | ||
165 | OMX_BUFFERHEADERTYPE **pCodecInBufferArray; | ||
166 | OMXBase_BufHdrPvtData *pCodecInBufferBackupArray; | ||
167 | |||
168 | /* temporary memory to meet and codec and dce requirements */ | ||
169 | MemHeader *pTempBuffer[2]; | ||
170 | |||
171 | OMX_BOOL bInputMetaDataBufferMode; | ||
172 | OMX_PTR hCC; | ||
173 | IMG_native_handle_t **pBackupBuffers; | ||
174 | alloc_device_t *mAllocDev; | ||
175 | |||
176 | } OMXH264VidEncComp; | ||
177 | |||
178 | OMX_ERRORTYPE OMXH264VE_ComponentInit(OMX_HANDLETYPE hComponent); | ||
179 | |||
180 | #ifdef _cplusplus | ||
181 | } | ||
182 | #endif /* __cplusplus */ | ||
183 | |||
184 | #endif /* _OMX_H264VE_COMPONENT_H */ | ||
185 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <string.h> | ||
18 | |||
19 | #include <OMX_Core.h> | ||
20 | #include <OMX_Component.h> | ||
21 | #include <OMX_TI_Custom.h> | ||
22 | |||
23 | #include <omx_base.h> | ||
24 | #include <omx_base_utils.h> | ||
25 | |||
26 | #include <xdc/std.h> | ||
27 | #include <ti/sdo/ce/video2/videnc2.h> | ||
28 | #include <ti/sdo/codecs/h264enc/ih264enc.h> | ||
29 | |||
30 | /* For Baseline Profile :: FLAG to indicate Constrained Baseline profile in the Bitstream generated by codec | ||
31 | conforming to the H264Standard */ | ||
32 | #define OMX_H264_SET_CONSTRAINT_SET1_FLAG 0x14 | ||
33 | #define OMX_H264_SET_CONSTRAINT_SET1b_FLAG 0x15 | ||
34 | #define OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS 0x0 | ||
35 | |||
36 | /* OMX Component Version */ | ||
37 | #define OMX_H264VE_COMP_VERSION_MAJOR 1 | ||
38 | |||
39 | #define OMX_H264VE_COMP_VERSION_MINOR 1 | ||
40 | |||
41 | #define OMX_H264VE_COMP_VERSION_REVISION 0 | ||
42 | |||
43 | #define OMX_H264VE_COMP_VERSION_STEP 0 | ||
44 | |||
45 | /* OMX Component port numbers */ | ||
46 | #define OMX_H264VE_NUM_PORTS (2) | ||
47 | |||
48 | #define OMX_H264VE_DEFAULT_START_PORT_NUM (0) | ||
49 | |||
50 | #define OMX_H264VE_INPUT_PORT (0) | ||
51 | |||
52 | #define OMX_H264VE_OUTPUT_PORT (1) | ||
53 | |||
54 | /* OMX Component thread related */ | ||
55 | #define OMX_H264VE_DEFAULT_TASKPRIORITY (10) | ||
56 | |||
57 | #define OMX_H264VE_STACKSIZE (1024 * 100) | ||
58 | |||
59 | /* OMX Component and Encoder Name */ | ||
60 | #define OMX_H264VE_COMP_NAME "OMX.TI.DUCATI1.VIDEO.H264E" | ||
61 | |||
62 | #define OMX_H264V_ENCODER_NAME "ivahd_h264enc" | ||
63 | |||
64 | /* Default Interframe intervals */ | ||
65 | #define OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL (3) | ||
66 | |||
67 | #define OMX_H264VE_BASELINE_INTERFRAME_INTERVAL (1) | ||
68 | |||
69 | /* OMX Component Buffer defaults */ | ||
70 | #define OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT (2) | ||
71 | |||
72 | #define OMX_H264VE_DEFAULT_OUTPUT_BUFFER_COUNT (OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT + 2) | ||
73 | |||
74 | #define OMX_H264VE_MIN_INPUT_BUFFER_COUNT (OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL) | ||
75 | |||
76 | #define OMX_H264VE_DEFAULT_INPUT_BUFFER_COUNT (OMX_H264VE_MIN_INPUT_BUFFER_COUNT) | ||
77 | |||
78 | /* Default Framerate */ | ||
79 | #define OMX_H264VE_DEFAULT_FRAME_RATE (15) | ||
80 | |||
81 | /* Default Intra Frame Interval */ | ||
82 | #define OMX_H264VE_DEFAULT_INTRAFRAME_INTERVAL (OMX_H264VE_DEFAULT_FRAME_RATE) | ||
83 | |||
84 | /* Default MaxIntra Frame Interval */ | ||
85 | #define OMX_H264VE_DEFAULT_MAXINTRAFRAME_INTERVAL (0x7FFFFFFF) | ||
86 | |||
87 | /* Minimum Bitrate */ | ||
88 | #define OMX_H264VE_MIN_BITRATE (16385) //( > 16*1024) | ||
89 | |||
90 | /* Default Bitrate */ | ||
91 | #define OMX_H264VE_DEFAULT_BITRATE (64000) | ||
92 | |||
93 | /*Default Frame Width */ | ||
94 | #define OMX_H264VE_DEFAULT_FRAME_WIDTH (176) | ||
95 | |||
96 | /* Default Frame Height */ | ||
97 | #define OMX_H264VE_DEFAULT_FRAME_HEIGHT (144) | ||
98 | |||
99 | /* Max Frame width */ | ||
100 | #define OMX_H264VE_MAX_FRAME_WIDTH (1920) | ||
101 | |||
102 | /* Max Frame Height */ | ||
103 | #define OMX_H264VE_MAX_FRAME_HEIGHT (1088) | ||
104 | |||
105 | /* Max Inter Frame Interval */ | ||
106 | #define OMX_H264VE_MAX_INTER_FRAME_INTERVAL (OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL) | ||
107 | |||
108 | /* deafult input buffer size */ | ||
109 | #define OMX_H264VE_DEFAULT_INPUT_BUFFER_SIZE (OMX_H264VE_DEFAULT_FRAME_WIDTH * OMX_H264VE_DEFAULT_FRAME_HEIGHT * 3 / 2) | ||
110 | |||
111 | /* deafult output buffer size */ | ||
112 | #define OMX_H264VE_DEFAULT_OUTPUT_BUFFER_SIZE (OMX_H264VE_DEFAULT_FRAME_WIDTH * OMX_H264VE_DEFAULT_FRAME_HEIGHT * 3 / 2) | ||
113 | /* Assuming encoded frame size will not exceed this size*/ | ||
114 | |||
115 | /* deafult Aspect Ratio Height */ | ||
116 | #define OMX_H264VE_DEFAULT_ASPECT_RATIO_HEIGHT (1) | ||
117 | |||
118 | /* deafult Aspect Ratio Width */ | ||
119 | #define OMX_H264VE_DEFAULT_ASPECT_RATIO_WIDTH (1) | ||
120 | |||
121 | /* default Qp Settings for I frame */ | ||
122 | #define OMX_H264VE_DEFAULT_QP_IFRAME (28) | ||
123 | #define OMX_H264VE_DEFAULT_QPMAX_IFRAME (36) | ||
124 | #define OMX_H264VE_DEFAULT_QPMIN_IFRAME (10) | ||
125 | |||
126 | /* default Qp Settings for P frame */ | ||
127 | #define OMX_H264VE_DEFAULT_QP_PFRAME (28) | ||
128 | #define OMX_H264VE_DEFAULT_QPMAX_PFRAME (40) | ||
129 | #define OMX_H264VE_DEFAULT_QPMIN_PFRAME (10) | ||
130 | |||
131 | /* default Qp Settings for B frame */ | ||
132 | #define OMX_H264VE_DEFAULT_QPOFFSET_BFRAME (4) | ||
133 | #define OMX_H264VE_DEFAULT_QPMAX_BFRAME (44) | ||
134 | #define OMX_H264VE_DEFAULT_QPMIN_BFRAME (10) | ||
135 | |||
136 | /* default Qp Settings for Chroma */ | ||
137 | #define OMX_H264VE_DEFAULT_QPOFFSET_CHROMA (0) | ||
138 | |||
139 | /* default Search Range for P */ | ||
140 | #define OMX_H264VE_DEFAULT_HORSEARCH_PFRAME (144) | ||
141 | #define OMX_H264VE_DEFAULT_VERSEARCH_PFRAME (32) | ||
142 | |||
143 | /* default Search Range for B */ | ||
144 | #define OMX_H264VE_DEFAULT_HORSEARCH_BFRAME (144) | ||
145 | #define OMX_H264VE_DEFAULT_VERSEARCH_BFRAME (16) | ||
146 | |||
147 | /* default Min and Max Pic Size Ratio. Enables Codec to to chose ratio */ | ||
148 | #define OMX_H264VE_DEFAULT_MINPICSIZERATIO (0) | ||
149 | #define OMX_H264VE_DEFAULT_MAXPICSIZERATIOI (20) // codec default is 640 in Q5 format | ||
150 | #define OMX_H264VE_DEFAULT_MAXPICSIZERATIOP (0) | ||
151 | #define OMX_H264VE_DEFAULT_MAXPICSIZERATIOB (0) | ||
152 | |||
153 | /* the header size SPS+PPS */ | ||
154 | #define SPS_PPS_HEADER_DATA_SIZE 0x100 | ||
155 | |||
156 | /* The PARAMS_UPDATE_STATUS enum represents the status of the setconfig call. | ||
157 | * With respect to a process call there are 3 possibilities: | ||
158 | * 1. No params have been changed(no setconfig call has occured) | ||
159 | * 2. Setconfig call has occured but the modified params have not been updated to the codec | ||
160 | * It has been updated only at Ducati | ||
161 | * 3. Setconfig call has occured and the modified params have been updated to the codec | ||
162 | */ | ||
163 | typedef enum PARAMS_UPDATE_STATUS { | ||
164 | NO_PARAM_CHANGE = 0, | ||
165 | PARAMS_UPDATED_AT_OMX = 1, | ||
166 | PARAMS_UPDATED_AT_CODEC = 2, | ||
167 | PARAMS_UPDATE_STATUS_MAX = 0x7FFFFFFF | ||
168 | } PARAMS_UPDATE_STATUS; | ||
169 | |||
170 | /* inline functions */ | ||
171 | #define GET_OMX_RC_ALG(_pCompPvtStruct_, _pParamStruct_, _e_) \ | ||
172 | if((_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC) && (_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip == OMX_FALSE)) { \ | ||
173 | ((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate = OMX_Video_ControlRateVariable;\ | ||
174 | _e_=OMX_ErrorNone;\ | ||
175 | } else if((_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY) && (_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip == OMX_FALSE)) { \ | ||
176 | ((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate = OMX_Video_ControlRateConstant;\ | ||
177 | _e_=OMX_ErrorNone;\ | ||
178 | } | ||
179 | |||
180 | #define SET_H264CODEC_RC_ALG(_pParamStruct_, _pCompPvtStruct_, _e_) \ | ||
181 | if(((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate == OMX_Video_ControlRateVariable ) { \ | ||
182 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_PRC;\ | ||
183 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\ | ||
184 | _e_=OMX_ErrorNone;\ | ||
185 | } else if(((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate == OMX_Video_ControlRateConstant ) { \ | ||
186 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_PRC_LOW_DELAY;\ | ||
187 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\ | ||
188 | _e_=OMX_ErrorNone;\ | ||
189 | } else {\ | ||
190 | _e_=OMX_ErrorUnsupportedSetting;\ | ||
191 | } | ||
192 | |||
193 | #define GET_OMX_AVC_PARAMS(_pCompPvtStruct_, _pParamStruct_) \ | ||
194 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nSliceHeaderSpacing = 0; /* present code doesn't use this value: set to 0 */\ | ||
195 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nPFrames = (_pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval);\ | ||
196 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames = ((_pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval) - 1);\ | ||
197 | ((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 */\ | ||
198 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nRefFrames = 1; /* According to the Spec BUT present code doesn't use this value */\ | ||
199 | ((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 */\ | ||
200 | ((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 */\ | ||
201 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableUEP = OMX_FALSE; /* present code doesn't use this value */\ | ||
202 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableFMO = (((_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset) == IH264_FMOCODING_NONE) ? OMX_FALSE : OMX_TRUE);\ | ||
203 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableASO = OMX_FALSE; /* present code doesn't use this value */\ | ||
204 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableRS = OMX_FALSE; /* present code doesn't use this value */\ | ||
205 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nAllowedPictureTypes = 3; /* present code doesn't use this value */\ | ||
206 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bFrameMBsOnly = OMX_TRUE; /* present code doesn't use this value */\ | ||
207 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bMBAFF = ((_pCompPvtStruct_->pVidEncStaticParams->interlaceCodingType == IH264_INTERLACE_MBAFF) ? OMX_TRUE : OMX_FALSE); /* present code doesn't use this value */\ | ||
208 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEntropyCodingCABAC = ((_pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode == IH264_ENTROPYCODING_CABAC) ? OMX_TRUE : OMX_FALSE);\ | ||
209 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bWeightedPPrediction = OMX_FALSE; /* present code doesn't use this value */\ | ||
210 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nWeightedBipredicitonMode = OMX_FALSE; /* present code doesn't use this value */\ | ||
211 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred = (((_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable) == 0) ? OMX_FALSE : OMX_TRUE);\ | ||
212 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bDirect8x8Inference = OMX_FALSE; /* present code doesn't use this value */\ | ||
213 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bDirectSpatialTemporal = OMX_FALSE; /* present code doesn't use this value */\ | ||
214 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nCabacInitIdc = 0; /* present code doesn't use this value */ | ||
215 | |||
216 | |||
217 | #define SET_H264CODEC_PARAMS_FROM_AVC(_pParamStruct_, _pCompPvtStruct_) \ | ||
218 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nPFrames;\ | ||
219 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = (((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames + 1);\ | ||
220 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = (((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames + 1);\ | ||
221 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableFMO;\ | ||
222 | _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = ((((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEntropyCodingCABAC) ? IH264_ENTROPYCODING_CABAC : IH264_ENTROPYCODING_CAVLC);\ | ||
223 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred;\ | ||
224 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred;\ | ||
225 | if( _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable ) {\ | ||
226 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\ | ||
227 | } | ||
228 | |||
229 | #define GET_OMX_AVC_PROFILE(_pCompPvtStruct_, _pParamStruct_, _e_)\ | ||
230 | switch( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile ) {\ | ||
231 | case IH264_BASELINE_PROFILE :\ | ||
232 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileBaseline;\ | ||
233 | break;\ | ||
234 | case IH264_MAIN_PROFILE :\ | ||
235 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileMain;\ | ||
236 | break;\ | ||
237 | case IH264_HIGH_PROFILE :\ | ||
238 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh;\ | ||
239 | break;\ | ||
240 | case IH264_EXTENDED_PROFILE :\ | ||
241 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileExtended;\ | ||
242 | break;\ | ||
243 | case IH264_HIGH10_PROFILE :\ | ||
244 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh10;\ | ||
245 | break;\ | ||
246 | case IH264_HIGH422_PROFILE :\ | ||
247 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh422;\ | ||
248 | break;\ | ||
249 | default :\ | ||
250 | _e_= OMX_ErrorNoMore;\ | ||
251 | break;\ | ||
252 | } | ||
253 | |||
254 | #define SET_H264CODEC_PROFILE(_pParamStruct_, _pCompPvtStruct_, _e_) \ | ||
255 | switch(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile ) {\ | ||
256 | case OMX_VIDEO_AVCProfileBaseline :\ | ||
257 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile = IH264_BASELINE_PROFILE;\ | ||
258 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ | ||
259 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ | ||
260 | _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_SET_CONSTRAINT_SET1_FLAG;\ | ||
261 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\ | ||
262 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\ | ||
263 | _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CAVLC;\ | ||
264 | _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\ | ||
265 | break;\ | ||
266 | case OMX_VIDEO_AVCProfileMain :\ | ||
267 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile =IH264_MAIN_PROFILE;\ | ||
268 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ | ||
269 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ | ||
270 | _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\ | ||
271 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ | ||
272 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ | ||
273 | _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\ | ||
274 | _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\ | ||
275 | break;\ | ||
276 | case OMX_VIDEO_AVCProfileHigh :\ | ||
277 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile=IH264_HIGH_PROFILE;\ | ||
278 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\ | ||
279 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\ | ||
280 | _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\ | ||
281 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ | ||
282 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ | ||
283 | _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\ | ||
284 | _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_ADAPTIVE;\ | ||
285 | break;\ | ||
286 | case OMX_VIDEO_AVCProfileExtended :\ | ||
287 | case OMX_VIDEO_AVCProfileHigh10 :\ | ||
288 | case OMX_VIDEO_AVCProfileHigh422 :\ | ||
289 | default :\ | ||
290 | _e_= OMX_ErrorUnsupportedSetting;\ | ||
291 | break;\ | ||
292 | } | ||
293 | |||
294 | |||
295 | #define GET_OMX_AVC_LEVEL(_pCompPvtStruct_, _pParamStruct_, _e_)\ | ||
296 | switch( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level ) {\ | ||
297 | case IH264_LEVEL_10 :\ | ||
298 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel1;\ | ||
299 | break;\ | ||
300 | case IH264_LEVEL_1b :\ | ||
301 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel1b;\ | ||
302 | break;\ | ||
303 | case IH264_LEVEL_11 :\ | ||
304 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel11;\ | ||
305 | break;\ | ||
306 | case IH264_LEVEL_12 :\ | ||
307 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel12;\ | ||
308 | break;\ | ||
309 | case IH264_LEVEL_13 :\ | ||
310 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel13;\ | ||
311 | break;\ | ||
312 | case IH264_LEVEL_20 :\ | ||
313 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel2;\ | ||
314 | break;\ | ||
315 | case IH264_LEVEL_21 :\ | ||
316 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel21;\ | ||
317 | break;\ | ||
318 | case IH264_LEVEL_22 :\ | ||
319 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel22;\ | ||
320 | break;\ | ||
321 | case IH264_LEVEL_30 :\ | ||
322 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel3;\ | ||
323 | break;\ | ||
324 | case IH264_LEVEL_31 :\ | ||
325 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel31;\ | ||
326 | break;\ | ||
327 | case IH264_LEVEL_32 :\ | ||
328 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel32;\ | ||
329 | break;\ | ||
330 | case IH264_LEVEL_40 :\ | ||
331 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel4;\ | ||
332 | break;\ | ||
333 | case IH264_LEVEL_41 :\ | ||
334 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel41;\ | ||
335 | break;\ | ||
336 | case IH264_LEVEL_42 :\ | ||
337 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel42;\ | ||
338 | break;\ | ||
339 | case IH264_LEVEL_50 :\ | ||
340 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel5;\ | ||
341 | break;\ | ||
342 | case IH264_LEVEL_51 :\ | ||
343 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel51;\ | ||
344 | break;\ | ||
345 | default :\ | ||
346 | _e_= OMX_ErrorNoMore;\ | ||
347 | break;\ | ||
348 | } | ||
349 | |||
350 | #define SET_H264CODEC_LEVEL(_pParamStruct_, _pCompPvtStruct_, _e_)\ | ||
351 | switch(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel ) {\ | ||
352 | case OMX_VIDEO_AVCLevel1 :\ | ||
353 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_10;\ | ||
354 | break;\ | ||
355 | case OMX_VIDEO_AVCLevel1b :\ | ||
356 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_1b;\ | ||
357 | if (((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile == OMX_VIDEO_AVCProfileBaseline) {\ | ||
358 | _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_SET_CONSTRAINT_SET1b_FLAG;\ | ||
359 | }\ | ||
360 | break;\ | ||
361 | case OMX_VIDEO_AVCLevel11 :\ | ||
362 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_11;\ | ||
363 | break;\ | ||
364 | case OMX_VIDEO_AVCLevel12 :\ | ||
365 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_12;\ | ||
366 | break;\ | ||
367 | case OMX_VIDEO_AVCLevel13 :\ | ||
368 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_13;\ | ||
369 | break;\ | ||
370 | case OMX_VIDEO_AVCLevel2 :\ | ||
371 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_20;\ | ||
372 | break;\ | ||
373 | case OMX_VIDEO_AVCLevel21 :\ | ||
374 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_21;\ | ||
375 | break;\ | ||
376 | case OMX_VIDEO_AVCLevel22 :\ | ||
377 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_22;\ | ||
378 | break;\ | ||
379 | case OMX_VIDEO_AVCLevel3 :\ | ||
380 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_30;\ | ||
381 | break;\ | ||
382 | case OMX_VIDEO_AVCLevel31 :\ | ||
383 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_31;\ | ||
384 | break;\ | ||
385 | case OMX_VIDEO_AVCLevel32 :\ | ||
386 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_32;\ | ||
387 | break;\ | ||
388 | case OMX_VIDEO_AVCLevel4 :\ | ||
389 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_40;\ | ||
390 | break;\ | ||
391 | case OMX_VIDEO_AVCLevel41 :\ | ||
392 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_41;\ | ||
393 | break;\ | ||
394 | case OMX_VIDEO_AVCLevel42 :\ | ||
395 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_42;\ | ||
396 | break;\ | ||
397 | case OMX_VIDEO_AVCLevel5 :\ | ||
398 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_50;\ | ||
399 | break;\ | ||
400 | case OMX_VIDEO_AVCLevel51 :\ | ||
401 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_51;\ | ||
402 | break;\ | ||
403 | default :\ | ||
404 | _e_= OMX_ErrorUnsupportedSetting;\ | ||
405 | break;\ | ||
406 | } | ||
407 | |||
408 | #define GET_OMX_AVC_LFMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\ | ||
409 | if((_pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_NONE) || (_pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_DEFAULT)) {\ | ||
410 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;\ | ||
411 | } else if( _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_ALL_EDGES ) {\ | ||
412 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterDisable;\ | ||
413 | } else if( _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_SLICE_EDGES ) {\ | ||
414 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterDisableSliceBoundary;\ | ||
415 | } else {\ | ||
416 | ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterMax;\ | ||
417 | _e_= OMX_ErrorNoMore;\ | ||
418 | } | ||
419 | |||
420 | |||
421 | #define SET_H264CODEC_LFMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\ | ||
422 | if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterEnable ) {\ | ||
423 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_NONE;\ | ||
424 | } else if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterDisable ) {\ | ||
425 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_ALL_EDGES;\ | ||
426 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = 1;\ | ||
427 | } else if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterDisableSliceBoundary ) {\ | ||
428 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_SLICE_EDGES;\ | ||
429 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = 1;\ | ||
430 | } else {\ | ||
431 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_MAX;\ | ||
432 | _e_= OMX_ErrorUnsupportedSetting;\ | ||
433 | } | ||
434 | |||
435 | #define GET_OMX_FMO_SLIGRPMAPTYPE(_pCompPvtStruct_, _pParamStruct_, _e_)\ | ||
436 | if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_INTERLEAVED_SLICE_GRP ) {\ | ||
437 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 0;\ | ||
438 | } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_DISPERSED_SLICE_GRP ) {\ | ||
439 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 1;\ | ||
440 | } else if((_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_SLICE_GRP_MAP_DEFAULT) || (_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_RASTER_SCAN_SLICE_GRP)) {\ | ||
441 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 2;\ | ||
442 | } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP ) {\ | ||
443 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 3;\ | ||
444 | } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_BOX_OUT_SLICE_GRP ) {\ | ||
445 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 4;\ | ||
446 | } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_WIPE_SLICE_GRP ) {\ | ||
447 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 5;\ | ||
448 | } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_EXPLICIT_SLICE_GRP ) {\ | ||
449 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 6;\ | ||
450 | } else {\ | ||
451 | _e_= OMX_ErrorNoMore;\ | ||
452 | } | ||
453 | |||
454 | #define SET_H264CODEC_FMO_SLIGRPMAPTYPE(_pParamStruct_, _pCompPvtStruct_, _e_)\ | ||
455 | if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 0 ) {\ | ||
456 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_INTERLEAVED_SLICE_GRP;\ | ||
457 | } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 1 ) {\ | ||
458 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_DISPERSED_SLICE_GRP;\ | ||
459 | } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 2 ) {\ | ||
460 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_RASTER_SCAN_SLICE_GRP;\ | ||
461 | } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 3 ) {\ | ||
462 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP;\ | ||
463 | } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 4 ) {\ | ||
464 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_BOX_OUT_SLICE_GRP;\ | ||
465 | } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 5 ) {\ | ||
466 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_WIPE_SLICE_GRP;\ | ||
467 | } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 6 ) {\ | ||
468 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_EXPLICIT_SLICE_GRP;\ | ||
469 | } else {\ | ||
470 | _e_= OMX_ErrorUnsupportedSetting;\ | ||
471 | } | ||
472 | |||
473 | #define GET_OMX_FMO_SLICEMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\ | ||
474 | if((_pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_NONE) || (_pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT)) {\ | ||
475 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCDefault;\ | ||
476 | } else if( _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_MBUNIT ) {\ | ||
477 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCMBSlice;\ | ||
478 | } else if( _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) {\ | ||
479 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCByteSlice;\ | ||
480 | } else {\ | ||
481 | _e_= OMX_ErrorNoMore;\ | ||
482 | } | ||
483 | |||
484 | #define SET_H264CODEC_SLICEMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\ | ||
485 | if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCDefault ) {\ | ||
486 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\ | ||
487 | } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCMBSlice ) {\ | ||
488 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_MBUNIT;\ | ||
489 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset=1;\ | ||
490 | } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCByteSlice ) {\ | ||
491 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES;\ | ||
492 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = 1;\ | ||
493 | } else {\ | ||
494 | _e_= OMX_ErrorUnsupportedSetting;\ | ||
495 | } | ||
496 | |||
497 | #define GET_OMX_INTRAREFRESHMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\ | ||
498 | if((_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_NONE) || (_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_DEFAULT) || (_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_MAX)) {\ | ||
499 | ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode = OMX_VIDEO_IntraRefreshMax;\ | ||
500 | ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirMBs = 0;\ | ||
501 | ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirRef = 0;\ | ||
502 | ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nCirMBs = 0;\ | ||
503 | } else if( _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_CYCLIC_MBS ) {\ | ||
504 | ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode = OMX_VIDEO_IntraRefreshAdaptive;\ | ||
505 | ((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);\ | ||
506 | ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirRef = 0;\ | ||
507 | ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nCirMBs = 0;\ | ||
508 | } else {\ | ||
509 | _e_= OMX_ErrorNoMore;\ | ||
510 | } | ||
511 | |||
512 | #define SET_H264CODEC_INTRAREFRESHMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\ | ||
513 | if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode == OMX_VIDEO_IntraRefreshAdaptive ) {\ | ||
514 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\ | ||
515 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_CYCLIC_MBS;\ | ||
516 | _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);\ | ||
517 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_CYCLIC_MBS;\ | ||
518 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate;\ | ||
519 | } else if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode == OMX_VIDEO_IntraRefreshMax ) {\ | ||
520 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\ | ||
521 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_NONE;\ | ||
522 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate = 0;\ | ||
523 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_NONE;\ | ||
524 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = 0;\ | ||
525 | } else {\ | ||
526 | _e_= OMX_ErrorUnsupportedSetting;\ | ||
527 | } | ||
528 | |||
529 | |||
530 | /*Set the Codec Chroma Format*/ | ||
531 | #define GET_OMX_COLORFORMAT(_pCompPvtStruct_, _e_)\ | ||
532 | if((_pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat == XDM_YUV_420SP)) {\ | ||
533 | _pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;\ | ||
534 | } else {\ | ||
535 | _e_ = OMX_ErrorNoMore; } | ||
536 | |||
537 | #define SET_H264CODEC_CHROMAFORMAT(_pPortdefStruct_, _pCompPvtStruct_, _e_)\ | ||
538 | if((_pPortdefStruct_->format.video.eColorFormat) == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar ||\ | ||
539 | (_pPortdefStruct_->format.video.eColorFormat) == OMX_COLOR_FormatAndroidOpaque ||\ | ||
540 | (_pPortdefStruct_->format.video.eColorFormat) == OMX_COLOR_FormatYUV420Flexible) {\ | ||
541 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat = XDM_YUV_420SP;\ | ||
542 | } else {\ | ||
543 | _e_= OMX_ErrorUnsupportedSetting; } | ||
544 | |||
545 | |||
546 | #define SET_H264CODEC_DEFAULT_IVIDENC2_PARAMS(_pCompPvtStruct_, _i_)\ | ||
547 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.size = sizeof(IH264ENC_Params);\ | ||
548 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.encodingPreset = XDM_USER_DEFINED;\ | ||
549 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.rateControlPreset = IVIDEO_USER_DEFINED;\ | ||
550 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT;\ | ||
551 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\ | ||
552 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.dataEndianness = XDM_BYTE;\ | ||
553 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxBitRate = -1;\ | ||
554 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.minBitRate = 0;\ | ||
555 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat = XDM_YUV_420SP;\ | ||
556 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType = IVIDEO_PROGRESSIVE;\ | ||
557 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.operatingMode = IVIDEO_ENCODE_ONLY;\ | ||
558 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile = IH264_HIGH_PROFILE;\ | ||
559 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_42;\ | ||
560 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval =OMX_H264VE_MAX_INTER_FRAME_INTERVAL;\ | ||
561 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\ | ||
562 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\ | ||
563 | }\ | ||
564 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputDataMode = IVIDEO_ENTIREFRAME;\ | ||
565 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.outputDataMode = IVIDEO_ENTIREFRAME;\ | ||
566 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.numInputDataUnits = 1;\ | ||
567 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.numOutputDataUnits = 1;\ | ||
568 | for( _i_ = 0; _i_ < IVIDEO_MAX_NUM_METADATA_PLANES; _i_++ ) {\ | ||
569 | _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.metadataType[_i_] = IVIDEO_METADATAPLANE_NONE;\ | ||
570 | } | ||
571 | |||
572 | |||
573 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_RATECONTROLPARAMS(_pCompPvtStruct_)\ | ||
574 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rateControlParamsPreset=IH264_RATECONTROLPARAMS_DEFAULT;\ | ||
575 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\ | ||
576 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ | ||
577 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ | ||
578 | }\ | ||
579 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_DEFAULT;\ | ||
580 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpI = OMX_H264VE_DEFAULT_QP_IFRAME;\ | ||
581 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxI = OMX_H264VE_DEFAULT_QPMAX_IFRAME;\ | ||
582 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinI = OMX_H264VE_DEFAULT_QPMIN_IFRAME;\ | ||
583 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpP = OMX_H264VE_DEFAULT_QP_PFRAME;\ | ||
584 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxP = OMX_H264VE_DEFAULT_QPMAX_PFRAME;\ | ||
585 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinP = OMX_H264VE_DEFAULT_QPMIN_PFRAME;\ | ||
586 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpOffsetB = OMX_H264VE_DEFAULT_QPOFFSET_BFRAME;\ | ||
587 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxB = OMX_H264VE_DEFAULT_QPMAX_BFRAME;\ | ||
588 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinB = OMX_H264VE_DEFAULT_QPMIN_BFRAME;\ | ||
589 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\ | ||
590 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.removeExpensiveCoeff = OMX_FALSE;\ | ||
591 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.chromaQPIndexOffset = OMX_H264VE_DEFAULT_QPOFFSET_CHROMA;\ | ||
592 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.IPQualityFactor = IH264_QUALITY_FACTOR_DEFAULT;\ | ||
593 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.HRDBufferSize = OMX_H264VE_DEFAULT_BITRATE;\ | ||
594 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.initialBufferLevel = pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize;\ | ||
595 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioI = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ | ||
596 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioI = OMX_H264VE_DEFAULT_MAXPICSIZERATIOI;\ | ||
597 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioP = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ | ||
598 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioP = OMX_H264VE_DEFAULT_MAXPICSIZERATIOP;\ | ||
599 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioB = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ | ||
600 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioB = OMX_H264VE_DEFAULT_MAXPICSIZERATIOB;\ | ||
601 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enablePRC = 1;\ | ||
602 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enablePartialFrameSkip = 0;\ | ||
603 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.discardSavedBits = 0;\ | ||
604 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reserved = 0;\ | ||
605 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.VBRDuration = 8;\ | ||
606 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.VBRsensitivity = 0;\ | ||
607 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.skipDistributionWindowLength = 5;\ | ||
608 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.numSkipInDistributionWindow = 1;\ | ||
609 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enableHRDComplianceMode = 1;\ | ||
610 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.frameSkipThMulQ5 = 0;\ | ||
611 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.vbvUseLevelThQ5 = 0;\ | ||
612 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[0] = 0;\ | ||
613 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[1] = 0;\ | ||
614 | _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[2] = 0; | ||
615 | |||
616 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTERCODINGPARAMS(_pCompPvtStruct_)\ | ||
617 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset=IH264_INTERCODING_DEFAULT;\ | ||
618 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeHorP = OMX_H264VE_DEFAULT_HORSEARCH_PFRAME;\ | ||
619 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeVerP = OMX_H264VE_DEFAULT_VERSEARCH_PFRAME;\ | ||
620 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeHorB = OMX_H264VE_DEFAULT_HORSEARCH_BFRAME;\ | ||
621 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeVerB = OMX_H264VE_DEFAULT_VERSEARCH_BFRAME;\ | ||
622 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;\ | ||
623 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;\ | ||
624 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_DEFAULT;\ | ||
625 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_DEFAULT;\ | ||
626 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.meAlgoMode = IH264ENC_MOTIONESTMODE_DEFAULT; | ||
627 | |||
628 | |||
629 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTRACODINGPARAMS(_pCompPvtStruct_)\ | ||
630 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_DEFAULT;\ | ||
631 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ | ||
632 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x0FF;\ | ||
633 | } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\ | ||
634 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x0;\ | ||
635 | } else {\ | ||
636 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x1F;\ | ||
637 | }\ | ||
638 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ | ||
639 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x0;\ | ||
640 | } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\ | ||
641 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x0FF;\ | ||
642 | } else {\ | ||
643 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x01F;\ | ||
644 | }\ | ||
645 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra16x16Enable = 0xF;\ | ||
646 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.chromaIntra8x8Enable = 0xF;\ | ||
647 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.chromaComponentEnable = IH264_CHROMA_COMPONENT_DEFAULT;\ | ||
648 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_DEFAULT;\ | ||
649 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate = 0;\ | ||
650 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.gdrOverlapRowsBtwFrames = 0;\ | ||
651 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable = 0;\ | ||
652 | _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingBias = IH264ENC_INTRACODINGBIAS_DEFAULT; | ||
653 | |||
654 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_NALUCONTROLPARAMS(_pCompPvtStruct_)\ | ||
655 | _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_DEFAULT;\ | ||
656 | _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskStartOfSequence= 0x01A0;\ | ||
657 | _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIDRPicture = 0x01A0;\ | ||
658 | _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIntraPicture= 0x0002;\ | ||
659 | _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskNonIntraPicture= 0x0002;\ | ||
660 | _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskEndOfSequence= 0x0C00;\ | ||
661 | |||
662 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SLICECODINGPARAMS(_pCompPvtStruct_)\ | ||
663 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_DEFAULT;\ | ||
664 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\ | ||
665 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceUnitSize = 0;\ | ||
666 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[0] = 0;\ | ||
667 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[1] = 0;\ | ||
668 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[2] = 0;\ | ||
669 | _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.streamFormat = IH264_STREAM_FORMAT_DEFAULT; | ||
670 | |||
671 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_LOOPFILTERPARAMS(_pCompPvtStruct_)\ | ||
672 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = IH264_LOOPFILTER_DEFAULT;\ | ||
673 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_DEFAULT;\ | ||
674 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.filterOffsetA = 0;\ | ||
675 | _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.filterOffsetB = 0; | ||
676 | |||
677 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_FMOCODINGPARAMS(_pCompPvtStruct_)\ | ||
678 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset = IH264_FMOCODING_DEFAULT;\ | ||
679 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.numSliceGroups = 1;\ | ||
680 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_SLICE_GRP_MAP_DEFAULT;\ | ||
681 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeDirectionFlag = IH264ENC_SLICEGROUP_CHANGE_DIRECTION_DEFAULT;\ | ||
682 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeRate = 0;\ | ||
683 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeCycle = 0;\ | ||
684 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupParams[0] = 0;\ | ||
685 | _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupParams[1] = 0; | ||
686 | |||
687 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_VUICODINGPARAMS(_pCompPvtStruct_)\ | ||
688 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.vuiCodingPreset = IH264_VUICODING_DEFAULT;\ | ||
689 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.aspectRatioInfoPresentFlag = 0;\ | ||
690 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.aspectRatioIdc = 0;\ | ||
691 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoSignalTypePresentFlag = 0;\ | ||
692 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoFormat = IH264ENC_VIDEOFORMAT_NTSC;\ | ||
693 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoFullRangeFlag = 0;\ | ||
694 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.timingInfoPresentFlag = 0;\ | ||
695 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.hrdParamsPresentFlag = XDAS_FALSE;\ | ||
696 | _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.numUnitsInTicks = 1000; | ||
697 | |||
698 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOINFOPARAMS(_pCompPvtStruct_)\ | ||
699 | _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.stereoInfoPreset = IH264_STEREOINFO_DISABLE;\ | ||
700 | _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.topFieldIsLeftViewFlag = 1;\ | ||
701 | _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.viewSelfContainedFlag = 0; | ||
702 | |||
703 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOFRAMEPACKINGPARAMS(_pCompPvtStruct_)\ | ||
704 | _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.framePackingPreset = IH264_FRAMEPACK_SEI_DISABLE;\ | ||
705 | _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.framePackingType = IH264_FRAMEPACK_TYPE_DEFAULT;\ | ||
706 | _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame0PositionX = 0;\ | ||
707 | _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame0PositionY = 0;\ | ||
708 | _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame1PositionX = 0;\ | ||
709 | _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame1PositionY = 0;\ | ||
710 | _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.reservedByte = 0; | ||
711 | |||
712 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SVCCODINGPARAMS(_pCompPvtStruct_)\ | ||
713 | _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.svcExtensionFlag = IH264_SVC_EXTENSION_FLAG_DISABLE;\ | ||
714 | _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.dependencyID = 0;\ | ||
715 | _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.qualityID = 0;\ | ||
716 | _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.enhancementProfileID = 0;\ | ||
717 | _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.layerIndex = 0;\ | ||
718 | _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.refLayerDQId = 0; | ||
719 | |||
720 | #define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_EXTENDEDPARAMS(_pCompPvtStruct_)\ | ||
721 | _pCompPvtStruct_->pVidEncStaticParams->interlaceCodingType = IH264_INTERLACE_FIELDONLY_ARF;\ | ||
722 | _pCompPvtStruct_->pVidEncStaticParams->bottomFieldIntra = OMX_FALSE;\ | ||
723 | _pCompPvtStruct_->pVidEncStaticParams->gopStructure = IH264ENC_GOPSTRUCTURE_DEFAULT;\ | ||
724 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\ | ||
725 | _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CAVLC;\ | ||
726 | } else {\ | ||
727 | _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\ | ||
728 | }\ | ||
729 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_HIGH_PROFILE ) {\ | ||
730 | _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_ADAPTIVE;\ | ||
731 | } else {\ | ||
732 | _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\ | ||
733 | }\ | ||
734 | _pCompPvtStruct_->pVidEncStaticParams->log2MaxFNumMinus4 = 10;\ | ||
735 | _pCompPvtStruct_->pVidEncStaticParams->picOrderCountType = IH264_POC_TYPE_DEFAULT;\ | ||
736 | _pCompPvtStruct_->pVidEncStaticParams->maxIntraFrameInterval = OMX_H264VE_DEFAULT_MAXINTRAFRAME_INTERVAL;\ | ||
737 | _pCompPvtStruct_->pVidEncStaticParams->enableWatermark = 0;\ | ||
738 | _pCompPvtStruct_->pVidEncStaticParams->IDRFrameInterval = 0;\ | ||
739 | _pCompPvtStruct_->pVidEncStaticParams->pConstantMemory = NULL;\ | ||
740 | _pCompPvtStruct_->pVidEncStaticParams->debugTraceLevel = 0;\ | ||
741 | _pCompPvtStruct_->pVidEncStaticParams->lastNFramesToLog = 0;\ | ||
742 | _pCompPvtStruct_->pVidEncStaticParams->enableAnalyticinfo = 0;\ | ||
743 | _pCompPvtStruct_->pVidEncStaticParams->enableGMVSei = 0;\ | ||
744 | _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\ | ||
745 | _pCompPvtStruct_->pVidEncStaticParams->enableRCDO = 0;\ | ||
746 | _pCompPvtStruct_->pVidEncStaticParams->enableLongTermRefFrame = IH264ENC_LTRP_NONE;\ | ||
747 | _pCompPvtStruct_->pVidEncStaticParams->LTRPPeriod = 0;\ | ||
748 | _pCompPvtStruct_->pVidEncStaticParams->numTemporalLayer = IH264_TEMPORAL_LAYERS_1;\ | ||
749 | _pCompPvtStruct_->pVidEncStaticParams->referencePicMarking = IH264_LONG_TERM_PICTURE;\ | ||
750 | _pCompPvtStruct_->pVidEncStaticParams->reservedParams[0] = 0;\ | ||
751 | _pCompPvtStruct_->pVidEncStaticParams->reservedParams[1] = 0;\ | ||
752 | _pCompPvtStruct_->pVidEncStaticParams->reservedParams[2] = 0; | ||
753 | |||
754 | #define OVERWRITE_H264CODEC_DEFAULT_STATIC_PARAMS(_pCompPvtStruct_)\ | ||
755 | _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_USERDEFINED;\ | ||
756 | _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIDRPicture = 0x0020;\ | ||
757 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset= IH264_INTERCODING_USERDEFINED;\ | ||
758 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_MILD;\ | ||
759 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\ | ||
760 | _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_SET_CONSTRAINT_SET1_FLAG;\ | ||
761 | } | ||
762 | |||
763 | #define ENABLE_4MV(_pCompPvtStruct_)\ | ||
764 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset = IH264_INTERCODING_USERDEFINED;\ | ||
765 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8;\ | ||
766 | _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8;\ | ||
767 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8;\ | ||
768 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8; | ||
769 | |||
770 | #define SET_H264CODEC_DEFAULT_IVIDENC2_DYNAMICPARAMS(_pCompPvtStruct_)\ | ||
771 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.size = sizeof(IH264ENC_DynamicParams);\ | ||
772 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.inputHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT;\ | ||
773 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.inputWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\ | ||
774 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.refFrameRate = (OMX_H264VE_DEFAULT_FRAME_RATE) * 1000;\ | ||
775 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = (OMX_H264VE_DEFAULT_FRAME_RATE) * 1000;\ | ||
776 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_DEFAULT_BITRATE;\ | ||
777 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval = OMX_H264VE_DEFAULT_INTRAFRAME_INTERVAL;\ | ||
778 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;\ | ||
779 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.ignoreOutbufSizeFlag = XDAS_TRUE;\ | ||
780 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.captureWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\ | ||
781 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_NA_FRAME;\ | ||
782 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\ | ||
783 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\ | ||
784 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\ | ||
785 | }\ | ||
786 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy = IVIDENC2_MOTIONVECTOR_QUARTERPEL;\ | ||
787 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.sampleAspectRatioHeight = OMX_H264VE_DEFAULT_ASPECT_RATIO_HEIGHT;\ | ||
788 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.sampleAspectRatioWidth = OMX_H264VE_DEFAULT_ASPECT_RATIO_WIDTH;\ | ||
789 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.putDataFxn = NULL;\ | ||
790 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.putDataHandle = 0;\ | ||
791 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getDataFxn = NULL;\ | ||
792 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getDataHandle = 0;\ | ||
793 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getBufferFxn = NULL;\ | ||
794 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getBufferHandle = NULL;\ | ||
795 | _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.lateAcquireArg = -1; | ||
796 | |||
797 | |||
798 | #define SET_H264CODEC_DEFAULT_DYNAMIC_RATECONTROLPARAMS(_pCompPvtStruct_)\ | ||
799 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_DEFAULT;\ | ||
800 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\ | ||
801 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ | ||
802 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\ | ||
803 | }\ | ||
804 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.rcAlgo = IH264_RATECONTROL_DEFAULT;\ | ||
805 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpI = OMX_H264VE_DEFAULT_QP_IFRAME;\ | ||
806 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxI = OMX_H264VE_DEFAULT_QPMAX_IFRAME;\ | ||
807 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinI = OMX_H264VE_DEFAULT_QPMIN_IFRAME;\ | ||
808 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpP = OMX_H264VE_DEFAULT_QP_PFRAME;\ | ||
809 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxP = OMX_H264VE_DEFAULT_QPMAX_PFRAME;\ | ||
810 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinP = OMX_H264VE_DEFAULT_QPMIN_PFRAME;\ | ||
811 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpOffsetB = OMX_H264VE_DEFAULT_QPOFFSET_BFRAME;\ | ||
812 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxB = OMX_H264VE_DEFAULT_QPMAX_BFRAME;\ | ||
813 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinB = OMX_H264VE_DEFAULT_QPMIN_BFRAME;\ | ||
814 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.allowFrameSkip = OMX_FALSE;\ | ||
815 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.removeExpensiveCoeff = OMX_FALSE;\ | ||
816 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.chromaQPIndexOffset = OMX_H264VE_DEFAULT_QPOFFSET_CHROMA;\ | ||
817 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.IPQualityFactor = IH264_QUALITY_FACTOR_DEFAULT;\ | ||
818 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.HRDBufferSize = OMX_H264VE_DEFAULT_BITRATE;\ | ||
819 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.initialBufferLevel = pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize;\ | ||
820 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioI = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ | ||
821 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioI = OMX_H264VE_DEFAULT_MAXPICSIZERATIOI;\ | ||
822 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioP = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ | ||
823 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioP = OMX_H264VE_DEFAULT_MAXPICSIZERATIOP;\ | ||
824 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioB = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\ | ||
825 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioB = OMX_H264VE_DEFAULT_MAXPICSIZERATIOB;\ | ||
826 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enablePRC = 1;\ | ||
827 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enablePartialFrameSkip = 0;\ | ||
828 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.discardSavedBits = 0;\ | ||
829 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reserved = 0;\ | ||
830 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.VBRDuration = 8;\ | ||
831 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.VBRsensitivity = 0;\ | ||
832 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.skipDistributionWindowLength = 5;\ | ||
833 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.numSkipInDistributionWindow = 1;\ | ||
834 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enableHRDComplianceMode = 1;\ | ||
835 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.frameSkipThMulQ5 = 0;\ | ||
836 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.vbvUseLevelThQ5 = 0;\ | ||
837 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[0] = 0;\ | ||
838 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[1] = 0;\ | ||
839 | _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[2] = 0; | ||
840 | |||
841 | |||
842 | #define SET_H264CODEC_DEFAULT_DYNAMIC_INTERCODINGPARAMS(_pCompPvtStruct_)\ | ||
843 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.interCodingPreset = IH264_INTERCODING_DEFAULT;\ | ||
844 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeHorP = OMX_H264VE_DEFAULT_HORSEARCH_PFRAME;\ | ||
845 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeVerP = OMX_H264VE_DEFAULT_VERSEARCH_PFRAME;\ | ||
846 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeHorB = OMX_H264VE_DEFAULT_HORSEARCH_BFRAME;\ | ||
847 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeVerB = OMX_H264VE_DEFAULT_VERSEARCH_BFRAME;\ | ||
848 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;\ | ||
849 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;\ | ||
850 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_DEFAULT;\ | ||
851 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_DEFAULT;\ | ||
852 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.meAlgoMode = IH264ENC_MOTIONESTMODE_DEFAULT; | ||
853 | |||
854 | |||
855 | #define SET_H264CODEC_DEFAULT_DYNAMIC_INTRACODINGPARAMS(_pCompPvtStruct_)\ | ||
856 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_DEFAULT;\ | ||
857 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ | ||
858 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x0FF;\ | ||
859 | } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\ | ||
860 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x0;\ | ||
861 | } else {\ | ||
862 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x1F;\ | ||
863 | }\ | ||
864 | if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\ | ||
865 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x0;\ | ||
866 | } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\ | ||
867 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x0FF;\ | ||
868 | } else {\ | ||
869 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x01F;\ | ||
870 | }\ | ||
871 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra16x16Enable = 0xF;\ | ||
872 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.chromaIntra8x8Enable = 0xF;\ | ||
873 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.chromaComponentEnable = IH264_CHROMA_COMPONENT_DEFAULT;\ | ||
874 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_DEFAULT;\ | ||
875 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = 0;\ | ||
876 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.gdrOverlapRowsBtwFrames = 0;\ | ||
877 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable = 0;\ | ||
878 | _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraCodingBias = IH264ENC_INTRACODINGBIAS_DEFAULT; | ||
879 | |||
880 | |||
881 | #define SET_H264CODEC_DEFAULT_DYNAMIC_SLICECODINGPARAMS(_pCompPvtStruct_)\ | ||
882 | _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_DEFAULT;\ | ||
883 | _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\ | ||
884 | _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize = 0;\ | ||
885 | _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[0] = 0;\ | ||
886 | _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[1] = 0;\ | ||
887 | _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[2] = 0;\ | ||
888 | _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.streamFormat = IH264_STREAM_FORMAT_DEFAULT; | ||
889 | |||
890 | |||
891 | #define SET_H264CODEC_DEFAULT_DYNAMIC_IH264_EXTENDEDPARAMS(_pCompPvtStruct_)\ | ||
892 | _pCompPvtStruct_->pVidEncDynamicParams->sliceGroupChangeCycle = 0;\ | ||
893 | _pCompPvtStruct_->pVidEncDynamicParams->searchCenter.x = 0x7FFF;\ | ||
894 | _pCompPvtStruct_->pVidEncDynamicParams->searchCenter.y = 0x7FFF;\ | ||
895 | _pCompPvtStruct_->pVidEncDynamicParams->enableStaticMBCount = 0;\ | ||
896 | _pCompPvtStruct_->pVidEncDynamicParams->enableROI = 0;\ | ||
897 | _pCompPvtStruct_->pVidEncDynamicParams->reservedDynParams[0] = 0; | ||
898 | |||
899 | #define OVERWRITE_H264CODEC_DEFAULT_DYNAMIC_PARAMS(_pCompPvtStruct_)\ | ||
900 | _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_MILD; | ||
901 | |||
902 | |||
903 | #define MAP_CODEC_TO_OMX_AVCLEVEL(_InCodecLevel_, _OutOMXLevel_, _nIndex_, _e_)\ | ||
904 | switch( _InCodecLevel_ ) {\ | ||
905 | case IH264_LEVEL_10 :\ | ||
906 | _OutOMXLevel_ = OMX_VIDEO_AVCLevel1;\ | ||
907 | _nIndex_ = 0;\ | ||
908 | break;\ | ||
909 | case IH264_LEVEL_1b :\ | ||
910 | _OutOMXLevel_ = OMX_VIDEO_AVCLevel1b;\ | ||
911 | _nIndex_ = 1;\ | ||
912 | break;\ | ||
913 | case IH264_LEVEL_11 :\ | ||
914 | _OutOMXLevel_ = OMX_VIDEO_AVCLevel11;\ | ||
915 | _nIndex_ = 2;\ | ||
916 | break;\ | ||
917 | case IH264_LEVEL_12 :\ | ||
918 | _OutOMXLevel_= OMX_VIDEO_AVCLevel12;\ | ||
919 | _nIndex_ = 3;\ | ||
920 | break;\ | ||
921 | case IH264_LEVEL_13 :\ | ||
922 | _OutOMXLevel_ = OMX_VIDEO_AVCLevel13;\ | ||
923 | _nIndex_ = 4;\ | ||
924 | break;\ | ||
925 | case IH264_LEVEL_20 :\ | ||
926 | _OutOMXLevel_= OMX_VIDEO_AVCLevel2;\ | ||
927 | _nIndex_ = 5;\ | ||
928 | break;\ | ||
929 | case IH264_LEVEL_21 :\ | ||
930 | _OutOMXLevel_=OMX_VIDEO_AVCLevel21;\ | ||
931 | _nIndex_ = 6;\ | ||
932 | break;\ | ||
933 | case IH264_LEVEL_22 :\ | ||
934 | _OutOMXLevel_= OMX_VIDEO_AVCLevel22;\ | ||
935 | _nIndex_ = 7;\ | ||
936 | break;\ | ||
937 | case IH264_LEVEL_30 :\ | ||
938 | _OutOMXLevel_= OMX_VIDEO_AVCLevel3;\ | ||
939 | _nIndex_ = 8;\ | ||
940 | break;\ | ||
941 | case IH264_LEVEL_31 :\ | ||
942 | _OutOMXLevel_= OMX_VIDEO_AVCLevel31;\ | ||
943 | _nIndex_ = 9;\ | ||
944 | break;\ | ||
945 | case IH264_LEVEL_32 :\ | ||
946 | _OutOMXLevel_= OMX_VIDEO_AVCLevel32;\ | ||
947 | _nIndex_ = 10;\ | ||
948 | break;\ | ||
949 | case IH264_LEVEL_40 :\ | ||
950 | _OutOMXLevel_= OMX_VIDEO_AVCLevel4;\ | ||
951 | _nIndex_ = 11;\ | ||
952 | break;\ | ||
953 | case IH264_LEVEL_41 :\ | ||
954 | _OutOMXLevel_ = OMX_VIDEO_AVCLevel41;\ | ||
955 | _nIndex_ = 12;\ | ||
956 | break;\ | ||
957 | case IH264_LEVEL_42 :\ | ||
958 | _OutOMXLevel_ = OMX_VIDEO_AVCLevel42;\ | ||
959 | _nIndex_ = 13;\ | ||
960 | break;\ | ||
961 | case IH264_LEVEL_50 :\ | ||
962 | _OutOMXLevel_= OMX_VIDEO_AVCLevel5;\ | ||
963 | _nIndex_ = 14;\ | ||
964 | break;\ | ||
965 | case IH264_LEVEL_51 :\ | ||
966 | _OutOMXLevel_= OMX_VIDEO_AVCLevel51;\ | ||
967 | _nIndex_ = 15;\ | ||
968 | break;\ | ||
969 | default :\ | ||
970 | _e_= OMX_ErrorNoMore;\ | ||
971 | _nIndex_ = 0xFFFFFFFF;\ | ||
972 | break;\ | ||
973 | } | ||
974 | |||
975 | /* Error mapping b/n XDM and OMX */ | ||
976 | #define OMX_TI_GET_ERROR(_pCompPvtStruct_, _x_, _e_) \ | ||
977 | _e_ = OMX_ErrorUndefined; \ | ||
978 | if( XDM_ISFATALERROR(_x_)) { /*bit 15*/\ | ||
979 | _e_ = OMX_ErrorUndefined;\ | ||
980 | OSAL_ErrorTrace("Undefined From Codec");\ | ||
981 | }\ | ||
982 | if(((_x_) >> IH264ENC_LEVEL_INCOMPLAINT_PARAMETER) & 0x1 ) { /*bit 0*/\ | ||
983 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
984 | OSAL_ErrorTrace("Due to Level Incompliant Param Setting");\ | ||
985 | }\ | ||
986 | if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_CONTENTTYPE) & 0x1 ) { /*bit 1*/\ | ||
987 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
988 | OSAL_ErrorTrace("Due to Profile Incompliant Content type(progressive/Interlace) Setting");\ | ||
989 | }\ | ||
990 | if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_FMO_SETTING) & 0x1 ) { /*bit 2*/\ | ||
991 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
992 | OSAL_ErrorTrace("Due to Profile Incompliant FMO Param Setting");\ | ||
993 | }\ | ||
994 | if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_TRANSFORMBLOCKSIZE) & 0x1 ) { /*bit 3*/\ | ||
995 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
996 | OSAL_ErrorTrace("Due to Profile Incompliant Transform Block Size Setting");\ | ||
997 | }\ | ||
998 | if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_INTERFRAMEINTERVAL) & 0x1 ) { /*bit 4*/\ | ||
999 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1000 | OSAL_ErrorTrace("Due to Profile Incompliant IntraFrame Interval Setting");\ | ||
1001 | }\ | ||
1002 | if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_SCALINGMATRIXPRESET) & 0x1 ) { /*bit 5*/\ | ||
1003 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1004 | OSAL_ErrorTrace("Due to Profile Incompliant Scaling Matrix Setting");\ | ||
1005 | }\ | ||
1006 | if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_ENTROPYCODINGMODE) & 0x1 ) { /*bit 6*/\ | ||
1007 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1008 | OSAL_ErrorTrace("Due to Profile Incompliant Entropy Coding Setting");\ | ||
1009 | OSAL_ErrorTrace("_or_ Due to violation of slice size (crossing the limit)");\ | ||
1010 | }\ | ||
1011 | if(((_x_) >> IH264ENC_MAX_BIT_RATE_VOILATION) & 0x1 ) { /*bit 7*/\ | ||
1012 | _e_ = OMX_ErrorOverflow;\ | ||
1013 | OSAL_ErrorTrace("Max bits for one Unit (1 sec) Voilation");\ | ||
1014 | }\ | ||
1015 | if(((_x_) >> IH264ENC_IMPROPER_HDVICP2_STATE) & 0x1 ) { /*bit 16*/\ | ||
1016 | _e_ = OMX_ErrorHardware;\ | ||
1017 | OSAL_ErrorTrace("IVAHD Device is not proper state to use");\ | ||
1018 | }\ | ||
1019 | if(((_x_) >> IH264ENC_IMPROPER_STREAMFORMAT) & 0x1 ) { /*bit 17*/\ | ||
1020 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1021 | OSAL_ErrorTrace("Due To Improper StreamFormat");\ | ||
1022 | }\ | ||
1023 | if(((_x_) >> IH264ENC_IMPROPER_POCTYPE) & 0x1 ) { /*bit 18*/\ | ||
1024 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1025 | OSAL_ErrorTrace("Due to InCorrect POC Type");\ | ||
1026 | }\ | ||
1027 | if(((_x_) >> IH264ENC_IMPROPER_DATASYNC_SETTING) & 0x1 ) { /*bit 19*/\ | ||
1028 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1029 | OSAL_ErrorTrace("Due to Imprper DataSync Settings");\ | ||
1030 | }\ | ||
1031 | if(((_x_) >> IH264ENC_UNSUPPORTED_VIDENC2PARAMS) & 0x1 ) { /*bit 20*/\ | ||
1032 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1033 | OSAL_ErrorTrace("Due To Unsupported Videnc2 Params");\ | ||
1034 | }\ | ||
1035 | if(((_x_) >> IH264ENC_UNSUPPORTED_RATECONTROLPARAMS) & 0x1 ) { /*bit 21*/\ | ||
1036 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1037 | OSAL_ErrorTrace("Due To Unsupported Rate Control Params");\ | ||
1038 | }\ | ||
1039 | if(((_x_) >> IH264ENC_UNSUPPORTED_INTERCODINGPARAMS) & 0x1 ) { /*bit 22*/\ | ||
1040 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1041 | OSAL_ErrorTrace("Due to Unsupported Intercoding Params");\ | ||
1042 | }\ | ||
1043 | if(((_x_) >> IH264ENC_UNSUPPORTED_INTRACODINGPARAMS) & 0x1 ) { /*bit 23*/\ | ||
1044 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1045 | OSAL_ErrorTrace("Due to Unsupported Intracoding Params");\ | ||
1046 | }\ | ||
1047 | if(((_x_) >> IH264ENC_UNSUPPORTED_NALUNITCONTROLPARAMS) & 0x1 ) { /*bit 24*/\ | ||
1048 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1049 | OSAL_ErrorTrace("Due to Unsupported NALControl Params");\ | ||
1050 | }\ | ||
1051 | if(((_x_) >> IH264ENC_UNSUPPORTED_SLICECODINGPARAMS) & 0x1 ) { /*bit 25*/\ | ||
1052 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1053 | OSAL_ErrorTrace("Due to Unsupported Slicecoding Params");\ | ||
1054 | }\ | ||
1055 | if(((_x_) >> IH264ENC_UNSUPPORTED_LOOPFILTERPARAMS) & 0x1 ) { /*bit 26*/\ | ||
1056 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1057 | OSAL_ErrorTrace("Due to Unsupported LoopFilter Params");\ | ||
1058 | }\ | ||
1059 | if(((_x_) >> IH264ENC_UNSUPPORTED_FMOCODINGPARAMS) & 0x1 ) { /*bit 27*/\ | ||
1060 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1061 | OSAL_ErrorTrace("Due to Unsupported FMOCoding Params or");\ | ||
1062 | OSAL_ErrorTrace("DATASYNC::No of NALs in 1Kb of data is more than 8/ insufficient memory blocks or");\ | ||
1063 | OSAL_ErrorTrace("Due to Unsupported setting in N frame process call scenario");\ | ||
1064 | }\ | ||
1065 | if(((_x_) >> IH264ENC_UNSUPPORTED_VUICODINGPARAMS) & 0x1 ) { /*bit 28*/\ | ||
1066 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1067 | OSAL_ErrorTrace("Due to Unsupported VUIcoding Params");\ | ||
1068 | }\ | ||
1069 | if(((_x_) >> IH264ENC_UNSUPPORTED_H264ENCPARAMS) & 0x1 ) { /*bit 29*/\ | ||
1070 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1071 | OSAL_ErrorTrace("Due to Unsupported H264ENC Params");\ | ||
1072 | }\ | ||
1073 | if(((_x_) >> IH264ENC_UNSUPPORTED_VIDENC2DYNAMICPARAMS) & 0x1 ) { /*bit 30*/\ | ||
1074 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1075 | OSAL_ErrorTrace("Due to Unsupported VIDENC2DYNAMIC Params");\ | ||
1076 | }\ | ||
1077 | if(((_x_) >> IH264ENC_UNSUPPORTED_H264ENCDYNAMICPARAMS) & 0x1 ) { /*bit 31*/\ | ||
1078 | _e_ = OMX_ErrorUnsupportedSetting;\ | ||
1079 | OSAL_ErrorTrace("Due to Unsupported H264ENCDYNAMIC Params");\ | ||
1080 | }\ | ||
1081 | if( XDM_ISUNSUPPORTEDPARAM(_x_)) { /*bit 14*/\ | ||
1082 | _e_ = OMX_ErrorBadParameter;\ | ||
1083 | OSAL_ErrorTrace("Due to UnSupported Parameter");\ | ||
1084 | }\ | ||
1085 | if( XDM_ISUNSUPPORTEDINPUT(_x_)) { /*bit 13*/\ | ||
1086 | _e_ = OMX_ErrorBadParameter;\ | ||
1087 | OSAL_ErrorTrace("Due to Unsupported Input");\ | ||
1088 | }\ | ||
1089 | if( XDM_ISCORRUPTEDHEADER(_x_)) { /*bit 12*/\ | ||
1090 | _e_ = OMX_ErrorStreamCorrupt;\ | ||
1091 | OSAL_ErrorTrace("Due to Corrupt Header");\ | ||
1092 | }\ | ||
1093 | if( XDM_ISCORRUPTEDDATA(_x_)) { /*bit 11*/\ | ||
1094 | _e_ = OMX_ErrorStreamCorrupt;\ | ||
1095 | OSAL_ErrorTrace("Due to Corrupted Data");\ | ||
1096 | }\ | ||
1097 | if( XDM_ISINSUFFICIENTDATA(_x_)) { /*bit 10*/\ | ||
1098 | _e_ = OMX_ErrorInsufficientResources;\ | ||
1099 | OSAL_ErrorTrace("Due to Insufficient Data");\ | ||
1100 | } | ||
1101 | |||
1102 | /* Internal functions */ | ||
1103 | OMX_ERRORTYPE OMXH264VE_InitFields(OMX_HANDLETYPE hComponent); | ||
1104 | |||
1105 | OMX_ERRORTYPE OMXH264VE_InitialzeComponentPrivateParams(OMX_HANDLETYPE hComponent); | ||
1106 | |||
1107 | OMX_ERRORTYPE OMXH264VE_SetAlgDefaultCreationParams(OMX_HANDLETYPE pHandle); | ||
1108 | |||
1109 | OMX_ERRORTYPE OMXH264VE_SetAlgDefaultDynamicParams(OMX_HANDLETYPE pHandle); | ||
1110 | |||
1111 | OMX_ERRORTYPE OMXH264VE_SetBufferDesc(OMX_HANDLETYPE pHandle, OMX_U32 nPortIndex); | ||
1112 | |||
1113 | OMX_ERRORTYPE OMXH264VE_SetEncCodecReady(OMX_HANDLETYPE hComponent); | ||
1114 | |||
1115 | OMX_ERRORTYPE OMXH264VE_UpdateParams(OMX_HANDLETYPE hComponent); | ||
1116 | |||
1117 | /* Buffer statemachine Related*/ | ||
1118 | OMX_ERRORTYPE OMXH264VE_FLUSHLockedBuffers(OMX_HANDLETYPE hComponent); | ||
1119 | OMX_ERRORTYPE OMXH264VE_GetNextFreeBufHdr(OMX_HANDLETYPE hComponent, OMX_S32 *nBuffIndex, OMX_U32 nPortIndex); | ||
1120 | OMX_ERRORTYPE OMXH264VE_GetNumCodecLockedBuffers(OMX_HANDLETYPE hComponent, OMX_U32 *nLockedBuffCount); | ||
1121 | OMX_ERRORTYPE OMXH264VE_SetDynamicParamsToCodec(OMX_HANDLETYPE hComponent); | ||
1122 | |||
1123 | OMX_ERRORTYPE OMXH264VE_VISACONTROL(VIDENC2_Handle handle, IVIDENC2_Cmd id, IVIDENC2_DynamicParams *dynParams, | ||
1124 | IVIDENC2_Status *status, OMX_HANDLETYPE hComponent, XDAS_Int32 *retval); | ||
1125 | |||
1126 | OMX_ERRORTYPE OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(OMX_HANDLETYPE hComponent, XDAS_Int32 *retval); | ||
1127 | |||
1128 | /* Functions to check the max bit rate supported as per profile & level settings*/ | ||
1129 | OMX_ERRORTYPE OMXH264VE_CheckBitRateCap(OMX_U32 targetBitRate, OMX_HANDLETYPE hComponent); | ||
1130 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_H264_ENCODER" | ||
18 | |||
19 | #include <MetadataBufferType.h> | ||
20 | #include "omx_H264videoencoder.h" | ||
21 | #include <OMX_IndexExt.h> | ||
22 | #include <libdce.h> | ||
23 | |||
24 | #define COLORCONVERT_MAX_SUB_BUFFERS (3) | ||
25 | |||
26 | #define COLORCONVERT_BUFTYPE_VIRTUAL (0x0) | ||
27 | #define COLORCONVERT_BUFTYPE_ION (0x1) | ||
28 | #define COLORCONVERT_BUFTYPE_GRALLOCOPAQUE (0x2) | ||
29 | |||
30 | static OMX_ERRORTYPE OMXH264VE_GetParameter(OMX_HANDLETYPE hComponent, | ||
31 | OMX_INDEXTYPE nParamIndex, | ||
32 | OMX_PTR pParamStruct); | ||
33 | |||
34 | static OMX_ERRORTYPE OMXH264VE_SetParameter(OMX_HANDLETYPE hComponent, | ||
35 | OMX_INDEXTYPE nParamIndex, | ||
36 | OMX_PTR pParamStruct); | ||
37 | |||
38 | static OMX_ERRORTYPE OMXH264VE_GetConfig(OMX_HANDLETYPE hComponent, | ||
39 | OMX_INDEXTYPE nIndex, | ||
40 | OMX_PTR pConfigData); | ||
41 | |||
42 | static OMX_ERRORTYPE OMXH264VE_SetConfig(OMX_HANDLETYPE hComponent, | ||
43 | OMX_INDEXTYPE nIndex, | ||
44 | OMX_PTR pConfigData); | ||
45 | |||
46 | static OMX_ERRORTYPE OMXH264VE_ComponentTunnelRequest(OMX_HANDLETYPE hComponent, | ||
47 | OMX_U32 nPort, | ||
48 | OMX_HANDLETYPE hTunneledComp, | ||
49 | OMX_U32 nTunneledPort, | ||
50 | OMX_TUNNELSETUPTYPE *pTunnelSetup); | ||
51 | |||
52 | static OMX_ERRORTYPE OMXH264VE_CommandNotify(OMX_HANDLETYPE hComponent, | ||
53 | OMX_COMMANDTYPE Cmd, | ||
54 | OMX_U32 nParam, | ||
55 | OMX_PTR pCmdData); | ||
56 | |||
57 | static OMX_ERRORTYPE OMXH264VE_DataNotify(OMX_HANDLETYPE hComponent); | ||
58 | |||
59 | |||
60 | static OMX_ERRORTYPE OMXH264VE_ComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent); | ||
61 | |||
62 | |||
63 | static OMX_ERRORTYPE OMXH264VE_GetExtensionIndex(OMX_HANDLETYPE hComponent, | ||
64 | OMX_STRING cParameterName, | ||
65 | OMX_INDEXTYPE *pIndexType); | ||
66 | |||
67 | |||
68 | int COLORCONVERT_PlatformOpaqueToNV12(void *hCC, | ||
69 | void *pSrc[COLORCONVERT_MAX_SUB_BUFFERS], | ||
70 | void *pDst[COLORCONVERT_MAX_SUB_BUFFERS], | ||
71 | int nWidth, int nHeight, int nStride, | ||
72 | int nSrcBufType,int nDstBufType) | ||
73 | { | ||
74 | IMG_gralloc_module_public_t const* module = hCC; | ||
75 | int nErr = -1; | ||
76 | (void)nStride; | ||
77 | |||
78 | if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_VIRTUAL)) { | ||
79 | nErr = module->Blit(module, pSrc[0], pDst, HAL_PIXEL_FORMAT_NV12); | ||
80 | } else if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE )) { | ||
81 | nErr = module->Blit2(module, pSrc[0], pDst[0], nWidth, nHeight, 0, 0); | ||
82 | } | ||
83 | |||
84 | return nErr; | ||
85 | } | ||
86 | |||
87 | OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent) | ||
88 | { | ||
89 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
90 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
91 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
92 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
93 | |||
94 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
95 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
96 | |||
97 | OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); | ||
98 | |||
99 | /* Allocate memory for H264VE Component's private data area */ | ||
100 | pHandle->pComponentPrivate = (OMXH264VidEncComp *)OSAL_Malloc(sizeof(OMXH264VidEncComp)); | ||
101 | OMX_CHECK(pHandle->pComponentPrivate != NULL, OMX_ErrorInsufficientResources); | ||
102 | tStatus = OSAL_Memset(pHandle->pComponentPrivate, 0x0, sizeof(OMXH264VidEncComp)); | ||
103 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter); | ||
104 | |||
105 | /*Initialize the Component Private handle*/ | ||
106 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
107 | |||
108 | eError= OMXH264VE_InitFields(pHandle); | ||
109 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
110 | |||
111 | /*initialize the Hooks to Notify Command and Data from Base Comp to Derived Comp */ | ||
112 | pH264VEComp->sBase.fpCommandNotify = OMXH264VE_CommandNotify; | ||
113 | pH264VEComp->sBase.fpDataNotify = OMXH264VE_DataNotify; | ||
114 | |||
115 | /* initialize the base component */ | ||
116 | eError = OMXBase_ComponentInit(hComponent); | ||
117 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
118 | |||
119 | strcpy((char *)pH264VEComp->sBase.pPvtData->cTaskName, "H264VideoEncoder"); | ||
120 | pH264VEComp->sBase.pPvtData->nStackSize = OMX_H264VE_STACKSIZE; | ||
121 | pH264VEComp->sBase.pPvtData->nPrioirty = OMX_H264VE_DEFAULT_TASKPRIORITY; | ||
122 | |||
123 | /*Setting default properties. PreCondition: NumOfPorts is filled and all pointers allocated*/ | ||
124 | eError = OMXBase_SetDefaultProperties(hComponent); | ||
125 | OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); | ||
126 | |||
127 | /* Override the function pointers of pHandle "OMX_COMPONENTTYPE" | ||
128 | * which Base cannot handle and needs to be taken care by the Dervied comp*/ | ||
129 | pHandle->GetParameter = OMXH264VE_GetParameter; | ||
130 | pHandle->SetParameter = OMXH264VE_SetParameter; | ||
131 | pHandle->SetConfig = OMXH264VE_SetConfig; | ||
132 | pHandle->GetConfig = OMXH264VE_GetConfig; | ||
133 | pHandle->ComponentDeInit = OMXH264VE_ComponentDeinit; | ||
134 | pHandle->GetExtensionIndex = OMXH264VE_GetExtensionIndex; | ||
135 | pHandle->ComponentTunnelRequest = OMXH264VE_ComponentTunnelRequest; | ||
136 | |||
137 | eError= OMXH264VE_InitialzeComponentPrivateParams(pHandle); | ||
138 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
139 | |||
140 | /* Open the Engine*/ | ||
141 | pH264VEComp->pCEhandle = Engine_open(OMX_ENGINE_NAME, NULL, &pH264VEComp->tCEerror); | ||
142 | if( pH264VEComp->pCEhandle == NULL ) { | ||
143 | OSAL_ErrorTrace("Engine creation: Could not open engine \n"); | ||
144 | eError = OMX_ErrorInsufficientResources; | ||
145 | goto EXIT; | ||
146 | } | ||
147 | |||
148 | pH264VEComp->bInputMetaDataBufferMode = OMX_FALSE; | ||
149 | pH264VEComp->mAllocDev = NULL; | ||
150 | pH264VEComp->hCC = NULL; | ||
151 | |||
152 | EXIT: | ||
153 | if( eError != OMX_ErrorNone ) { | ||
154 | OSAL_ErrorTrace(" H264VE Comp Initialization Failed...! "); | ||
155 | if( pHandle ) { | ||
156 | pHandle->ComponentDeInit(hComponent); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | return (eError); | ||
161 | } | ||
162 | |||
163 | |||
164 | static OMX_ERRORTYPE OMXH264VE_GetParameter(OMX_HANDLETYPE hComponent, | ||
165 | OMX_INDEXTYPE nParamIndex, | ||
166 | OMX_PTR pParamStruct) | ||
167 | { | ||
168 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
169 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
170 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
171 | OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortParams = NULL; | ||
172 | OMX_VIDEO_PARAM_AVCTYPE *LAVCParams=NULL; | ||
173 | OMX_VIDEO_PARAM_VBSMCTYPE *LVBSMC = NULL; | ||
174 | OMX_STATETYPE nLCurState; | ||
175 | OMX_BOOL bAllocateLocalAVC=OMX_FALSE; | ||
176 | OMX_U32 nPortIndex; | ||
177 | OMX_U32 *pConsumerUsage; | ||
178 | OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef=NULL; | ||
179 | struct DescribeColorFormatParams *Colorparams; | ||
180 | |||
181 | /* Check all the input parametrs */ | ||
182 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
183 | OMX_CHECK(pParamStruct != NULL, OMX_ErrorBadParameter); | ||
184 | |||
185 | /*initialize the component handle and component pvt handle*/ | ||
186 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
187 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
188 | |||
189 | /* Allocate memory for LAVCParams */ | ||
190 | LAVCParams = (OMX_VIDEO_PARAM_AVCTYPE *)OSAL_Malloc(sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | ||
191 | OMX_CHECK(LAVCParams != NULL, OMX_ErrorInsufficientResources); | ||
192 | bAllocateLocalAVC=OMX_TRUE; | ||
193 | |||
194 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
195 | nLCurState=pH264VEComp->sBase.tCurState; | ||
196 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
197 | /* GetParameter can't be invoked incase the comp is in Invalid State */ | ||
198 | OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation); | ||
199 | |||
200 | switch( (int) nParamIndex ) { | ||
201 | /* case OMX_IndexParamVideoInit: required for Standard Video Encoder as per Spec & is defined at BASE */ | ||
202 | /* case OMX_IndexParamPortDefinition: required for Standard Video Encoder as per Spec & is defined at BASE */ | ||
203 | /* required for Standard Video Encoder as per Spec .. | ||
204 | client uses this to query the format supported by the port */ | ||
205 | case OMX_IndexParamVideoPortFormat : | ||
206 | /* Check for the correct nSize & nVersion information */ | ||
207 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError); | ||
208 | pVideoPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; | ||
209 | /* Retrieving the Input Port params */ | ||
210 | if( pVideoPortParams->nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex ) { | ||
211 | /*Get the compression format*/ | ||
212 | pVideoPortParams->eCompressionFormat = OMX_VIDEO_CodingUnused; | ||
213 | |||
214 | /*Get the Frame rate : from the codec Dynamic Params...Q16 format*/ | ||
215 | pVideoPortParams->xFramerate = (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate / 1000) << 16; | ||
216 | |||
217 | /*Get the supported (only 420SP is supported) color formats : from the Codec creation time Params*/ | ||
218 | switch( pVideoPortParams->nIndex ) { | ||
219 | case 0 : | ||
220 | GET_OMX_COLORFORMAT(pH264VEComp, eError); | ||
221 | pVideoPortParams->eColorFormat = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat; | ||
222 | break; | ||
223 | case 1 : | ||
224 | pVideoPortParams->eColorFormat = OMX_COLOR_FormatAndroidOpaque; | ||
225 | break; | ||
226 | case 2: | ||
227 | pVideoPortParams->eColorFormat = OMX_COLOR_FormatYUV420Flexible; | ||
228 | break; | ||
229 | default : | ||
230 | eError = OMX_ErrorNoMore; | ||
231 | break; | ||
232 | } | ||
233 | } | ||
234 | /* Retrieving the Output Port params */ | ||
235 | else if( pVideoPortParams->nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex ) { | ||
236 | |||
237 | /*Get the Color Format*/ | ||
238 | pVideoPortParams->eColorFormat = OMX_COLOR_FormatUnused; | ||
239 | |||
240 | /*Get the Frame Rate */ | ||
241 | pVideoPortParams->xFramerate = 0; | ||
242 | |||
243 | /*Get the Supported CompressionFormats: only AVC is supported*/ | ||
244 | switch( pVideoPortParams->nIndex ) { | ||
245 | case 0 : | ||
246 | pVideoPortParams->eCompressionFormat = OMX_VIDEO_CodingAVC; | ||
247 | break; | ||
248 | default : | ||
249 | eError=OMX_ErrorNoMore; | ||
250 | break; | ||
251 | } | ||
252 | } else { | ||
253 | eError = OMX_ErrorBadPortIndex; | ||
254 | } | ||
255 | break; | ||
256 | |||
257 | /* required for Standard Video Encoder as per Spec & | ||
258 | Client uses this to retrieve the Info related to the AVC rate control type*/ | ||
259 | case OMX_IndexParamVideoBitrate : | ||
260 | /* Check for the correct nSize & nVersion information */ | ||
261 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_BITRATETYPE, eError); | ||
262 | if(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
263 | /*Get the Rate Control Algorithm: from the Codec Creation Time Params*/ | ||
264 | GET_OMX_RC_ALG(pH264VEComp, pParamStruct, eError); | ||
265 | |||
266 | /*Get the Target Bit Rate: from the Codec Dynamic Params*/ | ||
267 | ((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate= | ||
268 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate; | ||
269 | |||
270 | } else { | ||
271 | eError = OMX_ErrorBadPortIndex; | ||
272 | } | ||
273 | break; | ||
274 | |||
275 | /* required for Standard Video Encoder as per Spec & | ||
276 | Client uses this to retrieve the Info related to the AVC structure type*/ | ||
277 | case OMX_IndexParamVideoAvc : | ||
278 | /* Check for the correct nSize & nVersion information */ | ||
279 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError); | ||
280 | if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
281 | GET_OMX_AVC_PARAMS(pH264VEComp, pParamStruct); | ||
282 | /*Get the Profile value from the Codec Creation Params*/ | ||
283 | GET_OMX_AVC_PROFILE(pH264VEComp, pParamStruct, eError); | ||
284 | |||
285 | /*Get the level from the Codec Creation Params*/ | ||
286 | GET_OMX_AVC_LEVEL(pH264VEComp, pParamStruct, eError); | ||
287 | |||
288 | /*get the LoopFilter mode form the Codec Creation Time Params*/ | ||
289 | GET_OMX_AVC_LFMODE(pH264VEComp, pParamStruct, eError); | ||
290 | } else { | ||
291 | eError = OMX_ErrorBadPortIndex; | ||
292 | } | ||
293 | break; | ||
294 | |||
295 | /* Client uses this to retrieve the Info related to the Motion vector type*/ | ||
296 | case OMX_IndexParamVideoMotionVector : | ||
297 | /* Check for the correct nSize & nVersion information */ | ||
298 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MOTIONVECTORTYPE, eError); | ||
299 | if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
300 | /*Get the MV Accuracy from Codec Dynamic Params*/ | ||
301 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->eAccuracy = | ||
302 | (OMX_VIDEO_MOTIONVECTORTYPE)pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy; | ||
303 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bUnrestrictedMVs = OMX_TRUE; /*by Default Codec Supports*/ | ||
304 | /*Number of MVs depend on the min Block size selected*/ | ||
305 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bFourMV = | ||
306 | (pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_8x8 ? OMX_TRUE : OMX_FALSE); | ||
307 | /*Get the Search Range from the search Range for P Frame*/ | ||
308 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange = | ||
309 | pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorP; | ||
310 | |||
311 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange = | ||
312 | pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerP; | ||
313 | } else { | ||
314 | eError = OMX_ErrorBadPortIndex; | ||
315 | } | ||
316 | break; | ||
317 | |||
318 | /* Client uses this to configure Info related to the quantization parameter type*/ | ||
319 | case OMX_IndexParamVideoQuantization : | ||
320 | /* Check for the correct nSize & nVersion information */ | ||
321 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_QUANTIZATIONTYPE, eError); | ||
322 | if(((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
323 | ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI = pH264VEComp->pVidEncStaticParams->rateControlParams.qpI; | ||
324 | ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP = pH264VEComp->pVidEncStaticParams->rateControlParams.qpP; | ||
325 | ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB = (pH264VEComp->pVidEncStaticParams->rateControlParams.qpP) | ||
326 | + (pH264VEComp->pVidEncStaticParams->rateControlParams.qpOffsetB); | ||
327 | } else { | ||
328 | eError = OMX_ErrorBadPortIndex; | ||
329 | } | ||
330 | break; | ||
331 | |||
332 | case OMX_IndexParamVideoSliceFMO : | ||
333 | /* Check for the correct nSize & nVersion information */ | ||
334 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCSLICEFMO, eError); | ||
335 | if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
336 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nNumSliceGroups = | ||
337 | pH264VEComp->pVidEncStaticParams->fmoCodingParams.numSliceGroups; | ||
338 | |||
339 | /*get the fmo slice grp type form the Codec Creation Time Params*/ | ||
340 | GET_OMX_FMO_SLIGRPMAPTYPE(pH264VEComp, pParamStruct, eError); | ||
341 | |||
342 | /*get the slice mode from the Codec Creation Time Params*/ | ||
343 | GET_OMX_FMO_SLICEMODE(pH264VEComp, pParamStruct, eError); | ||
344 | |||
345 | } else { | ||
346 | eError = OMX_ErrorBadPortIndex; | ||
347 | } | ||
348 | break; | ||
349 | |||
350 | case OMX_IndexParamVideoIntraRefresh : | ||
351 | /* Check for the correct nSize & nVersion information */ | ||
352 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_INTRAREFRESHTYPE, eError); | ||
353 | if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
354 | GET_OMX_INTRAREFRESHMODE(pH264VEComp, pParamStruct, eError); | ||
355 | } else { | ||
356 | eError = OMX_ErrorBadPortIndex; | ||
357 | } | ||
358 | break; | ||
359 | |||
360 | /* required for Standard Video Encoder as per Spec*/ | ||
361 | case OMX_IndexParamVideoProfileLevelCurrent : | ||
362 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
363 | if(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
364 | /*Get the Codec Profile */ | ||
365 | GET_OMX_AVC_PROFILE(pH264VEComp, LAVCParams, eError); | ||
366 | ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile = LAVCParams->eProfile; | ||
367 | |||
368 | /*Get the Codec level */ | ||
369 | GET_OMX_AVC_LEVEL(pH264VEComp, LAVCParams, eError); | ||
370 | |||
371 | ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel = LAVCParams->eLevel; | ||
372 | } else { | ||
373 | eError = OMX_ErrorBadPortIndex; | ||
374 | } | ||
375 | break; | ||
376 | |||
377 | /* required for Standard Video Encoder as per Spec*/ | ||
378 | case OMX_IndexParamVideoProfileLevelQuerySupported : | ||
379 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
380 | if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
381 | switch(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nProfileIndex ) { | ||
382 | case 0 : | ||
383 | ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile = OMX_VIDEO_AVCProfileBaseline; | ||
384 | ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel = OMX_VIDEO_AVCLevel51; | ||
385 | break; | ||
386 | case 1 : | ||
387 | ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile=OMX_VIDEO_AVCProfileMain; | ||
388 | ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel=OMX_VIDEO_AVCLevel51; | ||
389 | break; | ||
390 | case 2 : | ||
391 | ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile=OMX_VIDEO_AVCProfileHigh; | ||
392 | ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel=OMX_VIDEO_AVCLevel51; | ||
393 | break; | ||
394 | default : | ||
395 | eError =OMX_ErrorNoMore; | ||
396 | } | ||
397 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
398 | } else { | ||
399 | eError = OMX_ErrorBadPortIndex; | ||
400 | } | ||
401 | break; | ||
402 | |||
403 | case OMX_IndexParamVideoVBSMC : | ||
404 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
405 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
406 | nLCurState=pH264VEComp->sBase.tCurState; | ||
407 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
408 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
409 | /* Check for the correct nSize & nVersion information */ | ||
410 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_VBSMCTYPE, eError); | ||
411 | if(((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
412 | LVBSMC = ((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct); | ||
413 | if( pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_8x8 ) { | ||
414 | /*4MV case*/ | ||
415 | LVBSMC->b16x16=OMX_TRUE; | ||
416 | LVBSMC->b16x8=OMX_TRUE; | ||
417 | LVBSMC->b8x16=OMX_TRUE; | ||
418 | LVBSMC->b8x8=OMX_TRUE; | ||
419 | LVBSMC->b8x4=OMX_FALSE; | ||
420 | LVBSMC->b4x8=OMX_FALSE; | ||
421 | LVBSMC->b4x4=OMX_FALSE; | ||
422 | } else if( pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_16x16 ) { | ||
423 | /*1 MV case*/ | ||
424 | /*set the same value for both P & B frames prediction*/ | ||
425 | LVBSMC->b16x16=OMX_TRUE; | ||
426 | LVBSMC->b16x8=OMX_FALSE; | ||
427 | LVBSMC->b8x16=OMX_FALSE; | ||
428 | LVBSMC->b8x8=OMX_FALSE; | ||
429 | LVBSMC->b8x4=OMX_FALSE; | ||
430 | LVBSMC->b4x8=OMX_FALSE; | ||
431 | LVBSMC->b4x4=OMX_FALSE; | ||
432 | } else { | ||
433 | eError = OMX_ErrorNoMore; | ||
434 | } | ||
435 | } else { | ||
436 | eError = OMX_ErrorBadPortIndex; | ||
437 | } | ||
438 | break; | ||
439 | |||
440 | case OMX_IndexParamConsumerUsageBits: | ||
441 | //parameter is uint32 | ||
442 | pConsumerUsage = (OMX_U32*)(pParamStruct); | ||
443 | *pConsumerUsage = 0x00; | ||
444 | eError = OMX_ErrorNone; | ||
445 | break; | ||
446 | |||
447 | case (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat: | ||
448 | Colorparams = (struct DescribeColorFormatParams*)(pParamStruct); | ||
449 | |||
450 | pInputPortDef = &(pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef); | ||
451 | struct MediaImage *image = &(Colorparams->sMediaImage); | ||
452 | memset(image, 0, sizeof(MediaImage)); | ||
453 | |||
454 | image->mWidth = pInputPortDef->format.video.nFrameWidth; | ||
455 | image->mHeight = pInputPortDef->format.video.nFrameHeight; | ||
456 | |||
457 | image->mType = MEDIA_IMAGE_TYPE_YUV; | ||
458 | image->mNumPlanes = 3; | ||
459 | image->mBitDepth = 8; | ||
460 | |||
461 | image->mPlane[Y].mOffset = 0; | ||
462 | image->mPlane[Y].mColInc = 1; | ||
463 | image->mPlane[Y].mRowInc = pInputPortDef->format.video.nStride; | ||
464 | image->mPlane[Y].mHorizSubsampling = 1; | ||
465 | image->mPlane[Y].mVertSubsampling = 1; | ||
466 | |||
467 | image->mPlane[U].mOffset = pInputPortDef->format.video.nStride * pInputPortDef->format.video.nFrameHeight; | ||
468 | image->mPlane[U].mColInc = 2; | ||
469 | image->mPlane[U].mRowInc = pInputPortDef->format.video.nStride; | ||
470 | image->mPlane[U].mHorizSubsampling = 2; | ||
471 | image->mPlane[U].mVertSubsampling = 2; | ||
472 | |||
473 | image->mPlane[V].mOffset = image->mPlane[U].mOffset + 1; | ||
474 | image->mPlane[V].mColInc = 2; | ||
475 | image->mPlane[V].mRowInc = pInputPortDef->format.video.nStride; | ||
476 | image->mPlane[V].mHorizSubsampling = 2; | ||
477 | image->mPlane[V].mVertSubsampling = 2; | ||
478 | |||
479 | break; | ||
480 | |||
481 | /* redirects the call to "OMXBase_GetParameter" which supports standard comp indexes */ | ||
482 | default : | ||
483 | eError = OMXBase_GetParameter(hComponent, nParamIndex, pParamStruct); | ||
484 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
485 | break; | ||
486 | |||
487 | } | ||
488 | |||
489 | EXIT: | ||
490 | if( bAllocateLocalAVC ) { | ||
491 | OSAL_Free(LAVCParams); | ||
492 | } | ||
493 | |||
494 | return (eError); | ||
495 | } | ||
496 | |||
497 | static OMX_ERRORTYPE OMXH264VE_SetParameter(OMX_HANDLETYPE hComponent, | ||
498 | OMX_INDEXTYPE nParamIndex, | ||
499 | OMX_PTR pParamStruct) | ||
500 | { | ||
501 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
502 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
503 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
504 | OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortParams = NULL; | ||
505 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef=NULL; | ||
506 | OMX_PARAM_PORTDEFINITIONTYPE *pLocalPortDef=NULL; | ||
507 | OMX_VIDEO_PARAM_AVCTYPE *LAVCParams=NULL; | ||
508 | OMX_VIDEO_PARAM_VBSMCTYPE *LVBSMC = NULL; | ||
509 | OMX_U32 nPortIndex; | ||
510 | OMX_STATETYPE nLCurState; | ||
511 | OMX_BOOL bLCodecCreateFlag=OMX_FALSE; | ||
512 | PARAMS_UPDATE_STATUS bLCallxDMSetParams=NO_PARAM_CHANGE; | ||
513 | OMX_BOOL bAllocateLocalAVC=OMX_FALSE; | ||
514 | |||
515 | /* Check for the input parameters */ | ||
516 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
517 | OMX_CHECK(pParamStruct != NULL, OMX_ErrorBadParameter); | ||
518 | |||
519 | /*initialize the component handle and component pvt handle*/ | ||
520 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
521 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
522 | |||
523 | /* Allocate memory for LAVCParams */ | ||
524 | LAVCParams = (OMX_VIDEO_PARAM_AVCTYPE *)OSAL_Malloc(sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | ||
525 | OMX_CHECK(LAVCParams != NULL, OMX_ErrorInsufficientResources); | ||
526 | bAllocateLocalAVC = OMX_TRUE; | ||
527 | |||
528 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
529 | nLCurState = pH264VEComp->sBase.tCurState; | ||
530 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
531 | |||
532 | /* SetParameter can't be invoked incase the comp is in Invalid State */ | ||
533 | OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation); | ||
534 | |||
535 | switch( (int) nParamIndex ) { | ||
536 | case OMX_IndexParamVideoInit : | ||
537 | OSAL_Info("In OMX_IndexParamVideoInit"); | ||
538 | /* SetParameter can be invoked only when the comp is in loaded or on a disabled port */ | ||
539 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
540 | nLCurState = pH264VEComp->sBase.tCurState; | ||
541 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
542 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
543 | OMX_CHECK((((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber == 0), OMX_ErrorUnsupportedSetting); | ||
544 | OMX_CHECK((((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts == 2), OMX_ErrorUnsupportedSetting); | ||
545 | OSAL_Memcpy(pH264VEComp->sBase.pVideoPortParams, pParamStruct, sizeof(OMX_PORT_PARAM_TYPE)); | ||
546 | break; | ||
547 | |||
548 | case OMX_IndexParamPortDefinition : | ||
549 | OSAL_Info("In OMX_IndexParamPortDefinition"); | ||
550 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, eError); | ||
551 | pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct; | ||
552 | nPortIndex = pPortDef->nPortIndex; | ||
553 | |||
554 | /*check for valid port index */ | ||
555 | OMX_CHECK(nPortIndex < ((pH264VEComp->sBase.pVideoPortParams->nStartPortNumber) + | ||
556 | (pH264VEComp->sBase.pVideoPortParams->nPorts)), OMX_ErrorBadPortIndex); | ||
557 | |||
558 | /*successful only when the comp is in loaded or on a disabled port*/ | ||
559 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
560 | nLCurState = pH264VEComp->sBase.tCurState; | ||
561 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
562 | OMX_CHECK((nLCurState == OMX_StateLoaded) || | ||
563 | (pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.bEnabled == OMX_FALSE), | ||
564 | OMX_ErrorIncorrectStateOperation); | ||
565 | pLocalPortDef = &(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef); | ||
566 | |||
567 | OMX_CHECK((pPortDef->nBufferCountActual >= | ||
568 | pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.nBufferCountMin), OMX_ErrorUnsupportedSetting); | ||
569 | |||
570 | pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.nBufferCountActual = pPortDef->nBufferCountActual; | ||
571 | /*if frame height/widht changes then change the buffer requirements accordingly*/ | ||
572 | if( nPortIndex == OMX_H264VE_INPUT_PORT ) { | ||
573 | if (pH264VEComp->bInputMetaDataBufferMode) { | ||
574 | pPortDef->format.video.nStride = ALIGN(pPortDef->format.video.nStride, HW_ALIGN); | ||
575 | } | ||
576 | |||
577 | OMX_CHECK(((pPortDef->format.video.nFrameWidth & 0x0F) == 0), OMX_ErrorUnsupportedSetting); /*Width should be multiple of 16*/ | ||
578 | if( pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) { | ||
579 | OMX_CHECK(((pPortDef->format.video.nFrameHeight & 0x01) == 0), OMX_ErrorUnsupportedSetting); /* Width should be multiple of 16 */ | ||
580 | } else { | ||
581 | OMX_CHECK(((pPortDef->format.video.nFrameHeight & 0x03) == 0), OMX_ErrorUnsupportedSetting); /* Width should be multiple of 16 */ | ||
582 | } | ||
583 | if (pPortDef->format.video.nStride % 16 != 0) { | ||
584 | eError = OMX_ErrorUnsupportedSetting; | ||
585 | break; | ||
586 | } | ||
587 | OMX_CHECK(((OMX_U32)pPortDef->format.video.nStride >= pPortDef->format.video.nFrameWidth), OMX_ErrorUnsupportedSetting); | ||
588 | |||
589 | OMX_CHECK((pPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) || | ||
590 | (pPortDef->format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) || | ||
591 | (pPortDef->format.video.eColorFormat == OMX_COLOR_FormatYUV420Flexible), | ||
592 | OMX_ErrorUnsupportedSetting); | ||
593 | if((pPortDef->format.video.nFrameWidth < 96) || (pPortDef->format.video.nFrameHeight < 80)) { | ||
594 | eError=OMX_ErrorUnsupportedSetting; | ||
595 | break; | ||
596 | } | ||
597 | SET_H264CODEC_CHROMAFORMAT(pPortDef, pH264VEComp, eError); | ||
598 | |||
599 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
600 | // Storing the CLient provided frame rate in internal port def structure for i/p port | ||
601 | if( pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate != pPortDef->format.video.xFramerate) { | ||
602 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate = | ||
603 | pPortDef->format.video.xFramerate; | ||
604 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = | ||
605 | (pPortDef->format.video.xFramerate >> 16) * 1000; | ||
606 | } | ||
607 | |||
608 | if((pLocalPortDef->format.video.nFrameHeight != pPortDef->format.video.nFrameHeight) || | ||
609 | (pLocalPortDef->format.video.nFrameWidth != pPortDef->format.video.nFrameWidth) || | ||
610 | (pLocalPortDef->format.video.nStride != pPortDef->format.video.nStride)) { | ||
611 | pLocalPortDef->format.video.nStride =pPortDef->format.video.nStride; | ||
612 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth = | ||
613 | pPortDef->format.video.nFrameWidth; | ||
614 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight = | ||
615 | pPortDef->format.video.nFrameHeight; | ||
616 | |||
617 | /*Update the Sliceheight as well*/ | ||
618 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nSliceHeight = | ||
619 | pPortDef->format.video.nFrameHeight; | ||
620 | |||
621 | pH264VEComp->pVidEncStaticParams->videnc2Params.maxHeight = pPortDef->format.video.nFrameHeight; | ||
622 | pH264VEComp->pVidEncStaticParams->videnc2Params.maxWidth = pPortDef->format.video.nFrameWidth; | ||
623 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputWidth = pPortDef->format.video.nFrameWidth; | ||
624 | |||
625 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.captureWidth = pPortDef->format.video.nStride; | ||
626 | |||
627 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputHeight = pPortDef->format.video.nFrameHeight; | ||
628 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferSize = | ||
629 | (pPortDef->format.video.nFrameHeight * pPortDef->format.video.nFrameWidth * 3 )/2; | ||
630 | |||
631 | bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
632 | OSAL_Memcpy(&(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.format), &(pPortDef->format), | ||
633 | sizeof(OMX_VIDEO_PORTDEFINITIONTYPE)); | ||
634 | |||
635 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = | ||
636 | (pPortDef->format.video.nFrameHeight * pPortDef->format.video.nStride * 3) / 2; | ||
637 | |||
638 | if (pH264VEComp->bInputMetaDataBufferMode) { | ||
639 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = sizeof(OMX_MetaDataBuffer); | ||
640 | } | ||
641 | |||
642 | /* read only field value. update with the frame height.for now codec does not supports the sub frame processing*/ | ||
643 | pLocalPortDef->format.video.nSliceHeight=pPortDef->format.video.nFrameHeight; | ||
644 | |||
645 | bLCodecCreateFlag = OMX_TRUE; | ||
646 | pH264VEComp->bSetParamInputIsDone = OMX_TRUE; | ||
647 | } | ||
648 | } else { | ||
649 | /*OUTPUT Port*/ | ||
650 | OMX_CHECK((pPortDef->format.video.nFrameWidth == | ||
651 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth), | ||
652 | OMX_ErrorUnsupportedSetting); | ||
653 | OMX_CHECK((pPortDef->format.video.nFrameHeight == | ||
654 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight), | ||
655 | OMX_ErrorUnsupportedSetting); | ||
656 | |||
657 | if( pPortDef->format.video.xFramerate != 0 ) { | ||
658 | OSAL_WarningTrace("Non-zero framerate rate set on o/p port. Setting frame rate is supported only on i/p port"); | ||
659 | pPortDef->format.video.xFramerate = 0; | ||
660 | } | ||
661 | eError = OMXH264VE_CheckBitRateCap(pPortDef->format.video.nBitrate, hComponent); | ||
662 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
663 | OSAL_Memcpy(&(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.format), &(pPortDef->format), | ||
664 | sizeof(OMX_VIDEO_PORTDEFINITIONTYPE)); | ||
665 | |||
666 | /*Not to modify the read only field value*/ | ||
667 | pLocalPortDef->format.video.nSliceHeight = | ||
668 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight; | ||
669 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = | ||
670 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate; | ||
671 | |||
672 | if (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate < OMX_H264VE_MIN_BITRATE) { | ||
673 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_MIN_BITRATE; | ||
674 | } | ||
675 | |||
676 | OMX_CHECK(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat == | ||
677 | OMX_VIDEO_CodingAVC, OMX_ErrorUnsupportedSetting); | ||
678 | bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX; | ||
679 | } | ||
680 | break; | ||
681 | |||
682 | /* client uses this to modify the format type of an port */ | ||
683 | case OMX_IndexParamVideoPortFormat : | ||
684 | OSAL_Info("In OMX_IndexParamVideoPortFormat"); | ||
685 | /* SetParameter can be invoked only when the comp is in loaded or on a disabled port */ | ||
686 | /* Check for the correct nSize & nVersion information */ | ||
687 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError); | ||
688 | pVideoPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct; | ||
689 | nPortIndex = pVideoPortParams->nPortIndex; | ||
690 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
691 | nLCurState = pH264VEComp->sBase.tCurState; | ||
692 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
693 | OMX_CHECK((nLCurState == OMX_StateLoaded) || | ||
694 | (pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.bEnabled == OMX_FALSE), | ||
695 | OMX_ErrorIncorrectStateOperation); | ||
696 | /* Specifying the Video port format type params */ | ||
697 | if( nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex ) { | ||
698 | pLocalPortDef = &(pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef); | ||
699 | if((pLocalPortDef->format.video.xFramerate != pVideoPortParams->xFramerate) || | ||
700 | (pLocalPortDef->format.video.eColorFormat != pVideoPortParams->eColorFormat)) { | ||
701 | SET_H264CODEC_CHROMAFORMAT(pLocalPortDef, pH264VEComp, eError); | ||
702 | |||
703 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
704 | /*Set the Codec Params accordingly*/ | ||
705 | pLocalPortDef->format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; | ||
706 | pLocalPortDef->format.video.xFramerate = pVideoPortParams->xFramerate; | ||
707 | pLocalPortDef->format.video.eColorFormat = pVideoPortParams->eColorFormat; | ||
708 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = | ||
709 | (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate >> 16) * 1000; | ||
710 | bLCodecCreateFlag = OMX_TRUE; | ||
711 | } | ||
712 | } else if( nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex ) { | ||
713 | pLocalPortDef = &(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef); | ||
714 | /*set the corresponding Portdef fields*/ | ||
715 | if((pLocalPortDef->format.video.xFramerate != pVideoPortParams->xFramerate) || | ||
716 | (pLocalPortDef->format.video.eCompressionFormat != pVideoPortParams->eCompressionFormat)) { | ||
717 | if( pVideoPortParams->xFramerate != 0 ) { | ||
718 | OSAL_ErrorTrace("Non-zero framerate rate set on o/p port. Setting frame rate is supported only on i/p port"); | ||
719 | eError = OMX_ErrorUnsupportedSetting; | ||
720 | goto EXIT; | ||
721 | } | ||
722 | pLocalPortDef->format.video.eCompressionFormat = pVideoPortParams->eCompressionFormat; | ||
723 | pLocalPortDef->format.video.xFramerate = pVideoPortParams->xFramerate; | ||
724 | pLocalPortDef->format.video.eColorFormat = OMX_COLOR_FormatUnused; | ||
725 | OMX_CHECK(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat == | ||
726 | OMX_VIDEO_CodingAVC, OMX_ErrorUnsupportedSetting); | ||
727 | bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
728 | } | ||
729 | } else { | ||
730 | eError = OMX_ErrorBadPortIndex; | ||
731 | break; | ||
732 | } | ||
733 | break; | ||
734 | |||
735 | /* Client uses this to configure Video Bit rate type and target bit-rate */ | ||
736 | case OMX_IndexParamVideoBitrate : | ||
737 | OSAL_Info("In OMX_IndexParamVideoBitrate"); | ||
738 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
739 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
740 | nLCurState = pH264VEComp->sBase.tCurState; | ||
741 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
742 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
743 | |||
744 | /* Check for the correct nSize & nVersion information */ | ||
745 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_BITRATETYPE, eError); | ||
746 | if(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
747 | /*check for the rateControlPreset can be set only when it is IVIDEO_USER_DEFINED*/ | ||
748 | if( pH264VEComp->pVidEncStaticParams->videnc2Params.rateControlPreset != IVIDEO_USER_DEFINED ) { | ||
749 | OSAL_ErrorTrace("Rate control preset is not set to User defined"); | ||
750 | eError = OMX_ErrorUnsupportedSetting; | ||
751 | goto EXIT; | ||
752 | } | ||
753 | /*Set the Codec Rate Control Algorithm: */ | ||
754 | SET_H264CODEC_RC_ALG(pParamStruct, pH264VEComp, eError); | ||
755 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
756 | /*Set the Preset to User Defined*/ | ||
757 | if((((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->eControlRate) != OMX_Video_ControlRateVariable ) { | ||
758 | pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset = 1; //UserDefined | ||
759 | } | ||
760 | eError = OMXH264VE_CheckBitRateCap(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate, hComponent); | ||
761 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
762 | /*Set the Codec Target Bit Rate: from the Codec Dynamic Params*/ | ||
763 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = | ||
764 | ((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate; | ||
765 | |||
766 | if (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate < OMX_H264VE_MIN_BITRATE) { | ||
767 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_MIN_BITRATE; | ||
768 | } | ||
769 | |||
770 | /*Update the output port bit rate as well...for the get param to reflect the proper values*/ | ||
771 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate = | ||
772 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate; | ||
773 | } else { | ||
774 | eError = OMX_ErrorBadPortIndex; | ||
775 | } | ||
776 | break; | ||
777 | |||
778 | /* Client uses this to configure AVC structure Parameters*/ | ||
779 | case OMX_IndexParamVideoAvc : | ||
780 | OSAL_Info("In OMX_IndexParamVideoAvc"); | ||
781 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
782 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
783 | nLCurState = pH264VEComp->sBase.tCurState; | ||
784 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
785 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
786 | |||
787 | /* Check for the correct nSize & nVersion information */ | ||
788 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError); | ||
789 | if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
790 | /*Set the Codec Profile */ | ||
791 | SET_H264CODEC_PROFILE(pParamStruct, pH264VEComp, eError); | ||
792 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
793 | |||
794 | /*Set the Codec level */ | ||
795 | SET_H264CODEC_LEVEL(pParamStruct, pH264VEComp, eError); | ||
796 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
797 | |||
798 | eError = OMXH264VE_CheckBitRateCap(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate, hComponent); | ||
799 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
800 | |||
801 | SET_H264CODEC_PARAMS_FROM_AVC(pParamStruct, pH264VEComp); | ||
802 | |||
803 | /*Set the LoopFilter mode */ | ||
804 | SET_H264CODEC_LFMODE(pParamStruct, pH264VEComp, eError); | ||
805 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
806 | |||
807 | /*depending on the interframe interval (nBframes supported) update the buffer requirements */ | ||
808 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin = | ||
809 | pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval; | ||
810 | if( pH264VEComp->bSetParamInputIsDone == OMX_TRUE ) { | ||
811 | if((pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual) < | ||
812 | (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin)) { | ||
813 | eError=OMX_ErrorBadParameter; | ||
814 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual = | ||
815 | pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval; | ||
816 | OSAL_ErrorTrace("need to set the no of buffers properly (buffactual < min requirement)"); | ||
817 | goto EXIT; | ||
818 | } | ||
819 | } else { | ||
820 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual = | ||
821 | pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval; | ||
822 | } | ||
823 | OSAL_Info("input port buff actual =%d", pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual); | ||
824 | } else { | ||
825 | eError = OMX_ErrorBadPortIndex; | ||
826 | } | ||
827 | break; | ||
828 | |||
829 | case OMX_IndexParamVideoMotionVector : | ||
830 | OSAL_Info("In OMX_IndexParamVideoMotionVector"); | ||
831 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
832 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
833 | nLCurState = pH264VEComp->sBase.tCurState; | ||
834 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
835 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
836 | /* Check for the correct nSize & nVersion information */ | ||
837 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MOTIONVECTORTYPE, eError); | ||
838 | if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
839 | /*Get the MV Accuracy from Codec Dynamic Params*/ | ||
840 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy = | ||
841 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->eAccuracy; | ||
842 | /*Number of MVs depend on the min Block size selected*/ | ||
843 | if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bFourMV ) { | ||
844 | pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8; | ||
845 | pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8; | ||
846 | } else { | ||
847 | pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_16x16; | ||
848 | pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_16x16; | ||
849 | } | ||
850 | /*Set the Search Range for P Frame*/ | ||
851 | pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorP = | ||
852 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange; | ||
853 | pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerP = | ||
854 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange; | ||
855 | /*Set the Search Range for B Frame*/ | ||
856 | pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorB = | ||
857 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange; | ||
858 | pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerB = | ||
859 | OMX_H264VE_DEFAULT_VERSEARCH_BFRAME; /*the only supported value by codec*/ | ||
860 | |||
861 | /*Update the corresponding Dynamic params also*/ | ||
862 | /*Set the Search Range for P Frame*/ | ||
863 | pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeHorP = | ||
864 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange; | ||
865 | pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeVerP = | ||
866 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange; | ||
867 | /*Set the Search Range for B Frame*/ | ||
868 | pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeHorB = | ||
869 | ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange; | ||
870 | pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeVerB = | ||
871 | OMX_H264VE_DEFAULT_VERSEARCH_BFRAME; /*the only supported value by codec*/ | ||
872 | pH264VEComp->pVidEncStaticParams->interCodingParams.interCodingPreset = 1; //User Defined | ||
873 | } else { | ||
874 | eError = OMX_ErrorBadPortIndex; | ||
875 | } | ||
876 | break; | ||
877 | |||
878 | case OMX_IndexParamVideoQuantization : | ||
879 | OSAL_Info("In OMX_IndexParamVideoQuantization"); | ||
880 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
881 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
882 | nLCurState = pH264VEComp->sBase.tCurState; | ||
883 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
884 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
885 | /* Check for the correct nSize & nVersion information */ | ||
886 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_QUANTIZATIONTYPE, eError); | ||
887 | if(((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
888 | pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset = | ||
889 | IH264_RATECONTROLPARAMS_USERDEFINED; | ||
890 | pH264VEComp->pVidEncStaticParams->rateControlParams.qpI = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI; | ||
891 | pH264VEComp->pVidEncStaticParams->rateControlParams.qpP = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP; | ||
892 | (pH264VEComp->pVidEncStaticParams->rateControlParams.qpOffsetB) = | ||
893 | ((((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB) - | ||
894 | (((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP)); | ||
895 | |||
896 | /*Update the corresponding Dynamic params also*/ | ||
897 | pH264VEComp->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset = | ||
898 | IH264_RATECONTROLPARAMS_USERDEFINED; | ||
899 | pH264VEComp->pVidEncDynamicParams->rateControlParams.qpI = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI; | ||
900 | pH264VEComp->pVidEncDynamicParams->rateControlParams.qpP = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP; | ||
901 | (pH264VEComp->pVidEncDynamicParams->rateControlParams.qpOffsetB) = | ||
902 | ((((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB) - | ||
903 | (((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP)); | ||
904 | } else { | ||
905 | eError = OMX_ErrorBadPortIndex; | ||
906 | } | ||
907 | break; | ||
908 | |||
909 | case OMX_IndexParamVideoSliceFMO : | ||
910 | OSAL_Info("In OMX_IndexParamVideoSliceFMO"); | ||
911 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
912 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
913 | nLCurState = pH264VEComp->sBase.tCurState; | ||
914 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
915 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
916 | /* Check for the correct nSize & nVersion information */ | ||
917 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCSLICEFMO, eError); | ||
918 | if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
919 | pH264VEComp->pVidEncStaticParams->fmoCodingParams.numSliceGroups = | ||
920 | ((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nNumSliceGroups; | ||
921 | /*Set the slicegrp type*/ | ||
922 | SET_H264CODEC_FMO_SLIGRPMAPTYPE(pParamStruct, pH264VEComp, eError); | ||
923 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
924 | |||
925 | /*Set the slicemode*/ | ||
926 | SET_H264CODEC_SLICEMODE(pParamStruct, pH264VEComp, eError); | ||
927 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
928 | |||
929 | /*Update the corresponding Dynamic params also*/ | ||
930 | pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode = | ||
931 | pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode; | ||
932 | } else { | ||
933 | eError = OMX_ErrorBadPortIndex; | ||
934 | } | ||
935 | break; | ||
936 | |||
937 | case OMX_IndexParamVideoIntraRefresh : | ||
938 | OSAL_Info("In OMX_IndexParamVideoIntraRefresh"); | ||
939 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
940 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
941 | nLCurState = pH264VEComp->sBase.tCurState; | ||
942 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
943 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
944 | |||
945 | /* Check for the correct nSize & nVersion information */ | ||
946 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_INTRAREFRESHTYPE, eError); | ||
947 | if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
948 | //SET_H264CODEC_INTRAREFRESHMODE(pParamStruct, pH264VEComp, eError); | ||
949 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
950 | } else { | ||
951 | eError = OMX_ErrorBadPortIndex; | ||
952 | } | ||
953 | break; | ||
954 | |||
955 | case OMX_IndexParamVideoVBSMC : | ||
956 | OSAL_Info("In OMX_IndexParamVideoVBSMC"); | ||
957 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
958 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
959 | nLCurState = pH264VEComp->sBase.tCurState; | ||
960 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
961 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
962 | |||
963 | /* Check for the correct nSize & nVersion information */ | ||
964 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_VBSMCTYPE, eError); | ||
965 | if(((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
966 | LVBSMC = ((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct); | ||
967 | if((LVBSMC->b16x16 == OMX_TRUE) && (LVBSMC->b16x8 == OMX_TRUE) && (LVBSMC->b8x16 == OMX_TRUE) && | ||
968 | (LVBSMC->b8x8 == OMX_TRUE) && (LVBSMC->b8x4 == OMX_FALSE) && (LVBSMC->b4x8 == OMX_FALSE) && | ||
969 | (LVBSMC->b4x4 == OMX_FALSE)) { | ||
970 | /*4MV case*/ | ||
971 | /*set the same value for both P & B frames prediction*/ | ||
972 | pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8; | ||
973 | pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8; | ||
974 | } else if((LVBSMC->b16x16 == OMX_TRUE) && (LVBSMC->b16x8 == OMX_FALSE) && (LVBSMC->b8x16 == OMX_FALSE) && | ||
975 | (LVBSMC->b8x8 == OMX_FALSE) && (LVBSMC->b8x4 == OMX_FALSE) && (LVBSMC->b4x8 == OMX_FALSE) && | ||
976 | (LVBSMC->b4x4 == OMX_FALSE)) { | ||
977 | /*1 MV case*/ | ||
978 | /*set the same value for both P & B frames prediction*/ | ||
979 | pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_16x16; | ||
980 | pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_16x16; | ||
981 | } else { | ||
982 | eError = OMX_ErrorUnsupportedSetting; | ||
983 | } | ||
984 | pH264VEComp->pVidEncStaticParams->interCodingParams.interCodingPreset = 1; //User Defined | ||
985 | } else { | ||
986 | eError = OMX_ErrorBadPortIndex; | ||
987 | } | ||
988 | break; | ||
989 | |||
990 | case OMX_IndexParamVideoProfileLevelCurrent : | ||
991 | OSAL_Info("In OMX_IndexParamVideoProfileLevelCurrent"); | ||
992 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
993 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
994 | nLCurState = pH264VEComp->sBase.tCurState; | ||
995 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
996 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
997 | |||
998 | /* Check for the correct nSize & nVersion information */ | ||
999 | OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError); | ||
1000 | if(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1001 | /*Set the Codec Profile */ | ||
1002 | LAVCParams->eProfile = (OMX_VIDEO_AVCPROFILETYPE)((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile; | ||
1003 | SET_H264CODEC_PROFILE(LAVCParams, pH264VEComp, eError); | ||
1004 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
1005 | |||
1006 | /*Set the Codec level */ | ||
1007 | LAVCParams->eLevel = (OMX_VIDEO_AVCLEVELTYPE)((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel; | ||
1008 | SET_H264CODEC_LEVEL(LAVCParams, pH264VEComp, eError); | ||
1009 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
1010 | } else { | ||
1011 | eError = OMX_ErrorBadPortIndex; | ||
1012 | } | ||
1013 | break; | ||
1014 | |||
1015 | case OMX_IndexParamStandardComponentRole : | ||
1016 | /*Nothing to do Right Now As the Component supports only one Role: AVC*/ | ||
1017 | /*if it suppots multiple roles then need to set the params (Component Pvt, Codec Create & Dynamic acordingly*/ | ||
1018 | break; | ||
1019 | case (OMX_INDEXTYPE)OMX_TI_IndexEncoderReceiveMetadataBuffers: | ||
1020 | /* SetParameter can be invoked only when the comp is in loaded or on disabled port */ | ||
1021 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1022 | nLCurState = pH264VEComp->sBase.tCurState; | ||
1023 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1024 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
1025 | |||
1026 | struct OMX_StoreMetaDataInBuffersParams *meta = (OMX_StoreMetaDataInBuffersParams *)pParamStruct; | ||
1027 | nPortIndex = meta->nPortIndex; | ||
1028 | |||
1029 | if (meta->bStoreMetaData) { | ||
1030 | if (nPortIndex == OMX_H264VE_INPUT_PORT) { | ||
1031 | hw_module_t const* module = NULL; | ||
1032 | eError = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); | ||
1033 | if (eError == 0) { | ||
1034 | pH264VEComp->hCC = (void *) ((IMG_gralloc_module_public_t const *)module); | ||
1035 | pH264VEComp->bInputMetaDataBufferMode = OMX_TRUE; | ||
1036 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = sizeof(OMX_MetaDataBuffer); | ||
1037 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride = | ||
1038 | ALIGN(pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride, HW_ALIGN); | ||
1039 | } | ||
1040 | } else { | ||
1041 | eError = OMX_ErrorUnsupportedSetting; | ||
1042 | } | ||
1043 | } | ||
1044 | break; | ||
1045 | |||
1046 | /* redirects the call to "OMXBase_SetParameter" which supports standard comp indexes */ | ||
1047 | default : | ||
1048 | OSAL_Info("In Default: Call to BASE Set Parameter"); | ||
1049 | eError = OMXBase_SetParameter(hComponent, nParamIndex, pParamStruct); | ||
1050 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
1051 | break; | ||
1052 | } | ||
1053 | |||
1054 | if( bLCodecCreateFlag == OMX_TRUE ) { | ||
1055 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1056 | pH264VEComp->bCodecCreateSettingsChange=OMX_TRUE; | ||
1057 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1058 | } | ||
1059 | if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) { | ||
1060 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1061 | pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_OMX; | ||
1062 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1063 | } | ||
1064 | |||
1065 | EXIT: | ||
1066 | |||
1067 | if( bAllocateLocalAVC ) { | ||
1068 | OSAL_Free(LAVCParams); | ||
1069 | } | ||
1070 | |||
1071 | return (eError); | ||
1072 | } | ||
1073 | |||
1074 | |||
1075 | static OMX_ERRORTYPE OMXH264VE_GetConfig(OMX_HANDLETYPE hComponent, | ||
1076 | OMX_INDEXTYPE nIndex, | ||
1077 | OMX_PTR pConfigData) | ||
1078 | { | ||
1079 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1080 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
1081 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
1082 | OMX_STATETYPE nLCurState; | ||
1083 | |||
1084 | /* Check the input params */ | ||
1085 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
1086 | OMX_CHECK(pConfigData != NULL, OMX_ErrorBadParameter); | ||
1087 | |||
1088 | /*initialize the component handle and component pvt handle*/ | ||
1089 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
1090 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
1091 | |||
1092 | /* GetConfig can't be invoked when the comp is in Invalid state */ | ||
1093 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1094 | nLCurState = pH264VEComp->sBase.tCurState; | ||
1095 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1096 | OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation); | ||
1097 | |||
1098 | /* Take care of Supported Indexes over here */ | ||
1099 | switch( nIndex ) { | ||
1100 | /* Client uses this to retrieve the bitrate structure*/ | ||
1101 | case OMX_IndexConfigVideoBitrate : | ||
1102 | OSAL_Info("In OMX_IndexConfigVideoBitrate"); | ||
1103 | /*required for Standard Video Encoder as per Spec*/ | ||
1104 | /* Check for the correct nSize & nVersion information */ | ||
1105 | OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_BITRATETYPE, eError); | ||
1106 | if(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1107 | ((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate = | ||
1108 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate; | ||
1109 | } else { | ||
1110 | eError = OMX_ErrorBadPortIndex; | ||
1111 | } | ||
1112 | break; | ||
1113 | |||
1114 | case OMX_IndexConfigVideoFramerate : | ||
1115 | OSAL_Info("In OMX_IndexConfigVideoFramerate"); | ||
1116 | /*required for Standard Video Encoder as per Spec*/ | ||
1117 | OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_FRAMERATETYPE, eError); | ||
1118 | if(((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_INPUT_PORT ) { | ||
1119 | ((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate = | ||
1120 | (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate << 16) / 1000; /*Q16 format*/ | ||
1121 | } else { | ||
1122 | eError = OMX_ErrorBadPortIndex; | ||
1123 | } | ||
1124 | break; | ||
1125 | |||
1126 | /* Client uses this to configure the intra refresh period */ | ||
1127 | case OMX_IndexConfigVideoAVCIntraPeriod : | ||
1128 | OSAL_Info("In OMX_IndexConfigVideoAVCIntraPeriod"); | ||
1129 | /* Check for the correct nSize & nVersion information */ | ||
1130 | OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_AVCINTRAPERIOD, eError); | ||
1131 | if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1132 | ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod = pH264VEComp->pVidEncStaticParams->IDRFrameInterval; | ||
1133 | ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPFrames = | ||
1134 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval; | ||
1135 | } else { | ||
1136 | eError = OMX_ErrorBadPortIndex; | ||
1137 | } | ||
1138 | break; | ||
1139 | |||
1140 | case OMX_IndexConfigVideoIntraVOPRefresh : | ||
1141 | OSAL_Info("In OMX_IndexConfigVideoIntraVOPRefresh"); | ||
1142 | /* Check for the correct nSize & nVersion information */ | ||
1143 | OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_INTRAREFRESHVOPTYPE, eError); | ||
1144 | if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1145 | ((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->IntraRefreshVOP = | ||
1146 | ((pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame == IVIDEO_I_FRAME) ? OMX_TRUE : OMX_FALSE); | ||
1147 | } else { | ||
1148 | eError = OMX_ErrorBadPortIndex; | ||
1149 | } | ||
1150 | break; | ||
1151 | |||
1152 | case OMX_IndexConfigVideoNalSize : | ||
1153 | OSAL_Info("In OMX_IndexConfigVideoNalSize"); | ||
1154 | /* Check for the correct nSize & nVersion information */ | ||
1155 | OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_NALSIZE, eError); | ||
1156 | if(((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1157 | if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) { | ||
1158 | ((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nNaluBytes = | ||
1159 | pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize; | ||
1160 | } else { | ||
1161 | eError = OMX_ErrorUnsupportedSetting; | ||
1162 | } | ||
1163 | } else { | ||
1164 | eError = OMX_ErrorBadPortIndex; | ||
1165 | } | ||
1166 | break; | ||
1167 | |||
1168 | case OMX_IndexConfigPriorityMgmt : | ||
1169 | OSAL_Info("In OMX_IndexConfigPriorityMgmt"); | ||
1170 | |||
1171 | default : | ||
1172 | OSAL_Info("In Default: Call to BASE GetConfig"); | ||
1173 | eError = OMXBase_GetConfig(hComponent, nIndex, pConfigData); | ||
1174 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
1175 | break; | ||
1176 | } | ||
1177 | |||
1178 | EXIT: | ||
1179 | return (eError); | ||
1180 | |||
1181 | } | ||
1182 | |||
1183 | |||
1184 | static OMX_ERRORTYPE OMXH264VE_SetConfig(OMX_HANDLETYPE hComponent, | ||
1185 | OMX_INDEXTYPE nIndex, | ||
1186 | OMX_PTR pConfigData) | ||
1187 | { | ||
1188 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1189 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
1190 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
1191 | OMX_STATETYPE nLCurState; | ||
1192 | OMX_BOOL bLCodecCreateFlag=OMX_FALSE; | ||
1193 | OMX_U32 tStatus; | ||
1194 | PARAMS_UPDATE_STATUS bLCallxDMSetParams=NO_PARAM_CHANGE; | ||
1195 | |||
1196 | /* Check the input params */ | ||
1197 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
1198 | OMX_CHECK(pConfigData != NULL, OMX_ErrorBadParameter); | ||
1199 | |||
1200 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
1201 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
1202 | |||
1203 | /* SetConfig can't be invoked when the comp is in Invalid state */ | ||
1204 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1205 | nLCurState = pH264VEComp->sBase.tCurState; | ||
1206 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1207 | OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation); | ||
1208 | |||
1209 | /* Take care of Supported Indices over here */ | ||
1210 | switch( nIndex ) { | ||
1211 | case OMX_IndexConfigVideoBitrate : | ||
1212 | OSAL_Info("In OMX_IndexConfigVideoBitrate"); | ||
1213 | /*required for Standard Video Encoder as per Spec*/ | ||
1214 | /* Check for the correct nSize & nVersion information */ | ||
1215 | OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_BITRATETYPE, eError); | ||
1216 | if(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1217 | eError = OMXH264VE_CheckBitRateCap(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate, hComponent); | ||
1218 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting); | ||
1219 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = | ||
1220 | ((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate; | ||
1221 | |||
1222 | if (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate < OMX_H264VE_MIN_BITRATE) { | ||
1223 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_MIN_BITRATE; | ||
1224 | } | ||
1225 | |||
1226 | /*Update the output port bit rate as well...for the get param to reflect the proper values*/ | ||
1227 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate = | ||
1228 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate; | ||
1229 | /*set the HRD biffer size appropriately*/ | ||
1230 | if( pH264VEComp->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY ) { | ||
1231 | pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize = | ||
1232 | (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2; | ||
1233 | } else { | ||
1234 | pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize = | ||
1235 | (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate); | ||
1236 | } | ||
1237 | bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX; | ||
1238 | |||
1239 | } else { | ||
1240 | eError = OMX_ErrorBadPortIndex; | ||
1241 | } | ||
1242 | break; | ||
1243 | |||
1244 | case OMX_IndexConfigVideoFramerate : | ||
1245 | OSAL_Info("In OMX_IndexConfigVideoFramerate"); | ||
1246 | /*required for Standard Video Encoder as per Spec*/ | ||
1247 | OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_FRAMERATETYPE, eError); | ||
1248 | if(((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_INPUT_PORT ) { | ||
1249 | if( pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate != | ||
1250 | (((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate)) { | ||
1251 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = | ||
1252 | ((((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate) >> 16) * 1000; | ||
1253 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate = | ||
1254 | (((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate); | ||
1255 | bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX; | ||
1256 | } | ||
1257 | } else { | ||
1258 | eError = OMX_ErrorBadPortIndex; | ||
1259 | } | ||
1260 | break; | ||
1261 | |||
1262 | case OMX_IndexConfigVideoAVCIntraPeriod : | ||
1263 | OSAL_Info("In OMX_IndexConfigVideoAVCIntraPeriod"); | ||
1264 | /* Check for the correct nSize & nVersion information */ | ||
1265 | OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_AVCINTRAPERIOD, eError); | ||
1266 | if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1267 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1268 | nLCurState = pH264VEComp->sBase.tCurState; | ||
1269 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1270 | /*If Client want to set the IDR frame Interval */ | ||
1271 | if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod != 1 ) { | ||
1272 | /*IDR frame Interval is other than the Component default settings - | ||
1273 | it is possible only when the component is in loaded state*/ | ||
1274 | OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation); | ||
1275 | pH264VEComp->pVidEncStaticParams->IDRFrameInterval = ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod; | ||
1276 | bLCodecCreateFlag = OMX_TRUE; | ||
1277 | } | ||
1278 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval = | ||
1279 | ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPFrames; | ||
1280 | bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
1281 | } else { | ||
1282 | eError = OMX_ErrorBadPortIndex; | ||
1283 | } | ||
1284 | break; | ||
1285 | |||
1286 | case OMX_IndexConfigVideoIntraVOPRefresh : | ||
1287 | OSAL_Info("In OMX_IndexConfigVideoIntraVOPRefresh"); | ||
1288 | /* Check for the correct nSize & nVersion information */ | ||
1289 | OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_INTRAREFRESHVOPTYPE, eError); | ||
1290 | if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1291 | if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->IntraRefreshVOP ) { | ||
1292 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_IDR_FRAME; | ||
1293 | } else { | ||
1294 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_NA_FRAME; | ||
1295 | } | ||
1296 | bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
1297 | } else { | ||
1298 | eError = OMX_ErrorBadPortIndex; | ||
1299 | } | ||
1300 | break; | ||
1301 | |||
1302 | case OMX_IndexConfigVideoNalSize : | ||
1303 | OSAL_Info("In OMX_IndexConfigVideoNalSize"); | ||
1304 | /* Check for the correct nSize & nVersion information */ | ||
1305 | OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_NALSIZE, eError); | ||
1306 | if(((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
1307 | if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT ) { | ||
1308 | pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES; | ||
1309 | pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_USERDEFINED; | ||
1310 | } | ||
1311 | if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) { | ||
1312 | OMX_CHECK(pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType != IVIDEO_INTERLACED, | ||
1313 | OMX_ErrorUnsupportedSetting); | ||
1314 | OMX_CHECK(pH264VEComp->pVidEncStaticParams->entropyCodingMode != IH264_ENTROPYCODING_CABAC, | ||
1315 | OMX_ErrorUnsupportedSetting); | ||
1316 | OMX_CHECK(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputWidth >= 128, | ||
1317 | OMX_ErrorUnsupportedSetting); | ||
1318 | OMX_CHECK(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval == 1, | ||
1319 | OMX_ErrorUnsupportedSetting); | ||
1320 | pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize = | ||
1321 | ((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nNaluBytes; | ||
1322 | |||
1323 | bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
1324 | if((nLCurState == OMX_StateLoaded) && (eError == OMX_ErrorNone)) { | ||
1325 | if( pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT ) { | ||
1326 | pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES; | ||
1327 | pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_USERDEFINED; | ||
1328 | } | ||
1329 | pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceUnitSize = | ||
1330 | pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize; | ||
1331 | } | ||
1332 | } else { | ||
1333 | eError = OMX_ErrorUnsupportedSetting; | ||
1334 | } | ||
1335 | } else { | ||
1336 | eError = OMX_ErrorBadPortIndex; | ||
1337 | } | ||
1338 | break; | ||
1339 | |||
1340 | case OMX_IndexConfigPriorityMgmt : | ||
1341 | OSAL_ErrorTrace("In OMX_IndexConfigPriorityMgmt"); | ||
1342 | |||
1343 | break; | ||
1344 | |||
1345 | default : | ||
1346 | OSAL_Info("In Default: Call to BASE SetConfig"); | ||
1347 | eError = OMXBase_SetConfig(hComponent, nIndex, pConfigData); | ||
1348 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
1349 | break; | ||
1350 | } | ||
1351 | |||
1352 | if( bLCodecCreateFlag == OMX_TRUE ) { | ||
1353 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1354 | pH264VEComp->bCodecCreateSettingsChange = OMX_TRUE; | ||
1355 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1356 | } | ||
1357 | |||
1358 | if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) { | ||
1359 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1360 | pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
1361 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1362 | } | ||
1363 | |||
1364 | EXIT: | ||
1365 | |||
1366 | return (eError); | ||
1367 | } | ||
1368 | |||
1369 | |||
1370 | static OMX_ERRORTYPE OMXH264VE_CommandNotify(OMX_HANDLETYPE hComponent, | ||
1371 | OMX_COMMANDTYPE Cmd, | ||
1372 | OMX_U32 nParam, | ||
1373 | OMX_PTR pCmdData) | ||
1374 | { | ||
1375 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1376 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
1377 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
1378 | OMX_U32 i; | ||
1379 | OMX_STATETYPE tCurState, tNewState; | ||
1380 | XDAS_Int32 retval = 0; | ||
1381 | (void)pCmdData; | ||
1382 | |||
1383 | /* Check the input parameters */ | ||
1384 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
1385 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
1386 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
1387 | |||
1388 | |||
1389 | /* Complete all the operations like Alg Instance create or | ||
1390 | * allocation of any resources which are specific to the Component, Notify this | ||
1391 | * Asynchronous event completion to the Base Comp via ReturnEventNotify call*/ | ||
1392 | |||
1393 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1394 | tCurState = pH264VEComp->sBase.tCurState; | ||
1395 | tNewState = pH264VEComp->sBase.tNewState; | ||
1396 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1397 | |||
1398 | switch( Cmd ) { | ||
1399 | case OMX_CommandStateSet : | ||
1400 | /* Incase if the comp is moving from loaded to idle */ | ||
1401 | if((tCurState == OMX_StateLoaded) && (tNewState == OMX_StateIdle)) { | ||
1402 | OSAL_Info("In OMX_CommandStateSet:Loaded to Idle"); | ||
1403 | eError = OMXH264VE_SetEncCodecReady(hComponent); | ||
1404 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1405 | } | ||
1406 | |||
1407 | /* Incase if the comp is moving from idle to executing, process buffers if an supplier port */ | ||
1408 | else if(((tCurState == OMX_StateIdle) && (tNewState == OMX_StateExecuting)) || | ||
1409 | ((tCurState == OMX_StateIdle) && (tNewState == OMX_StatePause))) { | ||
1410 | OSAL_Info("In OMX_CommandStateSet:Idle to Executing"); | ||
1411 | |||
1412 | pH264VEComp->pCodecInBufferArray = (OMX_BUFFERHEADERTYPE **)OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) * | ||
1413 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual); | ||
1414 | OMX_CHECK(pH264VEComp->pCodecInBufferArray != NULL, OMX_ErrorInsufficientResources); | ||
1415 | /*allocate the memory for the bufferhdrs*/ | ||
1416 | for (i = 0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) { | ||
1417 | pH264VEComp->pCodecInBufferArray[i] = NULL; | ||
1418 | } | ||
1419 | |||
1420 | pH264VEComp->pCodecInBufferBackupArray = (OMXBase_BufHdrPvtData *)OSAL_Malloc(sizeof(OMXBase_BufHdrPvtData) * | ||
1421 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual); | ||
1422 | |||
1423 | OMX_CHECK(pH264VEComp->pCodecInBufferBackupArray != NULL, OMX_ErrorInsufficientResources); | ||
1424 | } | ||
1425 | /* Incase If the comp is moving to Idle from executing, return all the buffers back to the IL client*/ | ||
1426 | else if(((tCurState == OMX_StateExecuting) && (tNewState == OMX_StateIdle)) || | ||
1427 | ((tCurState == OMX_StatePause) && (tNewState == OMX_StateIdle))) { | ||
1428 | OSAL_Info("In OMX_CommandStateSet:Executing/Pause to Idle"); | ||
1429 | |||
1430 | /*Flushout all the locked buffers*/ | ||
1431 | eError=OMXH264VE_FLUSHLockedBuffers(pHandle); | ||
1432 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1433 | if( pH264VEComp->bCodecCreate ) { | ||
1434 | /*Codec Call: control call with command XDM_RESET*/ | ||
1435 | OSAL_Info("Call Codec_RESET "); | ||
1436 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET, | ||
1437 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
1438 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
1439 | if( retval != VIDENC2_EOK ) { | ||
1440 | OSAL_ErrorTrace("Got error from the Codec_RESET call"); | ||
1441 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
1442 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1443 | } | ||
1444 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1445 | } | ||
1446 | |||
1447 | if( pH264VEComp->pCodecInBufferArray ) { | ||
1448 | OSAL_Free(pH264VEComp->pCodecInBufferArray); | ||
1449 | } | ||
1450 | |||
1451 | if (pH264VEComp->bInputMetaDataBufferMode && pH264VEComp->pBackupBuffers) { | ||
1452 | for (i = 0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++) { | ||
1453 | if(pH264VEComp->pBackupBuffers[i]) { | ||
1454 | //unregister this buffer with DRM | ||
1455 | dce_buf_unlock(1, (size_t *)&(pH264VEComp->pCodecInBufferBackupArray[i].sMemHdr[0].dma_buf_fd)); | ||
1456 | pH264VEComp->mAllocDev->free(pH264VEComp->mAllocDev, (buffer_handle_t)(pH264VEComp->pBackupBuffers[i])); | ||
1457 | pH264VEComp->pBackupBuffers[i] = NULL; | ||
1458 | } | ||
1459 | } | ||
1460 | OSAL_Free(pH264VEComp->pBackupBuffers); | ||
1461 | pH264VEComp->pBackupBuffers = NULL; | ||
1462 | } | ||
1463 | |||
1464 | if( pH264VEComp->pCodecInBufferBackupArray ) { | ||
1465 | OSAL_Free(pH264VEComp->pCodecInBufferBackupArray); | ||
1466 | } | ||
1467 | |||
1468 | if(pH264VEComp && pH264VEComp->mAllocDev) { | ||
1469 | gralloc_close(pH264VEComp->mAllocDev); | ||
1470 | pH264VEComp->mAllocDev = NULL; | ||
1471 | } | ||
1472 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1473 | pH264VEComp->nCodecConfigSize = 0; | ||
1474 | pH264VEComp->bAfterGenHeader = OMX_FALSE; | ||
1475 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1476 | |||
1477 | /* Update the Generate Header Params : to continue with New stream w/o codec create */ | ||
1478 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; | ||
1479 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1480 | pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
1481 | pH264VEComp->bSendCodecConfig = OMX_TRUE; | ||
1482 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1483 | } | ||
1484 | /* State transition from pause to executing state */ | ||
1485 | else if((tCurState == OMX_StatePause) && | ||
1486 | (tNewState == OMX_StateExecuting)) { | ||
1487 | OSAL_Info("In OMX_CommandStateSet:Pause to Executing"); | ||
1488 | } else if((tCurState == OMX_StateExecuting) && | ||
1489 | (tNewState == OMX_StatePause)) { | ||
1490 | } else if((tCurState == OMX_StateIdle) && | ||
1491 | (tNewState == OMX_StateLoaded)) { | ||
1492 | OSAL_Info("In OMX_CommandStateSet:Idle to Loaded"); | ||
1493 | /* Delete the Codec Instance */ | ||
1494 | if( pH264VEComp->bCodecCreate && pH264VEComp->pVidEncHandle) { | ||
1495 | VIDENC2_delete(pH264VEComp->pVidEncHandle); | ||
1496 | pH264VEComp->pVidEncHandle = NULL; | ||
1497 | } | ||
1498 | pH264VEComp->bCodecCreate=OMX_FALSE; | ||
1499 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1500 | pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_OMX; | ||
1501 | pH264VEComp->bSendCodecConfig=OMX_TRUE; | ||
1502 | pH264VEComp->bSetParamInputIsDone = OMX_FALSE; | ||
1503 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1504 | } else if( tNewState == OMX_StateInvalid ) { | ||
1505 | OSAL_Info("In OMX_CommandStateSet:Invalid state"); | ||
1506 | /* Delete the Codec Instance */ | ||
1507 | if( pH264VEComp->bCodecCreate && pH264VEComp->pVidEncHandle) { | ||
1508 | VIDENC2_delete(pH264VEComp->pVidEncHandle); | ||
1509 | pH264VEComp->pVidEncHandle = NULL; | ||
1510 | } | ||
1511 | pH264VEComp->bCodecCreate=OMX_FALSE; | ||
1512 | } | ||
1513 | break; | ||
1514 | |||
1515 | case OMX_CommandFlush : | ||
1516 | OSAL_Info("In OMX_CommandFlush"); | ||
1517 | OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)), | ||
1518 | OMX_ErrorBadParameter); | ||
1519 | if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) { | ||
1520 | if( pH264VEComp->bCodecCreate ) { | ||
1521 | /*Codec Call: control call with command XDM_FLUSH*/ | ||
1522 | OSAL_Info("Call CodecFlush "); | ||
1523 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH, | ||
1524 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
1525 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
1526 | if( retval != VIDENC2_EOK ) { | ||
1527 | OSAL_ErrorTrace("Got error from the CodecFlush call"); | ||
1528 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
1529 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1530 | } | ||
1531 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1532 | } | ||
1533 | /*Flushout all the locked buffers*/ | ||
1534 | eError = OMXH264VE_FLUSHLockedBuffers(pHandle); | ||
1535 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1536 | /* Reset the Codec : to continue with New stream w/o codec create */ | ||
1537 | if( pH264VEComp->bCodecCreate ) { | ||
1538 | /*Codec Call: control call with command XDM_RESET*/ | ||
1539 | OSAL_Info("Call Codec_RESET "); | ||
1540 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET, | ||
1541 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
1542 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
1543 | if( retval != VIDENC2_EOK ) { | ||
1544 | OSAL_ErrorTrace("Got error from the Codec_RESET call"); | ||
1545 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
1546 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1547 | } | ||
1548 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1549 | } | ||
1550 | |||
1551 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; | ||
1552 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1553 | pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
1554 | pH264VEComp->bSendCodecConfig = OMX_TRUE; | ||
1555 | pH264VEComp->nCodecConfigSize = 0; | ||
1556 | pH264VEComp->bAfterGenHeader = OMX_FALSE; | ||
1557 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1558 | } | ||
1559 | if(nParam == OMX_H264VE_OUTPUT_PORT) { | ||
1560 | /*do nothing*/ | ||
1561 | } | ||
1562 | break; | ||
1563 | |||
1564 | case OMX_CommandPortDisable : | ||
1565 | OSAL_Info("In OMX_CommandPortDisable"); | ||
1566 | OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)), | ||
1567 | OMX_ErrorBadParameter); | ||
1568 | if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) { | ||
1569 | if( pH264VEComp->bCodecCreate ) { | ||
1570 | /*control call with command XDM_FLUSH*/ | ||
1571 | OSAL_Info("Call CodecFlush "); | ||
1572 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH, | ||
1573 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
1574 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
1575 | if( retval != VIDENC2_EOK ) { | ||
1576 | OSAL_ErrorTrace("Got error from the CodecFlush call"); | ||
1577 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
1578 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1579 | } | ||
1580 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1581 | } | ||
1582 | /*Flushout all the locked buffers*/ | ||
1583 | eError= OMXH264VE_FLUSHLockedBuffers(pHandle); | ||
1584 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1585 | /* Reset the Codec : to continue with New stream w/o codec create */ | ||
1586 | if( pH264VEComp->bCodecCreate ) { | ||
1587 | /*Codec Call: control call with command XDM_RESET*/ | ||
1588 | OSAL_Info("Call Codec_RESET "); | ||
1589 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET, | ||
1590 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
1591 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
1592 | if( retval != VIDENC2_EOK ) { | ||
1593 | OSAL_ErrorTrace("Got error from the Codec_RESET call"); | ||
1594 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
1595 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1596 | } | ||
1597 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1598 | } | ||
1599 | pH264VEComp->bInputPortDisable = OMX_TRUE; | ||
1600 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; | ||
1601 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1602 | pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
1603 | pH264VEComp->bSendCodecConfig = OMX_TRUE; | ||
1604 | pH264VEComp->bSetParamInputIsDone = OMX_FALSE; | ||
1605 | pH264VEComp->nCodecConfigSize = 0; | ||
1606 | pH264VEComp->bAfterGenHeader = OMX_FALSE; | ||
1607 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1608 | } | ||
1609 | if( nParam == OMX_H264VE_OUTPUT_PORT ) { | ||
1610 | /*do nothing*/ | ||
1611 | } | ||
1612 | break; | ||
1613 | |||
1614 | case OMX_CommandPortEnable : | ||
1615 | OSAL_Info("In OMX_CommandPortEnable"); | ||
1616 | /*base is taking care of allocating all the resources*/ | ||
1617 | OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)), | ||
1618 | OMX_ErrorBadParameter); | ||
1619 | if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) { | ||
1620 | if((pH264VEComp->bCodecCreate) & (pH264VEComp->bInputPortDisable) & (pH264VEComp->bCodecCreateSettingsChange)) { | ||
1621 | /* Delete the old Codec Instance */ | ||
1622 | if( pH264VEComp->pVidEncHandle ) { | ||
1623 | VIDENC2_delete(pH264VEComp->pVidEncHandle); | ||
1624 | pH264VEComp->pVidEncHandle = NULL; | ||
1625 | } | ||
1626 | |||
1627 | /* Create a New Codec Instance */ | ||
1628 | eError = OMXH264VE_SetEncCodecReady(hComponent); | ||
1629 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1630 | } /*end if codec create*/ | ||
1631 | /*Reset the port disable flag */ | ||
1632 | pH264VEComp->bInputPortDisable = OMX_FALSE; | ||
1633 | } /*end if(i/p or ALL )*/ | ||
1634 | if( nParam == OMX_H264VE_OUTPUT_PORT ) { | ||
1635 | /*do nothing*/ | ||
1636 | } | ||
1637 | break; | ||
1638 | |||
1639 | default : | ||
1640 | OSAL_Info("In Default"); | ||
1641 | eError = OMX_ErrorBadParameter; | ||
1642 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1643 | break; | ||
1644 | } | ||
1645 | |||
1646 | /* Note: Notify this completion to the Base comp via ReturnEventNotify call */ | ||
1647 | OSAL_Info("Notify Base via ReturnEventNotify "); | ||
1648 | eError = pH264VEComp->sBase.fpReturnEventNotify(hComponent, OMX_EventCmdComplete, Cmd, nParam, NULL); | ||
1649 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1650 | |||
1651 | EXIT: | ||
1652 | |||
1653 | return (eError); | ||
1654 | } | ||
1655 | |||
1656 | |||
1657 | static OMX_ERRORTYPE OMXH264VE_DataNotify(OMX_HANDLETYPE hComponent) | ||
1658 | { | ||
1659 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
1660 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
1661 | OMX_COMPONENTTYPE *pComp = NULL; | ||
1662 | OMX_BUFFERHEADERTYPE *pOutBufHeader = NULL; | ||
1663 | OMX_U32 nInMsgCount = 0, nOutMsgCount = 0, i, j; | ||
1664 | XDAS_Int32 retval = 0; | ||
1665 | OMX_STATETYPE tCurState; | ||
1666 | PARAMS_UPDATE_STATUS bLCallxDMSetParams; | ||
1667 | OMX_BOOL bLEOS=OMX_FALSE; | ||
1668 | OMX_BOOL bLCodecFlush=OMX_FALSE; | ||
1669 | OMX_S32 InBufferHdrIndex = -1; | ||
1670 | OMX_U32 LCodecLockedBufferCount = 0; | ||
1671 | OMX_BOOL bLCallCodecProcess = OMX_FALSE; | ||
1672 | OMXBase_CodecConfigBuf AttrParams; | ||
1673 | OMX_BOOL bLSendCodecConfig; | ||
1674 | void *srcPtr = NULL, *dstPtr = NULL; | ||
1675 | OMX_U32 step, stride; | ||
1676 | |||
1677 | /* Check the input parameters */ | ||
1678 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
1679 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
1680 | pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate; | ||
1681 | |||
1682 | /* Strat buffer processing only when the comp is in Executing state and the Port are Enabled*/ | ||
1683 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1684 | tCurState = pH264VEComp->sBase.tCurState; | ||
1685 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1686 | if((tCurState == OMX_StateExecuting) && (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bEnabled) | ||
1687 | && (pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bEnabled)) { | ||
1688 | |||
1689 | eError = pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount); | ||
1690 | OMX_CHECK(((eError == OMX_ErrorNone) || (eError == OMX_TI_WarningEosReceived)), OMX_ErrorInsufficientResources); | ||
1691 | |||
1692 | eError = pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount); | ||
1693 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources); | ||
1694 | |||
1695 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1696 | bLSendCodecConfig = pH264VEComp->bSendCodecConfig; | ||
1697 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1698 | |||
1699 | if( bLSendCodecConfig ) { | ||
1700 | if((nOutMsgCount > 0) && (nInMsgCount > 0)) { | ||
1701 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1702 | bLCallxDMSetParams=pH264VEComp->bCallxDMSetParams; | ||
1703 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1704 | if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) { | ||
1705 | eError = OMXH264VE_SetDynamicParamsToCodec(hComponent); | ||
1706 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1707 | } | ||
1708 | |||
1709 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; | ||
1710 | /* Update the OutBuf details before the Codec Process call */ | ||
1711 | pH264VEComp->pVedEncOutBufs->descs[0].memType = XDM_MEMTYPE_RAW; | ||
1712 | pH264VEComp->pVedEncOutBufs->descs[0].buf = (XDAS_Int8 *)(pH264VEComp->sCodecConfigData.sBuffer); | ||
1713 | pH264VEComp->pVedEncOutBufs->descs[0].bufSize.bytes = SPS_PPS_HEADER_DATA_SIZE; | ||
1714 | |||
1715 | /* Update the InBuf details before the Codec Process call */ | ||
1716 | for( i = 0; i < (OMX_U32)pH264VEComp->pVedEncInBufs->numPlanes; i++ ) { | ||
1717 | pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)(pH264VEComp->pTempBuffer[i]); | ||
1718 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; | ||
1719 | pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = | ||
1720 | (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes); | ||
1721 | } | ||
1722 | |||
1723 | /* Update the InArgs details before the Codec Process call */ | ||
1724 | pH264VEComp->pVidEncInArgs->videnc2InArgs.size = sizeof(IVIDENC2_InArgs); | ||
1725 | pH264VEComp->pVidEncInArgs->videnc2InArgs.control=IVIDENC2_CTRL_NONE; | ||
1726 | pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = 1000; /*to overcome the limitation inside the Codec- codec checks for NULL*/ | ||
1727 | |||
1728 | /* Update the OutArgs details before the Codec Process call */ | ||
1729 | pH264VEComp->pVidEncOutArgs->videnc2OutArgs.size = sizeof(IVIDENC2_OutArgs); | ||
1730 | |||
1731 | /* Call the Codec Process call */ | ||
1732 | eError = OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(hComponent, &retval); | ||
1733 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1734 | |||
1735 | ALOGE("BytesGenerated=%d", (OMX_U32)pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated); | ||
1736 | ALOGE("freed ID=%d", (OMX_U32)pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]); | ||
1737 | |||
1738 | /* Send the Condec Config Data to the Client */ | ||
1739 | AttrParams.sBuffer = pH264VEComp->sCodecConfigData.sBuffer; | ||
1740 | AttrParams.sBuffer->size = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated; | ||
1741 | pH264VEComp->sBase.pPvtData->fpDioControl(pComp, OMX_H264VE_OUTPUT_PORT, OMX_DIO_CtrlCmd_SetCtrlAttribute, &AttrParams); | ||
1742 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_ENCODE_AU; | ||
1743 | |||
1744 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1745 | pH264VEComp->bSendCodecConfig =OMX_FALSE; | ||
1746 | pH264VEComp->nCodecConfigSize = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated; | ||
1747 | pH264VEComp->bAfterGenHeader = OMX_TRUE; | ||
1748 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1749 | |||
1750 | } else { | ||
1751 | goto EXIT; | ||
1752 | } | ||
1753 | } | ||
1754 | |||
1755 | /* check for both input and output */ | ||
1756 | eError=pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount); | ||
1757 | OMX_CHECK(((eError == OMX_ErrorNone) || (eError == OMX_TI_WarningEosReceived)), OMX_ErrorInsufficientResources); | ||
1758 | |||
1759 | eError=pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount); | ||
1760 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources); | ||
1761 | |||
1762 | /* if both are ready-> process data */ | ||
1763 | while(((nInMsgCount > 0) && (nOutMsgCount > 0)) || ((pH264VEComp->bAfterEOSReception) && (nOutMsgCount > 0))) { | ||
1764 | /*dequeue the output buffer*/ | ||
1765 | eError = pH264VEComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR*)(&pOutBufHeader)); | ||
1766 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources); | ||
1767 | ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC; | ||
1768 | |||
1769 | /*branch the control flow based on the Before EOS /After EOS processing*/ | ||
1770 | if( !pH264VEComp->bAfterEOSReception ) { | ||
1771 | OSAL_Info("Before EOS reception Case"); | ||
1772 | /*get the free bufhdr from the inputbufhdrarray*/ | ||
1773 | eError = OMXH264VE_GetNextFreeBufHdr(pComp, &InBufferHdrIndex, OMX_H264VE_INPUT_PORT); | ||
1774 | OMX_CHECK(((InBufferHdrIndex != -1) && (eError == OMX_ErrorNone)), OMX_ErrorInsufficientResources); | ||
1775 | |||
1776 | /*dequeue the input buffer*/ | ||
1777 | eError = pH264VEComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_H264VE_INPUT_PORT, | ||
1778 | (OMX_PTR*)&(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])); | ||
1779 | OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources); | ||
1780 | ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->bufSt = OWNED_BY_CODEC; | ||
1781 | |||
1782 | if((pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])->nFlags & OMX_BUFFERFLAG_EOS ) { | ||
1783 | bLEOS = OMX_TRUE; | ||
1784 | pH264VEComp->bPropagateEOSToOutputBuffer = OMX_TRUE; | ||
1785 | bLCodecFlush = OMX_TRUE; | ||
1786 | } | ||
1787 | |||
1788 | if(((pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])->nFilledLen) == 0 ) { | ||
1789 | /*update the buffer status to free & return the buffer to the client*/ | ||
1790 | ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->bufSt = OWNED_BY_US; | ||
1791 | |||
1792 | pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT, | ||
1793 | (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])); | ||
1794 | |||
1795 | ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US; | ||
1796 | |||
1797 | pH264VEComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); | ||
1798 | if( bLEOS ) { | ||
1799 | bLCallCodecProcess = OMX_FALSE; | ||
1800 | } else { | ||
1801 | OSAL_ErrorTrace("++++++++Input Buffer Sent with no DATA & no EOS flag++++++++++++"); | ||
1802 | goto CHECKCOUNT; | ||
1803 | } | ||
1804 | } else { | ||
1805 | /* Update the Input buffer details before the Codec Process call */ | ||
1806 | for( i = 0; i < (OMX_U32)pH264VEComp->pVedEncInBufs->numPlanes; i++ ) { | ||
1807 | if( i == 0 ) { | ||
1808 | if (pH264VEComp->bInputMetaDataBufferMode) { | ||
1809 | OMX_U32 *pTempBuffer; | ||
1810 | OMX_U32 nMetadataBufferType; | ||
1811 | IMG_native_handle_t* pGrallocHandle=NULL; | ||
1812 | pTempBuffer = (OMX_U32 *) (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pBuffer); | ||
1813 | nMetadataBufferType = *pTempBuffer; | ||
1814 | if(nMetadataBufferType == kMetadataBufferTypeGrallocSource){ | ||
1815 | buffer_handle_t tBufHandle; | ||
1816 | pTempBuffer++; | ||
1817 | tBufHandle = *((buffer_handle_t *)pTempBuffer); | ||
1818 | pGrallocHandle = (IMG_native_handle_t*) tBufHandle; | ||
1819 | if (pGrallocHandle->iFormat != HAL_PIXEL_FORMAT_NV12) { | ||
1820 | if (pH264VEComp->pBackupBuffers == NULL) { | ||
1821 | /* Open gralloc allocator and allocate the backup buffers */ | ||
1822 | gralloc_open(pH264VEComp->hCC, &(pH264VEComp->mAllocDev)); | ||
1823 | OMX_CHECK(pH264VEComp->mAllocDev != NULL, OMX_ErrorInsufficientResources); | ||
1824 | |||
1825 | pH264VEComp->pBackupBuffers = (IMG_native_handle_t **)OSAL_Malloc(sizeof(IMG_native_handle_t*) * | ||
1826 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual); | ||
1827 | OMX_CHECK(pH264VEComp->pBackupBuffers != NULL, OMX_ErrorInsufficientResources); | ||
1828 | |||
1829 | for (j = 0; j < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; j++ ) { | ||
1830 | pH264VEComp->pBackupBuffers[j] = NULL; | ||
1831 | int err = pH264VEComp->mAllocDev->alloc(pH264VEComp->mAllocDev, | ||
1832 | (int) pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
1833 | (int) pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
1834 | (int) HAL_PIXEL_FORMAT_NV12, (int) GRALLOC_USAGE_HW_RENDER, | ||
1835 | (buffer_handle_t *)(&(pH264VEComp->pBackupBuffers[j])), (int *) &stride); | ||
1836 | OMX_CHECK(err == 0, err); | ||
1837 | |||
1838 | //Get the DMA BUFF_FDs from the gralloc pointers | ||
1839 | pH264VEComp->pCodecInBufferBackupArray[j].sMemHdr[0].dma_buf_fd = (OMX_U32)((pH264VEComp->pBackupBuffers[j])->fd[0]); | ||
1840 | //register this buffer with DRM | ||
1841 | dce_buf_lock(1, (size_t *)&(pH264VEComp->pCodecInBufferBackupArray[j].sMemHdr[0].dma_buf_fd)); | ||
1842 | } | ||
1843 | } | ||
1844 | |||
1845 | /* Invoke color conversion routine here */ | ||
1846 | COLORCONVERT_PlatformOpaqueToNV12(pH264VEComp->hCC, (void **) &pGrallocHandle, | ||
1847 | (void **) &pH264VEComp->pBackupBuffers[InBufferHdrIndex], | ||
1848 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
1849 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight, | ||
1850 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth, | ||
1851 | COLORCONVERT_BUFTYPE_GRALLOCOPAQUE, | ||
1852 | COLORCONVERT_BUFTYPE_GRALLOCOPAQUE ); | ||
1853 | |||
1854 | |||
1855 | pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0].offset = (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->nOffset); | ||
1856 | |||
1857 | pH264VEComp->pVedEncInBufs->planeDesc[i].buf = | ||
1858 | (XDAS_Int8 *)&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0]); | ||
1859 | |||
1860 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_TILEDPAGE; | ||
1861 | } | ||
1862 | else { | ||
1863 | pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0].dma_buf_fd = (OMX_U32)(pGrallocHandle->fd[0]); | ||
1864 | pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0].offset = (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->nOffset); | ||
1865 | |||
1866 | pH264VEComp->pVedEncInBufs->planeDesc[i].buf = | ||
1867 | (XDAS_Int8 *)&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0]); | ||
1868 | |||
1869 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_TILEDPAGE; | ||
1870 | } | ||
1871 | } | ||
1872 | } else { | ||
1873 | ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0].offset = (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->nOffset); | ||
1874 | |||
1875 | pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0]); | ||
1876 | |||
1877 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; | ||
1878 | } | ||
1879 | pH264VEComp->pVedEncInBufs->imagePitch[0] = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride; | ||
1880 | pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->pVedEncInBufs->imagePitch[0]) * (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight); | ||
1881 | |||
1882 | } else if( i == 1 ) { | ||
1883 | if (pH264VEComp->bInputMetaDataBufferMode) { | ||
1884 | //Nothing to be done; color conversion and fd xlation is done during the plane0 processing | ||
1885 | memcpy(&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1]), &(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0]), sizeof(MemHeader)); | ||
1886 | |||
1887 | pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1].offset = | ||
1888 | ((pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride) * | ||
1889 | (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight)); | ||
1890 | |||
1891 | pH264VEComp->pVedEncInBufs->planeDesc[i].buf = | ||
1892 | (XDAS_Int8 *)&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1]); | ||
1893 | |||
1894 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_TILEDPAGE; | ||
1895 | } else { | ||
1896 | memcpy(&((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[1], &((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0], sizeof(MemHeader)); | ||
1897 | |||
1898 | ((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)); | ||
1899 | |||
1900 | pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[1]); | ||
1901 | |||
1902 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; | ||
1903 | } | ||
1904 | pH264VEComp->pVedEncInBufs->imagePitch[1] = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride; | ||
1905 | pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->pVedEncInBufs->imagePitch[1]) * (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight) / 2; | ||
1906 | |||
1907 | } else { | ||
1908 | eError = OMX_ErrorUnsupportedSetting; | ||
1909 | OSAL_ErrorTrace("only NV12 is supproted currently; wrong param from Codec"); | ||
1910 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1911 | } | ||
1912 | } | ||
1913 | bLCallCodecProcess=OMX_TRUE; | ||
1914 | } | ||
1915 | } else { | ||
1916 | OSAL_Info("After EOS reception Case"); | ||
1917 | eError = OMXH264VE_GetNumCodecLockedBuffers(pComp, &LCodecLockedBufferCount); | ||
1918 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1919 | if( LCodecLockedBufferCount > 0 ) { | ||
1920 | /*After EOS reception No need to provide Input for the Process, hence passing tempbuffers*/ | ||
1921 | for( i = 0; i < (OMX_U32)pH264VEComp->pVedEncInBufs->numPlanes; i++ ) { | ||
1922 | pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)(pH264VEComp->pTempBuffer[i]); | ||
1923 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; | ||
1924 | pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = | ||
1925 | (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes); | ||
1926 | } | ||
1927 | bLCallCodecProcess=OMX_TRUE; | ||
1928 | } else { | ||
1929 | /*Update the OutBufHeader*/ | ||
1930 | pOutBufHeader->nOffset = 0; | ||
1931 | pOutBufHeader->nFilledLen = 0; | ||
1932 | pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; | ||
1933 | pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); | ||
1934 | pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE; | ||
1935 | /*notify the EOSEvent to the client*/ | ||
1936 | pH264VEComp->bNotifyEOSEventToClient = OMX_TRUE; | ||
1937 | bLCallCodecProcess = OMX_FALSE; | ||
1938 | } | ||
1939 | } | ||
1940 | if( bLCallCodecProcess ) { | ||
1941 | if( !pH264VEComp->bAfterEOSReception ) { | ||
1942 | OSAL_Info("update the Dynamic params before Process"); | ||
1943 | /* Call to xDM Set Params depending on the pH264VEComp->bCallxDMSetParams flag status before the process call */ | ||
1944 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
1945 | bLCallxDMSetParams = pH264VEComp->bCallxDMSetParams; | ||
1946 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
1947 | if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) { | ||
1948 | eError = OMXH264VE_SetDynamicParamsToCodec(hComponent); | ||
1949 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1950 | } | ||
1951 | } | ||
1952 | /* Update the Output buffer details before the Codec Process call */ | ||
1953 | OSAL_Info("Update the Output buffer details before the Codec Process call"); | ||
1954 | /*Note: this implementation assumes | ||
1955 | a) output buffer is always 1D | ||
1956 | b) if in case of multiple output buffers that need to given to codec for each process call | ||
1957 | they are allocated in contiguous memory | ||
1958 | */ | ||
1959 | if( pH264VEComp->pVedEncOutBufs->numBufs != 1 ) { | ||
1960 | eError = OMX_ErrorUnsupportedSetting; | ||
1961 | OSAL_ErrorTrace("Encoder Output Buffer is assigned as 2D Buffer"); | ||
1962 | goto EXIT; | ||
1963 | } | ||
1964 | |||
1965 | pH264VEComp->pVedEncOutBufs->descs[0].buf = | ||
1966 | (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]); | ||
1967 | |||
1968 | pH264VEComp->pVedEncOutBufs->descs[0].bufSize.bytes = pOutBufHeader->nAllocLen; | ||
1969 | |||
1970 | /* Update the InArgs details before the Codec Process call */ | ||
1971 | OSAL_Info("Update the InArgs before the Codec Process call"); | ||
1972 | pH264VEComp->pVidEncInArgs->videnc2InArgs.size = sizeof(IH264ENC_InArgs); | ||
1973 | pH264VEComp->pVidEncInArgs->videnc2InArgs.control = IVIDENC2_CTRL_NONE; | ||
1974 | |||
1975 | if( !pH264VEComp->bAfterEOSReception ) { | ||
1976 | pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = InBufferHdrIndex + 1; | ||
1977 | /*Zero is not a valid input so increasing the bufferIndex value by 1*/ | ||
1978 | } else { | ||
1979 | pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = 0; /*Zero is not a valid input */ | ||
1980 | } | ||
1981 | |||
1982 | pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] = 0; | ||
1983 | /* Update the OutArgs details before the Codec Process call */ | ||
1984 | OSAL_Info("Update the OutArgs before the Codec Process call"); | ||
1985 | pH264VEComp->pVidEncOutArgs->videnc2OutArgs.size = sizeof(IVIDENC2_OutArgs); | ||
1986 | |||
1987 | /* Codec Process call */ | ||
1988 | eError = OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(hComponent, &retval); | ||
1989 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
1990 | |||
1991 | /* Send the input & corresponding output buffers Back to the Client when the codec frees */ | ||
1992 | /*Note: implementation is based on | ||
1993 | a) after every process, there will be at max one input buffer that can be freed | ||
1994 | b)for every input buffer that is freed ......there will be corresponding o/p buffer | ||
1995 | */ | ||
1996 | if( pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]) { | ||
1997 | /*Non Zero ID : valid free buffer ID*/ | ||
1998 | ALOGE("Codec freed input buffer with ID =%d", (OMX_U32)pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]); | ||
1999 | |||
2000 | /* Propagate the Time Stamps from input to Corresponding Output */ | ||
2001 | OSAL_Info("Propagate the timestamp"); | ||
2002 | pOutBufHeader->nTimeStamp = | ||
2003 | (pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)])->nTimeStamp; | ||
2004 | |||
2005 | /* Send the input buffers Back to the Client */ | ||
2006 | pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]->nFilledLen = 0; | ||
2007 | /*Completely Consumed*/ | ||
2008 | pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]->nOffset = 0; | ||
2009 | |||
2010 | ((OMXBase_BufHdrPvtData *)((pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)])->pPlatformPrivate))->bufSt = OWNED_BY_US; | ||
2011 | |||
2012 | pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT, | ||
2013 | pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]); | ||
2014 | /*check for the EOS */ | ||
2015 | if( pH264VEComp->bPropagateEOSToOutputBuffer ) { | ||
2016 | /*Send the Output with EOS after sending all the previous buffers*/ | ||
2017 | eError = OMXH264VE_GetNumCodecLockedBuffers(pComp, &LCodecLockedBufferCount); | ||
2018 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
2019 | if(LCodecLockedBufferCount == 0) { | ||
2020 | /*No locked buffers*/ | ||
2021 | pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; | ||
2022 | pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE; | ||
2023 | } | ||
2024 | } | ||
2025 | |||
2026 | /* Check for IDR frame & update the Output BufferHdr Flags */ | ||
2027 | if(((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.encodedFrameType) == IVIDEO_IDR_FRAME) || | ||
2028 | ((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.encodedFrameType) == IVIDEO_I_FRAME)) { | ||
2029 | pOutBufHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; | ||
2030 | } | ||
2031 | |||
2032 | /* Send the output buffers Back to the Client */ | ||
2033 | OSAL_Info("Send the output buffers Back to the Client"); | ||
2034 | /*Update the OutBufHeader*/ | ||
2035 | if( pH264VEComp->bAfterGenHeader ) { | ||
2036 | pOutBufHeader->nOffset = pH264VEComp->nCodecConfigSize; | ||
2037 | pOutBufHeader->nFilledLen = ((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated) - | ||
2038 | (pH264VEComp->nCodecConfigSize)); | ||
2039 | pH264VEComp->bAfterGenHeader = OMX_FALSE; | ||
2040 | pH264VEComp->nCodecConfigSize = 0; | ||
2041 | } else { | ||
2042 | pOutBufHeader->nOffset = 0; | ||
2043 | pOutBufHeader->nFilledLen = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated; | ||
2044 | } | ||
2045 | /* Return this output buffer to the Base comp via ReturnDataNotify call | ||
2046 | * to communciate with the IL client incase of Non-Tunneling or tunneled | ||
2047 | * component in case of tunneling*/ | ||
2048 | ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US; | ||
2049 | pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); | ||
2050 | } else { | ||
2051 | if( pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated == 0 ) { | ||
2052 | /*free ID ==0 so no inputbuffer is freed & thus no o/p should be generated*/ | ||
2053 | OSAL_Info("codec locked the buffer so do the DIO_Cancel for the outputbuffer"); | ||
2054 | OSAL_Info("bytes generated is Zero & retain the output buffers via DIO_Cancel"); | ||
2055 | ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US; | ||
2056 | pH264VEComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); | ||
2057 | } else { | ||
2058 | if((!pH264VEComp->bAfterEOSReception) || | ||
2059 | ((pH264VEComp->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskEndOfSequence) == 0x0)) { | ||
2060 | OSAL_ErrorTrace("***********something gone wrong***********"); | ||
2061 | goto EXIT; | ||
2062 | } | ||
2063 | /* Send the output buffers Back to the Client */ | ||
2064 | OSAL_Info("Send the output buffers Back to the Client"); | ||
2065 | /*Update the OutBufHeader*/ | ||
2066 | pOutBufHeader->nOffset = 0; | ||
2067 | pOutBufHeader->nFilledLen = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated; | ||
2068 | pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS; | ||
2069 | pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE; | ||
2070 | /*notify the EOSEvent to the client*/ | ||
2071 | pH264VEComp->bNotifyEOSEventToClient = OMX_TRUE; | ||
2072 | /* Return this output buffer to the Base comp via ReturnDataNotify call | ||
2073 | * to communciate with the IL client incase of Non-Tunneling or tunneled | ||
2074 | * component in case of tunneling*/ | ||
2075 | ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US; | ||
2076 | pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader); | ||
2077 | } | ||
2078 | } | ||
2079 | } | ||
2080 | /*Call to xDM_FLUSH when Input with EOS flag has been received*/ | ||
2081 | if( bLCodecFlush ) { | ||
2082 | /*control call with command XDM_FLUSH*/ | ||
2083 | OSAL_Info("Call CodecFlush "); | ||
2084 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH, | ||
2085 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
2086 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
2087 | if( retval == VIDENC2_EFAIL ) { | ||
2088 | OSAL_ErrorTrace("Got error from the CodecControl call"); | ||
2089 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
2090 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
2091 | } | ||
2092 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
2093 | /*Set the bCodecFlush to True ....no need to call codec flush during idle->Loaded Transition*/ | ||
2094 | pH264VEComp->bCodecFlush = OMX_TRUE; | ||
2095 | bLEOS= OMX_FALSE; | ||
2096 | bLCodecFlush = OMX_FALSE; | ||
2097 | /* after EOS no need to provide extra input buffer */ | ||
2098 | pH264VEComp->bAfterEOSReception = OMX_TRUE; | ||
2099 | } | ||
2100 | if( pH264VEComp->bNotifyEOSEventToClient ) { | ||
2101 | /* Reset the Codec : to continue with New stream w/o codec create */ | ||
2102 | if( pH264VEComp->bCodecCreate ) { | ||
2103 | /*Codec Call: control call with command XDM_RESET*/ | ||
2104 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET, | ||
2105 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
2106 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
2107 | if( retval != VIDENC2_EOK ) { | ||
2108 | OSAL_ErrorTrace("Got error from the Codec_RESET call"); | ||
2109 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
2110 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
2111 | } | ||
2112 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
2113 | } | ||
2114 | /* Notify EOS event flag to the Base Component via ReturnEventNotify | ||
2115 | * call , which communciates with the IL Client */ | ||
2116 | pH264VEComp->sBase.fpReturnEventNotify(hComponent, OMX_EventBufferFlag, | ||
2117 | OMX_H264VE_OUTPUT_PORT, | ||
2118 | OMX_BUFFERFLAG_EOS, NULL); | ||
2119 | /*reset the flags*/ | ||
2120 | pH264VEComp->bAfterEOSReception = OMX_FALSE; | ||
2121 | pH264VEComp->bNotifyEOSEventToClient = OMX_FALSE; | ||
2122 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; | ||
2123 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
2124 | pH264VEComp->bSendCodecConfig = OMX_TRUE; | ||
2125 | pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX; | ||
2126 | pH264VEComp->nCodecConfigSize = 0; | ||
2127 | pH264VEComp->bAfterGenHeader = OMX_FALSE; | ||
2128 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
2129 | goto EXIT; | ||
2130 | } | ||
2131 | |||
2132 | CHECKCOUNT: | ||
2133 | /*get the buffer count for the next loop execution*/ | ||
2134 | pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount); | ||
2135 | pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount); | ||
2136 | ALOGE("Input Msg Count=%d, Output Msg Count=%d for the Next process loop", nInMsgCount, nOutMsgCount); | ||
2137 | } /*end of process call loop*/ | ||
2138 | } else { | ||
2139 | OSAL_WarningTrace("!!!!!!!!!!!Incorrect State operation/ ports need to be enabled!!!!!!!!"); | ||
2140 | } | ||
2141 | |||
2142 | EXIT: | ||
2143 | |||
2144 | return (eError); | ||
2145 | |||
2146 | } | ||
2147 | |||
2148 | static OMX_ERRORTYPE OMXH264VE_ComponentDeinit(OMX_HANDLETYPE hComponent) | ||
2149 | { | ||
2150 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
2151 | OMX_COMPONENTTYPE *pComp = NULL; | ||
2152 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
2153 | OMX_U32 i; | ||
2154 | |||
2155 | |||
2156 | /* Check the input parameters */ | ||
2157 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
2158 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
2159 | pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate; | ||
2160 | |||
2161 | OMXBase_UtilCleanupIfError(hComponent); | ||
2162 | |||
2163 | |||
2164 | if( pH264VEComp->sBase.cComponentName ) { | ||
2165 | OSAL_Free(pH264VEComp->sBase.cComponentName); | ||
2166 | pH264VEComp->sBase.cComponentName = NULL; | ||
2167 | } | ||
2168 | |||
2169 | /* Calling OMX Base Component Deinit */ | ||
2170 | OSAL_Info("Call BaseComponent Deinit"); | ||
2171 | eError = OMXBase_ComponentDeinit(hComponent); | ||
2172 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
2173 | /*Allocating memory for port properties before calling SetDefaultProperties*/ | ||
2174 | OSAL_Info("DeInitialize DerToBase.PortProperties"); | ||
2175 | |||
2176 | pH264VEComp->bInputMetaDataBufferMode = OMX_FALSE; | ||
2177 | |||
2178 | /*Add CE deinit related stuff here*/ | ||
2179 | if( pH264VEComp->pCEhandle ) { | ||
2180 | OSAL_Info("Call Engine_Close"); | ||
2181 | Engine_close(pH264VEComp->pCEhandle); | ||
2182 | } | ||
2183 | |||
2184 | /* Free up the H264VE component's private area */ | ||
2185 | OSAL_Free(pH264VEComp->sBase.pAudioPortParams); | ||
2186 | OSAL_Free(pH264VEComp->sBase.pVideoPortParams); | ||
2187 | OSAL_Free(pH264VEComp->sBase.pImagePortParams); | ||
2188 | OSAL_Free(pH264VEComp->sBase.pOtherPortParams); | ||
2189 | memplugin_free_noheader(pH264VEComp->sCodecConfigData.sBuffer); | ||
2190 | memplugin_free_noheader(pH264VEComp->pTempBuffer[0]); | ||
2191 | memplugin_free_noheader(pH264VEComp->pTempBuffer[1]); | ||
2192 | memplugin_free(pH264VEComp->pVedEncOutBufs); | ||
2193 | memplugin_free(pH264VEComp->pVedEncInBufs); | ||
2194 | memplugin_free(pH264VEComp->pVidEncOutArgs); | ||
2195 | memplugin_free(pH264VEComp->pVidEncInArgs); | ||
2196 | memplugin_free(pH264VEComp->pVidEncStatus); | ||
2197 | memplugin_free(pH264VEComp->pVidEncDynamicParams); | ||
2198 | memplugin_free(pH264VEComp->pVidEncStaticParams); | ||
2199 | |||
2200 | OSAL_Free(pH264VEComp); | ||
2201 | pH264VEComp = NULL; | ||
2202 | |||
2203 | EXIT: | ||
2204 | OSAL_Info("At the End of Component DeInit"); | ||
2205 | return (eError); | ||
2206 | } | ||
2207 | |||
2208 | |||
2209 | OMX_ERRORTYPE OMXH264VE_GetExtensionIndex(OMX_HANDLETYPE hComponent, | ||
2210 | OMX_STRING cParameterName, | ||
2211 | OMX_INDEXTYPE *pIndexType) | ||
2212 | { | ||
2213 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
2214 | OMX_COMPONENTTYPE *pComp; | ||
2215 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
2216 | |||
2217 | /* Check the input parameters */ | ||
2218 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
2219 | |||
2220 | pComp = (OMX_COMPONENTTYPE *)hComponent; | ||
2221 | pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate; | ||
2222 | |||
2223 | OMX_CHECK(pH264VEComp != NULL, OMX_ErrorBadParameter); | ||
2224 | |||
2225 | OMX_CHECK(cParameterName != NULL, OMX_ErrorBadParameter); | ||
2226 | OMX_CHECK(pIndexType != NULL, OMX_ErrorBadParameter); | ||
2227 | if( pH264VEComp->sBase.tCurState == OMX_StateInvalid ) { | ||
2228 | eError = OMX_ErrorInvalidState; | ||
2229 | goto EXIT; | ||
2230 | } | ||
2231 | if( strlen(cParameterName) > 127 ) { | ||
2232 | //strlen does not include �\0� size, hence 127 | ||
2233 | eError = OMX_ErrorBadParameter; | ||
2234 | goto EXIT; | ||
2235 | } | ||
2236 | |||
2237 | if(strcmp(cParameterName, "OMX.google.android.index.storeMetaDataInBuffers") == 0) { | ||
2238 | *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexEncoderReceiveMetadataBuffers; | ||
2239 | goto EXIT; | ||
2240 | } else if( strcmp(cParameterName, "OMX.google.android.index.describeColorFormat") == 0 ) { | ||
2241 | // If Index type is Time Stamp In Decode Order | ||
2242 | *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat; | ||
2243 | goto EXIT; | ||
2244 | } | ||
2245 | |||
2246 | eError = OMX_ErrorUnsupportedIndex; | ||
2247 | |||
2248 | EXIT: | ||
2249 | return (eError); | ||
2250 | } | ||
2251 | |||
2252 | |||
2253 | static OMX_ERRORTYPE OMXH264VE_ComponentTunnelRequest(OMX_HANDLETYPE hComponent, | ||
2254 | OMX_U32 nPort, | ||
2255 | OMX_HANDLETYPE hTunneledComp, | ||
2256 | OMX_U32 nTunneledPort, | ||
2257 | OMX_TUNNELSETUPTYPE *pTunnelSetup) | ||
2258 | { | ||
2259 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
2260 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
2261 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
2262 | (void)nPort, hTunneledComp, nTunneledPort, pTunnelSetup; | ||
2263 | |||
2264 | /* Check all the input parametrs */ | ||
2265 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
2266 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
2267 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
2268 | OMX_CHECK((pH264VEComp != NULL), OMX_ErrorBadParameter); | ||
2269 | |||
2270 | eError = OMX_ErrorNotImplemented; | ||
2271 | OSAL_ErrorTrace("in omx-h264e ComponentTunnelRequest :: enable input subframe processing first"); | ||
2272 | OMX_CHECK(OMX_ErrorNone == eError, eError); | ||
2273 | |||
2274 | EXIT: | ||
2275 | return (eError); | ||
2276 | } | ||
2277 | |||
2278 | |||
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) Texas Instruments - http://www.ti.com/ | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "OMX_H264_ENCODERUTILS" | ||
18 | |||
19 | #include "omx_H264videoencoder.h" | ||
20 | |||
21 | OMX_H264_LVL_BITRATE OMX_H264_BP_MP_BITRATE_SUPPORT[] = | ||
22 | { | ||
23 | { OMX_VIDEO_AVCLevel1, 64000 }, | ||
24 | { OMX_VIDEO_AVCLevel1b, 128000 }, | ||
25 | { OMX_VIDEO_AVCLevel11, 192000 }, | ||
26 | { OMX_VIDEO_AVCLevel12, 384000 }, | ||
27 | { OMX_VIDEO_AVCLevel13, 768000 }, | ||
28 | { OMX_VIDEO_AVCLevel2, 2000000 }, | ||
29 | { OMX_VIDEO_AVCLevel21, 4000000 }, | ||
30 | { OMX_VIDEO_AVCLevel22, 4000000 }, | ||
31 | { OMX_VIDEO_AVCLevel3, 10000000 }, | ||
32 | { OMX_VIDEO_AVCLevel31, 14000000 }, | ||
33 | { OMX_VIDEO_AVCLevel32, 20000000 }, | ||
34 | { OMX_VIDEO_AVCLevel4, 20000000 }, | ||
35 | { OMX_VIDEO_AVCLevel41, 50000000 }, | ||
36 | { OMX_VIDEO_AVCLevel42, 50000000 }, | ||
37 | { 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 | ||
38 | { 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 | ||
39 | }; | ||
40 | |||
41 | OMX_H264_LVL_BITRATE OMX_H264_HP_BITRATE_SUPPORT[] = | ||
42 | { | ||
43 | { OMX_VIDEO_AVCLevel1, 80000 }, | ||
44 | { OMX_VIDEO_AVCLevel1b, 160000 }, | ||
45 | { OMX_VIDEO_AVCLevel11, 240000 }, | ||
46 | { OMX_VIDEO_AVCLevel12, 480000 }, | ||
47 | { OMX_VIDEO_AVCLevel13, 960000 }, | ||
48 | { OMX_VIDEO_AVCLevel2, 2500000 }, | ||
49 | { OMX_VIDEO_AVCLevel21, 5000000 }, | ||
50 | { OMX_VIDEO_AVCLevel22, 5000000 }, | ||
51 | { OMX_VIDEO_AVCLevel3, 12500000 }, | ||
52 | { OMX_VIDEO_AVCLevel31, 17500000 }, | ||
53 | { OMX_VIDEO_AVCLevel32, 25000000 }, | ||
54 | { OMX_VIDEO_AVCLevel4, 25000000 }, | ||
55 | { OMX_VIDEO_AVCLevel41, 62500000 }, | ||
56 | { OMX_VIDEO_AVCLevel42, 62500000 }, | ||
57 | { 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 | ||
58 | { 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 | ||
59 | }; | ||
60 | |||
61 | OMX_ERRORTYPE OMXH264VE_InitFields(OMX_HANDLETYPE hComponent) | ||
62 | { | ||
63 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
64 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
65 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
66 | |||
67 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
68 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
69 | |||
70 | OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); | ||
71 | |||
72 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
73 | |||
74 | pH264VEComp->sBase.cComponentName = (OMX_STRING )OSAL_Malloc(sizeof(OMX_U8) * OMX_MAX_STRINGNAME_SIZE); | ||
75 | OMX_CHECK(pH264VEComp->sBase.cComponentName != NULL, OMX_ErrorInsufficientResources); | ||
76 | |||
77 | strcpy(pH264VEComp->sBase.cComponentName, OMX_H264VE_COMP_NAME); | ||
78 | |||
79 | /* Fill component's version, this may not be same as the OMX Specification version */ | ||
80 | pH264VEComp->sBase.nComponentVersion.s.nVersionMajor = OMX_H264VE_COMP_VERSION_MAJOR; | ||
81 | pH264VEComp->sBase.nComponentVersion.s.nVersionMinor = OMX_H264VE_COMP_VERSION_MINOR; | ||
82 | pH264VEComp->sBase.nComponentVersion.s.nRevision = OMX_H264VE_COMP_VERSION_REVISION; | ||
83 | pH264VEComp->sBase.nComponentVersion.s.nStep = OMX_H264VE_COMP_VERSION_STEP; | ||
84 | |||
85 | /* Initialize Audio Port parameters */ | ||
86 | OSAL_Info("Initialize Audio Port Params"); | ||
87 | pH264VEComp->sBase.pAudioPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); | ||
88 | OMX_CHECK(pH264VEComp->sBase.pAudioPortParams != NULL, OMX_ErrorInsufficientResources); | ||
89 | |||
90 | OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pAudioPortParams, OMX_PORT_PARAM_TYPE); | ||
91 | pH264VEComp->sBase.pAudioPortParams->nPorts = 0; | ||
92 | pH264VEComp->sBase.pAudioPortParams->nStartPortNumber = 0; | ||
93 | |||
94 | /* Initialize Video Port parameters */ | ||
95 | OSAL_Info("Initialize Video Port Params"); | ||
96 | pH264VEComp->sBase.pVideoPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); | ||
97 | OMX_CHECK(pH264VEComp->sBase.pVideoPortParams != NULL, OMX_ErrorInsufficientResources); | ||
98 | |||
99 | OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pVideoPortParams, OMX_PORT_PARAM_TYPE); | ||
100 | pH264VEComp->sBase.pVideoPortParams->nPorts = OMX_H264VE_NUM_PORTS; | ||
101 | pH264VEComp->sBase.pVideoPortParams->nStartPortNumber = OMX_H264VE_DEFAULT_START_PORT_NUM; | ||
102 | |||
103 | /* Initialize Image Port parameters */ | ||
104 | OSAL_Info("Initialize Image Port Params"); | ||
105 | pH264VEComp->sBase.pImagePortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); | ||
106 | OMX_CHECK(pH264VEComp->sBase.pImagePortParams != NULL, OMX_ErrorInsufficientResources); | ||
107 | |||
108 | OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pImagePortParams, OMX_PORT_PARAM_TYPE); | ||
109 | pH264VEComp->sBase.pImagePortParams->nPorts = 0; | ||
110 | pH264VEComp->sBase.pImagePortParams->nStartPortNumber = 0; | ||
111 | |||
112 | /* Initialize Other Port parameters */ | ||
113 | OSAL_Info("Initialize Other Port Params"); | ||
114 | pH264VEComp->sBase.pOtherPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE)); | ||
115 | OMX_CHECK(pH264VEComp->sBase.pOtherPortParams != NULL, OMX_ErrorInsufficientResources); | ||
116 | |||
117 | OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pOtherPortParams, OMX_PORT_PARAM_TYPE); | ||
118 | pH264VEComp->sBase.pOtherPortParams->nPorts = 0; | ||
119 | pH264VEComp->sBase.pOtherPortParams->nStartPortNumber = 0; | ||
120 | |||
121 | /* Initialize the Total Number of Ports and Start Port Number*/ | ||
122 | OSAL_Info("Initialize Component Port Params"); | ||
123 | pH264VEComp->sBase.nNumPorts = OMX_H264VE_NUM_PORTS; | ||
124 | pH264VEComp->sBase.nMinStartPortIndex = OMX_H264VE_DEFAULT_START_PORT_NUM; | ||
125 | |||
126 | /* Overriding this value. Notify derived component only when data is available on all ports */ | ||
127 | pH264VEComp->sBase.bNotifyForAnyPort = OMX_FALSE; | ||
128 | |||
129 | /* Allocate Memory for Static Parameter */ | ||
130 | pH264VEComp->pVidEncStaticParams = (IH264ENC_Params *) memplugin_alloc(sizeof(IH264ENC_Params), 1, MEM_CARVEOUT, 0, 0); | ||
131 | OMX_CHECK(pH264VEComp->pVidEncStaticParams != NULL, OMX_ErrorInsufficientResources); | ||
132 | OSAL_Memset(pH264VEComp->pVidEncStaticParams, 0x0, sizeof(IH264ENC_Params)); | ||
133 | |||
134 | /* Allocate Memory for Dynamic Parameter */ | ||
135 | pH264VEComp->pVidEncDynamicParams = (IH264ENC_DynamicParams *) memplugin_alloc(sizeof(IH264ENC_DynamicParams), 1, MEM_CARVEOUT, 0, 0); | ||
136 | OMX_CHECK(pH264VEComp->pVidEncDynamicParams != NULL, OMX_ErrorInsufficientResources); | ||
137 | OSAL_Memset(pH264VEComp->pVidEncDynamicParams, 0x0, sizeof(IH264ENC_DynamicParams)); | ||
138 | |||
139 | /* Allocate Memory for status Parameter */ | ||
140 | pH264VEComp->pVidEncStatus = (IH264ENC_Status *) memplugin_alloc(sizeof(IH264ENC_Status), 1, MEM_CARVEOUT, 0, 0); | ||
141 | OMX_CHECK(pH264VEComp->pVidEncStatus != NULL, OMX_ErrorInsufficientResources); | ||
142 | OSAL_Memset(pH264VEComp->pVidEncStatus, 0x0, sizeof(IH264ENC_Status)); | ||
143 | |||
144 | /* Allocate Memory for InArgs Parameter */ | ||
145 | pH264VEComp->pVidEncInArgs = (IH264ENC_InArgs *) memplugin_alloc(sizeof(IH264ENC_InArgs), 1, MEM_CARVEOUT, 0, 0); | ||
146 | OMX_CHECK(pH264VEComp->pVidEncInArgs != NULL, OMX_ErrorInsufficientResources); | ||
147 | OSAL_Memset(pH264VEComp->pVidEncInArgs, 0x0, sizeof(IH264ENC_InArgs)); | ||
148 | |||
149 | /* Allocate Memory for OutArgs Parameter */ | ||
150 | pH264VEComp->pVidEncOutArgs = (IH264ENC_OutArgs *) memplugin_alloc(sizeof(IH264ENC_OutArgs), 1, MEM_CARVEOUT, 0, 0); | ||
151 | OMX_CHECK(pH264VEComp->pVidEncOutArgs != NULL, OMX_ErrorInsufficientResources); | ||
152 | OSAL_Memset(pH264VEComp->pVidEncOutArgs, 0x0, sizeof(IH264ENC_OutArgs)); | ||
153 | |||
154 | /* Allocate Memory for InDesc Parameter */ | ||
155 | pH264VEComp->pVedEncInBufs = (IVIDEO2_BufDesc *) memplugin_alloc(sizeof(IVIDEO2_BufDesc), 1, MEM_CARVEOUT, 0, 0); | ||
156 | OMX_CHECK(pH264VEComp->pVedEncInBufs != NULL, OMX_ErrorInsufficientResources); | ||
157 | OSAL_Memset(pH264VEComp->pVedEncInBufs, 0x0, sizeof(IVIDEO2_BufDesc)); | ||
158 | |||
159 | /* Allocate Memory for OutDesc Parameter */ | ||
160 | pH264VEComp->pVedEncOutBufs = (XDM2_BufDesc *) memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0); | ||
161 | OMX_CHECK(pH264VEComp->pVedEncOutBufs != NULL, OMX_ErrorInsufficientResources); | ||
162 | OSAL_Memset(pH264VEComp->pVedEncOutBufs, 0x0, sizeof(XDM2_BufDesc)); | ||
163 | |||
164 | EXIT: | ||
165 | if( eError != OMX_ErrorNone ) { | ||
166 | OSAL_ErrorTrace("in fn OMXH264VE_SesBaseParameters"); | ||
167 | } | ||
168 | |||
169 | return (eError); | ||
170 | |||
171 | } | ||
172 | |||
173 | |||
174 | OMX_ERRORTYPE OMXH264VE_InitialzeComponentPrivateParams(OMX_HANDLETYPE hComponent) | ||
175 | { | ||
176 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
177 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
178 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
179 | OMX_U32 i = 0; | ||
180 | OSAL_ERROR tStatus = OSAL_ErrNone; | ||
181 | |||
182 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
183 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
184 | |||
185 | OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); | ||
186 | |||
187 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
188 | |||
189 | OSAL_Info("Update the default Port Params"); | ||
190 | |||
191 | /* Set the Port Definition (OMX_PARAM_PORTDEFINITIONTYPE) Values : INPUT PORT */ | ||
192 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex = OMX_H264VE_INPUT_PORT; | ||
193 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.eDir = OMX_DirInput; | ||
194 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual = OMX_H264VE_DEFAULT_INPUT_BUFFER_COUNT; | ||
195 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin = OMX_H264VE_MIN_INPUT_BUFFER_COUNT; | ||
196 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = OMX_H264VE_DEFAULT_INPUT_BUFFER_SIZE; | ||
197 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bEnabled = OMX_TRUE; | ||
198 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bPopulated = OMX_FALSE; | ||
199 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.eDomain = OMX_PortDomainVideo; | ||
200 | /*Update the Domain (Video) Specific values*/ | ||
201 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.cMIMEType = NULL; | ||
202 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.pNativeRender = NULL; | ||
203 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH; /*should be multiples of 16*/ | ||
204 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; | ||
205 | 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)*/ | ||
206 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nSliceHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; /*setting the sliceheight as equal to frame height*/ | ||
207 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nBitrate = OMX_H264VE_DEFAULT_BITRATE; | ||
208 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate = (OMX_H264VE_DEFAULT_FRAME_RATE << 16); | ||
209 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment = OMX_FALSE; | ||
210 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; | ||
211 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat =OMX_TI_COLOR_FormatYUV420PackedSemiPlanar; | ||
212 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.pNativeWindow = NULL; | ||
213 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bBuffersContiguous=OMX_FALSE; | ||
214 | pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferAlignment=32; /*H264 Encoder Codec has alignment restriction for input buffers */ | ||
215 | |||
216 | /* Set the Port Definition (OMX_PARAM_PORTDEFINITIONTYPE)Values : OUTPUT PORT */ | ||
217 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex = OMX_H264VE_OUTPUT_PORT; | ||
218 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.eDir = OMX_DirOutput; | ||
219 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferCountActual = OMX_H264VE_DEFAULT_OUTPUT_BUFFER_COUNT; | ||
220 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferCountMin = OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT; | ||
221 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferSize = OMX_H264VE_DEFAULT_OUTPUT_BUFFER_SIZE; | ||
222 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bEnabled = OMX_TRUE; | ||
223 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bPopulated = OMX_FALSE; | ||
224 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.eDomain = OMX_PortDomainVideo; | ||
225 | /*Update the Domain (Video) Specific values*/ | ||
226 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.cMIMEType = NULL; | ||
227 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.pNativeRender = NULL; | ||
228 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH; | ||
229 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; | ||
230 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nStride = 0; //Stride is not used on port having bitstream buffers | ||
231 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nSliceHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; /*setting the sliceheight as equal frame height*/ | ||
232 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate = OMX_H264VE_DEFAULT_BITRATE; | ||
233 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.xFramerate = 0; | ||
234 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment = OMX_FALSE; | ||
235 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; | ||
236 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eColorFormat = OMX_COLOR_FormatUnused; | ||
237 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.pNativeWindow = NULL; | ||
238 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bBuffersContiguous=OMX_FALSE; | ||
239 | pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferAlignment=0; /*No Alignment required for output buffers*/ | ||
240 | |||
241 | OSAL_Info("SetH264AlgDefaultCreationParams "); | ||
242 | /* Set the Default IVIDENC2_Params: videnc2Params . Does not Adhere to Codec Defaults. Can be modified */ | ||
243 | SET_H264CODEC_DEFAULT_IVIDENC2_PARAMS(pH264VEComp, i); | ||
244 | /* Adheres to Codec Defaults. To be modified only when codec default params change */ | ||
245 | eError = OMXH264VE_SetAlgDefaultCreationParams(hComponent); | ||
246 | OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); | ||
247 | |||
248 | /*Overwrite some of the codec static defaults*/ | ||
249 | OVERWRITE_H264CODEC_DEFAULT_STATIC_PARAMS(pH264VEComp); | ||
250 | pH264VEComp->pVidEncStaticParams->IDRFrameInterval = 1; /*All I frames are IDR frames*/ | ||
251 | |||
252 | OSAL_Info("SetH264AlgDefaultDynamicParams "); | ||
253 | /* Set the IVIDENC2_DynamicParams videnc2DynamicParams */ | ||
254 | SET_H264CODEC_DEFAULT_IVIDENC2_DYNAMICPARAMS(pH264VEComp); | ||
255 | eError = OMXH264VE_SetAlgDefaultDynamicParams(hComponent); | ||
256 | OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); | ||
257 | |||
258 | /*Overwrite some of the codec static defaults*/ | ||
259 | OVERWRITE_H264CODEC_DEFAULT_DYNAMIC_PARAMS(pH264VEComp); | ||
260 | /*Enable 4 MV*/ | ||
261 | ENABLE_4MV(pH264VEComp); | ||
262 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; | ||
263 | |||
264 | pH264VEComp->bCodecCreate = OMX_FALSE; /*codec creation hasn't happened yet*/ | ||
265 | pH264VEComp->bCodecCreateSettingsChange = OMX_FALSE; /*set to true when Create time settings are modified*/ | ||
266 | pH264VEComp->bInputPortDisable = OMX_FALSE; /*flag to indicate codec creation is required or not */ | ||
267 | pH264VEComp->bCodecFlush = OMX_FALSE; | ||
268 | |||
269 | pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE; | ||
270 | pH264VEComp->pCodecInBufferArray = NULL; | ||
271 | pH264VEComp->bAfterEOSReception = OMX_FALSE; | ||
272 | pH264VEComp->bNotifyEOSEventToClient = OMX_FALSE; | ||
273 | pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE; | ||
274 | pH264VEComp->bSetParamInputIsDone = OMX_FALSE; | ||
275 | |||
276 | pH264VEComp->bSendCodecConfig = OMX_TRUE; | ||
277 | |||
278 | pH264VEComp->sCodecConfigData.sBuffer = OSAL_Malloc(sizeof(MemHeader)); | ||
279 | pH264VEComp->sCodecConfigData.sBuffer->ptr | ||
280 | = memplugin_alloc_noheader(pH264VEComp->sCodecConfigData.sBuffer, (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0); | ||
281 | OMX_CHECK(pH264VEComp->sCodecConfigData.sBuffer->ptr != NULL, OMX_ErrorInsufficientResources); | ||
282 | |||
283 | tStatus = OSAL_Memset(pH264VEComp->sCodecConfigData.sBuffer->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE)); | ||
284 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter); | ||
285 | |||
286 | |||
287 | pH264VEComp->pTempBuffer[0] = OSAL_Malloc(sizeof(MemHeader)); | ||
288 | pH264VEComp->pTempBuffer[0]->ptr | ||
289 | = memplugin_alloc_noheader(pH264VEComp->pTempBuffer[0], (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0); | ||
290 | OMX_CHECK(pH264VEComp->pTempBuffer[0]->ptr != NULL, OMX_ErrorInsufficientResources); | ||
291 | |||
292 | tStatus = OSAL_Memset(pH264VEComp->pTempBuffer[0]->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE)); | ||
293 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter); | ||
294 | |||
295 | pH264VEComp->pTempBuffer[1] = OSAL_Malloc(sizeof(MemHeader)); | ||
296 | pH264VEComp->pTempBuffer[1]->ptr | ||
297 | = memplugin_alloc_noheader(pH264VEComp->pTempBuffer[1], (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0); | ||
298 | OMX_CHECK(pH264VEComp->pTempBuffer[1]->ptr != NULL, OMX_ErrorInsufficientResources); | ||
299 | |||
300 | tStatus = OSAL_Memset(pH264VEComp->pTempBuffer[1]->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE)); | ||
301 | OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter); | ||
302 | |||
303 | pH264VEComp->nCodecConfigSize = 0; | ||
304 | pH264VEComp->bAfterGenHeader = OMX_FALSE; | ||
305 | |||
306 | EXIT: | ||
307 | if( eError != OMX_ErrorNone ) { | ||
308 | OSAL_ErrorTrace(" in fn OMXH264VE_InitialzeComponentPrivateParams"); | ||
309 | } | ||
310 | |||
311 | return (eError); | ||
312 | |||
313 | } | ||
314 | |||
315 | OMX_ERRORTYPE OMXH264VE_SetAlgDefaultCreationParams(OMX_HANDLETYPE hComponent) | ||
316 | { | ||
317 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
318 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
319 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
320 | |||
321 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
322 | |||
323 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
324 | OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); | ||
325 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
326 | |||
327 | /* Set the Default IH264ENC_RateControlParams: rateControlParams */ | ||
328 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_RATECONTROLPARAMS(pH264VEComp); | ||
329 | |||
330 | /* Set the Default IH264ENC_InterCodingParams interCodingParams */ | ||
331 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTERCODINGPARAMS(pH264VEComp); | ||
332 | |||
333 | /* Set the Default IH264ENC_IntraCodingParams intraCodingParams */ | ||
334 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTRACODINGPARAMS(pH264VEComp); | ||
335 | |||
336 | /* Set the Default IH264ENC_NALUControlParams nalUnitControlParams */ | ||
337 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_NALUCONTROLPARAMS(pH264VEComp); | ||
338 | |||
339 | /* Set the Default IH264ENC_SliceCodingParams sliceCodingParams */ | ||
340 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SLICECODINGPARAMS(pH264VEComp); | ||
341 | |||
342 | /* Set the Default IH264ENC_LoopFilterParams loopFilterParams */ | ||
343 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_LOOPFILTERPARAMS(pH264VEComp); | ||
344 | |||
345 | /* Set the Default IH264ENC_FMOCodingParams fmoCodingParams */ | ||
346 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_FMOCODINGPARAMS(pH264VEComp); | ||
347 | |||
348 | /* Set the Default IH264ENC_VUICodingParams vuiCodingParams */ | ||
349 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_VUICODINGPARAMS(pH264VEComp); | ||
350 | |||
351 | /* Set the Default IH264ENC_StereoInfoParams stereoInfoParams */ | ||
352 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOINFOPARAMS(pH264VEComp); | ||
353 | |||
354 | /* Set the Default IH264ENC_FramePackingSEIParams framePackingSEIParams */ | ||
355 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOFRAMEPACKINGPARAMS(pH264VEComp); | ||
356 | |||
357 | /* Set the Default IH264ENC_SVCCodingParams svcCodingParams */ | ||
358 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SVCCODINGPARAMS(pH264VEComp); | ||
359 | |||
360 | SET_H264CODEC_DEFAULT_STATIC_IH264ENC_EXTENDEDPARAMS(pH264VEComp); | ||
361 | |||
362 | EXIT: | ||
363 | if( eError != OMX_ErrorNone ) { | ||
364 | OSAL_ErrorTrace("in fn OMXH264VE_SetAlgDefaultCreationParams"); | ||
365 | } | ||
366 | |||
367 | return (eError); | ||
368 | } | ||
369 | |||
370 | OMX_ERRORTYPE OMXH264VE_SetAlgDefaultDynamicParams(OMX_HANDLETYPE hComponent) | ||
371 | { | ||
372 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
373 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
374 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
375 | |||
376 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
377 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
378 | OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); | ||
379 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
380 | |||
381 | /* Set the IH264ENC_RateControlParams rateControlParams */ | ||
382 | SET_H264CODEC_DEFAULT_DYNAMIC_RATECONTROLPARAMS(pH264VEComp); | ||
383 | |||
384 | /* Set the IH264ENC_InterCodingParams interCodingParams */ | ||
385 | SET_H264CODEC_DEFAULT_DYNAMIC_INTERCODINGPARAMS(pH264VEComp); | ||
386 | |||
387 | /* Set the IH264ENC_IntraCodingParams interCodingParams */ | ||
388 | SET_H264CODEC_DEFAULT_DYNAMIC_INTRACODINGPARAMS(pH264VEComp); | ||
389 | |||
390 | /* Set the IH264ENC_SliceCodingParams sliceCodingParams */ | ||
391 | SET_H264CODEC_DEFAULT_DYNAMIC_SLICECODINGPARAMS(pH264VEComp); | ||
392 | |||
393 | SET_H264CODEC_DEFAULT_DYNAMIC_IH264_EXTENDEDPARAMS(pH264VEComp); | ||
394 | |||
395 | EXIT: | ||
396 | if( eError != OMX_ErrorNone ) { | ||
397 | OSAL_ErrorTrace(" in fn OMXH264VE_SetAlgDefaultDynamicParams"); | ||
398 | } | ||
399 | return (eError); | ||
400 | } | ||
401 | |||
402 | |||
403 | OMX_ERRORTYPE OMXH264VE_SetBufferDesc(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex) | ||
404 | { | ||
405 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
406 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
407 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
408 | OMX_U8 i; | ||
409 | OMX_U32 extWidth, extHeight, extStride; | ||
410 | |||
411 | /* Check the input parameters, this should be TRUE else report an Error */ | ||
412 | OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter); | ||
413 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
414 | |||
415 | OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError); | ||
416 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
417 | |||
418 | if( nPortIndex == OMX_H264VE_INPUT_PORT ) { | ||
419 | pH264VEComp->pVedEncInBufs->numPlanes = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minNumInBufs; | ||
420 | for( i=0; i < pH264VEComp->pVedEncInBufs->numPlanes; i++ ) { | ||
421 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.inBufMemoryType[i]; | ||
422 | if( pH264VEComp->pVedEncInBufs->planeDesc[i].memType == XDM_MEMTYPE_RAW ) { | ||
423 | pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = | ||
424 | pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes; | ||
425 | } else { | ||
426 | /* Since we support non-tiler input buffers for encoding, change the memtype */ | ||
427 | pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW; | ||
428 | pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].tileMem.width) * (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].tileMem.height); | ||
429 | } | ||
430 | } | ||
431 | |||
432 | OSAL_Info("Update the Image,Active region of Codec params"); | ||
433 | 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*/ | ||
434 | extStride = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride; | ||
435 | extHeight = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight; | ||
436 | |||
437 | pH264VEComp->pVedEncInBufs->imageRegion.topLeft.x = 0; | ||
438 | pH264VEComp->pVedEncInBufs->imageRegion.topLeft.y = 0; | ||
439 | pH264VEComp->pVedEncInBufs->imageRegion.bottomRight.x = extStride; | ||
440 | |||
441 | pH264VEComp->pVedEncInBufs->activeFrameRegion.topLeft.x = 0; | ||
442 | pH264VEComp->pVedEncInBufs->activeFrameRegion.topLeft.y = 0; | ||
443 | pH264VEComp->pVedEncInBufs->activeFrameRegion.bottomRight.x = extWidth; | ||
444 | |||
445 | pH264VEComp->pVedEncInBufs->imagePitch[0] = extStride; | ||
446 | pH264VEComp->pVedEncInBufs->imagePitch[1] = extStride; | ||
447 | pH264VEComp->pVedEncInBufs->topFieldFirstFlag = OMX_TRUE; | ||
448 | |||
449 | pH264VEComp->pVedEncInBufs->contentType = IVIDEO_PROGRESSIVE; | ||
450 | pH264VEComp->pVedEncInBufs->activeFrameRegion.bottomRight.y = extHeight; | ||
451 | pH264VEComp->pVedEncInBufs->imageRegion.bottomRight.y = extHeight; | ||
452 | |||
453 | pH264VEComp->pVedEncInBufs->secondFieldOffsetWidth[0] = 0; | ||
454 | pH264VEComp->pVedEncInBufs->secondFieldOffsetWidth[1] = 0; | ||
455 | pH264VEComp->pVedEncInBufs->secondFieldOffsetHeight[0] = 0; | ||
456 | pH264VEComp->pVedEncInBufs->secondFieldOffsetHeight[1] = 0; | ||
457 | pH264VEComp->pVedEncInBufs->chromaFormat = XDM_YUV_420SP; | ||
458 | |||
459 | } else if( nPortIndex == OMX_H264VE_OUTPUT_PORT ) { | ||
460 | pH264VEComp->pVedEncOutBufs->numBufs = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minNumOutBufs; | ||
461 | for( i=0; i < pH264VEComp->pVedEncOutBufs->numBufs; i++ ) { | ||
462 | pH264VEComp->pVedEncOutBufs->descs[i].memType = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.outBufMemoryType[i]; | ||
463 | if( pH264VEComp->pVedEncOutBufs->descs[i].memType == XDM_MEMTYPE_RAW ) { | ||
464 | pH264VEComp->pVedEncOutBufs->descs[i].bufSize.bytes = | ||
465 | pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minOutBufSize[i].bytes; | ||
466 | } else { | ||
467 | /* since the output buffers are always non-tiled, change the memory type & size to RAW memory type*/ | ||
468 | pH264VEComp->pVedEncOutBufs->descs[i].memType = XDM_MEMTYPE_RAW; | ||
469 | pH264VEComp->pVedEncOutBufs->descs[i].bufSize.bytes = | ||
470 | pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minOutBufSize[i].bytes; | ||
471 | } | ||
472 | } | ||
473 | } else { | ||
474 | eError=OMX_ErrorBadPortIndex; | ||
475 | } | ||
476 | |||
477 | EXIT: | ||
478 | if( eError != OMX_ErrorNone ) { | ||
479 | OSAL_ErrorTrace("in fn OMXH264VE_SetBufferDesc"); | ||
480 | } | ||
481 | |||
482 | return (eError); | ||
483 | |||
484 | } | ||
485 | |||
486 | OMX_ERRORTYPE OMXH264VE_SetEncCodecReady(OMX_HANDLETYPE hComponent) | ||
487 | { | ||
488 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
489 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
490 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
491 | XDAS_Int32 retval = 0; | ||
492 | |||
493 | /* Check the input parameters */ | ||
494 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
495 | |||
496 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
497 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
498 | |||
499 | /*set the HRD buffer size appropriately*/ | ||
500 | if( pH264VEComp->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY ) { | ||
501 | pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize = | ||
502 | (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2; | ||
503 | pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize = | ||
504 | (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2; | ||
505 | } else { | ||
506 | pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize = | ||
507 | (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate); | ||
508 | pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize = | ||
509 | (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate); | ||
510 | } | ||
511 | pH264VEComp->pVidEncStaticParams->rateControlParams.initialBufferLevel = | ||
512 | pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize; | ||
513 | pH264VEComp->pVidEncDynamicParams->rateControlParams.initialBufferLevel = | ||
514 | pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize; | ||
515 | pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_USERDEFINED; | ||
516 | |||
517 | if( pH264VEComp->pVidEncStaticParams->videnc2Params.maxHeight & 0x01 ) { | ||
518 | eError = OMX_ErrorUnsupportedSetting; | ||
519 | OSAL_ErrorTrace("Incorrect Height Settings"); | ||
520 | OSAL_ErrorTrace("for Progressive Port Def Height need be multiple of 2"); | ||
521 | OSAL_ErrorTrace("for Interlace Port Def Height need be multiple of 4"); | ||
522 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
523 | } | ||
524 | |||
525 | /* Create H264 Encoder Instance */ | ||
526 | pH264VEComp->pVidEncHandle = VIDENC2_create(pH264VEComp->pCEhandle, | ||
527 | OMX_H264V_ENCODER_NAME, | ||
528 | (VIDENC2_Params *)(pH264VEComp->pVidEncStaticParams)); | ||
529 | |||
530 | OMX_CHECK(pH264VEComp->pVidEncHandle != NULL, OMX_ErrorInsufficientResources); | ||
531 | |||
532 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
533 | pH264VEComp->bCodecCreate=OMX_TRUE; | ||
534 | pH264VEComp->bCodecCreateSettingsChange=OMX_FALSE; | ||
535 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
536 | |||
537 | /* Set the Dynamic Parameters to the Codec */ | ||
538 | eError = OMXH264VE_SetDynamicParamsToCodec(hComponent); | ||
539 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
540 | |||
541 | /* Get the Codec Status Parametrs and Update the Component private Params accordingly */ | ||
542 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_GETSTATUS, | ||
543 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
544 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
545 | if( retval == VIDENC2_EFAIL ) { | ||
546 | OSAL_Info("Got error from the Codec GetbufInfo call"); | ||
547 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
548 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
549 | } | ||
550 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
551 | |||
552 | eError= OMXH264VE_UpdateParams(pHandle); | ||
553 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
554 | |||
555 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
556 | pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE; | ||
557 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
558 | |||
559 | /* get bufffer information: | ||
560 | * control->XDM_GETBUFINFO call always has to ensure the control->XDM_SETPARAMS call has done before | ||
561 | * Get the Buf Info from the Codec */ | ||
562 | OSAL_Info("call to xDM GetBufInfo"); | ||
563 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_GETBUFINFO, | ||
564 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
565 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
566 | if( retval == VIDENC2_EFAIL ) { | ||
567 | OSAL_Info("Got error from the Codec GetbufInfo call"); | ||
568 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
569 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
570 | } | ||
571 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
572 | /* Initialize the Inputbufs and Outputbufs with the values that Codec Expects */ | ||
573 | eError=OMXH264VE_SetBufferDesc(pHandle, OMX_H264VE_INPUT_PORT); | ||
574 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
575 | |||
576 | eError=OMXH264VE_SetBufferDesc(pHandle, OMX_H264VE_OUTPUT_PORT); | ||
577 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
578 | |||
579 | EXIT: | ||
580 | if( eError != OMX_ErrorNone ) { | ||
581 | OSAL_ErrorTrace("in fn OMXH264VE_SetEncCodecReady"); | ||
582 | } | ||
583 | |||
584 | return (eError); | ||
585 | |||
586 | } | ||
587 | |||
588 | OMX_ERRORTYPE OMXH264VE_UpdateParams(OMX_HANDLETYPE hComponent) | ||
589 | { | ||
590 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
591 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
592 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
593 | OMX_STATETYPE tState; | ||
594 | |||
595 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
596 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
597 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
598 | |||
599 | OSAL_Info("Update the OMX Component structures with Codec Structures"); | ||
600 | |||
601 | pH264VEComp->pVidEncStaticParams->videnc2Params.encodingPreset = pH264VEComp->pVidEncStatus->videnc2Status.encodingPreset; | ||
602 | |||
603 | pH264VEComp->pVidEncStaticParams->videnc2Params.rateControlPreset = pH264VEComp->pVidEncStatus->videnc2Status.rateControlPreset; | ||
604 | |||
605 | pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = pH264VEComp->pVidEncStatus->videnc2Status.maxInterFrameInterval; | ||
606 | |||
607 | pH264VEComp->pVidEncStaticParams->videnc2Params.inputChromaFormat = pH264VEComp->pVidEncStatus->videnc2Status.inputChromaFormat; | ||
608 | |||
609 | pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType = pH264VEComp->pVidEncStatus->videnc2Status.inputContentType; | ||
610 | |||
611 | pH264VEComp->pVidEncStaticParams->videnc2Params.operatingMode = pH264VEComp->pVidEncStatus->videnc2Status.operatingMode; | ||
612 | |||
613 | pH264VEComp->pVidEncStaticParams->videnc2Params.profile = pH264VEComp->pVidEncStatus->videnc2Status.profile; | ||
614 | |||
615 | pH264VEComp->pVidEncStaticParams->videnc2Params.level = pH264VEComp->pVidEncStatus->videnc2Status.level; | ||
616 | |||
617 | pH264VEComp->pVidEncStaticParams->videnc2Params.inputDataMode = pH264VEComp->pVidEncStatus->videnc2Status.inputDataMode; | ||
618 | pH264VEComp->pVidEncStaticParams->videnc2Params.outputDataMode = pH264VEComp->pVidEncStatus->videnc2Status.outputDataMode; | ||
619 | |||
620 | OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams), &(pH264VEComp->pVidEncStatus->videnc2Status.encDynamicParams), | ||
621 | sizeof (IVIDENC2_DynamicParams)); | ||
622 | |||
623 | OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->rateControlParams), &(pH264VEComp->pVidEncStatus->rateControlParams), | ||
624 | sizeof (IH264ENC_RateControlParams)); | ||
625 | |||
626 | OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->interCodingParams), &(pH264VEComp->pVidEncStatus->interCodingParams), | ||
627 | sizeof (IH264ENC_InterCodingParams)); | ||
628 | |||
629 | OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->intraCodingParams), &(pH264VEComp->pVidEncStatus->intraCodingParams), | ||
630 | sizeof (IH264ENC_IntraCodingParams)); | ||
631 | |||
632 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->nalUnitControlParams), &(pH264VEComp->pVidEncStatus->nalUnitControlParams), | ||
633 | sizeof (IH264ENC_NALUControlParams)); | ||
634 | |||
635 | OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->sliceCodingParams), &(pH264VEComp->pVidEncStatus->sliceCodingParams), | ||
636 | sizeof (IH264ENC_SliceCodingParams)); | ||
637 | |||
638 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->loopFilterParams), &(pH264VEComp->pVidEncStatus->loopFilterParams), | ||
639 | sizeof (IH264ENC_LoopFilterParams)); | ||
640 | |||
641 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->fmoCodingParams), &(pH264VEComp->pVidEncStatus->fmoCodingParams), | ||
642 | sizeof (IH264ENC_FMOCodingParams)); | ||
643 | |||
644 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->vuiCodingParams), &(pH264VEComp->pVidEncStatus->vuiCodingParams), | ||
645 | sizeof (IH264ENC_VUICodingParams)); | ||
646 | |||
647 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->stereoInfoParams), &(pH264VEComp->pVidEncStatus->stereoInfoParams), | ||
648 | sizeof (IH264ENC_StereoInfoParams)); | ||
649 | |||
650 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->framePackingSEIParams), &(pH264VEComp->pVidEncStatus->framePackingSEIParams), | ||
651 | sizeof (IH264ENC_FramePackingSEIParams)); | ||
652 | |||
653 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->svcCodingParams), &(pH264VEComp->pVidEncStatus->svcCodingParams), | ||
654 | sizeof (IH264ENC_SVCCodingParams)); | ||
655 | |||
656 | pH264VEComp->pVidEncStaticParams->interlaceCodingType = pH264VEComp->pVidEncStatus->interlaceCodingType; | ||
657 | |||
658 | pH264VEComp->pVidEncStaticParams->bottomFieldIntra = pH264VEComp->pVidEncStatus->bottomFieldIntra; | ||
659 | |||
660 | pH264VEComp->pVidEncStaticParams->gopStructure = pH264VEComp->pVidEncStatus->gopStructure; | ||
661 | |||
662 | pH264VEComp->pVidEncStaticParams->entropyCodingMode = pH264VEComp->pVidEncStatus->entropyCodingMode; | ||
663 | |||
664 | pH264VEComp->pVidEncStaticParams->transformBlockSize =pH264VEComp->pVidEncStatus->transformBlockSize; | ||
665 | |||
666 | pH264VEComp->pVidEncStaticParams->log2MaxFNumMinus4 = pH264VEComp->pVidEncStatus->log2MaxFNumMinus4; | ||
667 | |||
668 | pH264VEComp->pVidEncStaticParams->picOrderCountType = pH264VEComp->pVidEncStatus->picOrderCountType; | ||
669 | |||
670 | pH264VEComp->pVidEncStaticParams->enableWatermark = pH264VEComp->pVidEncStatus->enableWatermark; | ||
671 | |||
672 | pH264VEComp->pVidEncStaticParams->IDRFrameInterval =pH264VEComp->pVidEncStatus->IDRFrameInterval; | ||
673 | |||
674 | pH264VEComp->pVidEncStaticParams->maxIntraFrameInterval =pH264VEComp->pVidEncStatus->maxIntraFrameInterval; | ||
675 | |||
676 | pH264VEComp->pVidEncStaticParams->debugTraceLevel = pH264VEComp->pVidEncStatus->debugTraceLevel; | ||
677 | |||
678 | pH264VEComp->pVidEncStaticParams->lastNFramesToLog = pH264VEComp->pVidEncStatus->lastNFramesToLog; | ||
679 | |||
680 | pH264VEComp->pVidEncStaticParams->enableAnalyticinfo =pH264VEComp->pVidEncStatus->enableAnalyticinfo; | ||
681 | |||
682 | pH264VEComp->pVidEncStaticParams->enableGMVSei =pH264VEComp->pVidEncStatus->enableGMVSei; | ||
683 | |||
684 | pH264VEComp->pVidEncStaticParams->constraintSetFlags =pH264VEComp->pVidEncStatus->constraintSetFlags; | ||
685 | |||
686 | pH264VEComp->pVidEncStaticParams->enableRCDO =pH264VEComp->pVidEncStatus->enableRCDO; | ||
687 | |||
688 | pH264VEComp->pVidEncStaticParams->enableLongTermRefFrame =pH264VEComp->pVidEncStatus->enableLongTermRefFrame; | ||
689 | |||
690 | pH264VEComp->pVidEncStaticParams->LTRPPeriod =pH264VEComp->pVidEncStatus->LTRPPeriod; | ||
691 | |||
692 | pH264VEComp->pVidEncStaticParams->numTemporalLayer =pH264VEComp->pVidEncStatus->numTemporalLayer; | ||
693 | |||
694 | pH264VEComp->pVidEncStaticParams->referencePicMarking =pH264VEComp->pVidEncStatus->referencePicMarking; | ||
695 | |||
696 | pH264VEComp->pVidEncDynamicParams->searchCenter.x = pH264VEComp->pVidEncStatus->searchCenter.x; | ||
697 | |||
698 | pH264VEComp->pVidEncDynamicParams->searchCenter.x = pH264VEComp->pVidEncStatus->searchCenter.y; | ||
699 | |||
700 | pH264VEComp->pVidEncDynamicParams->enableStaticMBCount =pH264VEComp->pVidEncStatus->enableStaticMBCount; | ||
701 | |||
702 | pH264VEComp->pVidEncDynamicParams->enableROI = pH264VEComp->pVidEncStatus->enableROI; | ||
703 | |||
704 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
705 | tState=pH264VEComp->sBase.tCurState; | ||
706 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
707 | |||
708 | if((tState == OMX_StateLoaded) || (tState == OMX_StateIdle)) { | ||
709 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->rateControlParams), &(pH264VEComp->pVidEncStatus->rateControlParams), | ||
710 | sizeof (IH264ENC_RateControlParams)); | ||
711 | |||
712 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->interCodingParams), &(pH264VEComp->pVidEncStatus->interCodingParams), | ||
713 | sizeof (IH264ENC_InterCodingParams)); | ||
714 | |||
715 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->sliceCodingParams), &(pH264VEComp->pVidEncStatus->sliceCodingParams), | ||
716 | sizeof (IH264ENC_SliceCodingParams)); | ||
717 | |||
718 | OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->intraCodingParams), &(pH264VEComp->pVidEncStatus->intraCodingParams), | ||
719 | sizeof (IH264ENC_IntraCodingParams)); | ||
720 | } | ||
721 | |||
722 | EXIT: | ||
723 | if( eError != OMX_ErrorNone ) { | ||
724 | OSAL_ErrorTrace("in fn OMXH264VE_UpdateParams"); | ||
725 | } | ||
726 | |||
727 | return (eError); | ||
728 | } | ||
729 | |||
730 | OMX_ERRORTYPE OMXH264VE_FLUSHLockedBuffers(OMX_HANDLETYPE hComponent) | ||
731 | { | ||
732 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
733 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
734 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
735 | OMX_U32 i; | ||
736 | |||
737 | /* Check the input parameters */ | ||
738 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
739 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
740 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
741 | |||
742 | for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) { | ||
743 | if(pH264VEComp->pCodecInBufferArray && pH264VEComp->pCodecInBufferArray[i]) { | ||
744 | OMXBase_BufHdrPvtData *pPvtData = (OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate); | ||
745 | if (pPvtData->bufSt == OWNED_BY_CODEC ) { | ||
746 | pH264VEComp->pCodecInBufferArray[i]->nOffset = 0; | ||
747 | /*update the status to free*/ | ||
748 | pPvtData->bufSt = OWNED_BY_US; | ||
749 | pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT, pH264VEComp->pCodecInBufferArray[i]); | ||
750 | } | ||
751 | } | ||
752 | } | ||
753 | |||
754 | EXIT: | ||
755 | return (eError); | ||
756 | } | ||
757 | |||
758 | OMX_ERRORTYPE OMXH264VE_GetNextFreeBufHdr(OMX_HANDLETYPE hComponent, OMX_S32 *nBuffIndex, OMX_U32 nPortIndex) | ||
759 | { | ||
760 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
761 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
762 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
763 | OMX_BOOL bFreeBuffFound = OMX_FALSE; | ||
764 | OMX_S32 LBufIndex = -1; | ||
765 | OMX_U32 i; | ||
766 | |||
767 | /* Check the input parameters */ | ||
768 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
769 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
770 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
771 | |||
772 | if( nPortIndex == OMX_H264VE_INPUT_PORT ) { | ||
773 | for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) { | ||
774 | if(!pH264VEComp->pCodecInBufferArray[i] || | ||
775 | ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate))->bufSt != OWNED_BY_CODEC ) { | ||
776 | bFreeBuffFound=OMX_TRUE; | ||
777 | LBufIndex=i; | ||
778 | break; | ||
779 | } | ||
780 | } | ||
781 | } else { | ||
782 | eError = OMX_ErrorBadParameter; | ||
783 | } | ||
784 | |||
785 | EXIT: | ||
786 | |||
787 | if( bFreeBuffFound ) { | ||
788 | *nBuffIndex=LBufIndex; | ||
789 | } else { | ||
790 | *nBuffIndex=-1; | ||
791 | } | ||
792 | return (eError); | ||
793 | } | ||
794 | |||
795 | OMX_ERRORTYPE OMXH264VE_SetDynamicParamsToCodec(OMX_HANDLETYPE hComponent) | ||
796 | { | ||
797 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
798 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
799 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
800 | XDAS_Int32 retval = 0; | ||
801 | |||
802 | /* Check the input parameters */ | ||
803 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
804 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
805 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
806 | |||
807 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.size = sizeof(IH264ENC_DynamicParams); | ||
808 | pH264VEComp->pVidEncStatus->videnc2Status.size = sizeof(IH264ENC_Status); | ||
809 | |||
810 | if((pH264VEComp->bSendCodecConfig)) { | ||
811 | pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER; | ||
812 | pH264VEComp->nCodecConfigSize = 0; | ||
813 | pH264VEComp->bAfterGenHeader = OMX_FALSE; | ||
814 | } | ||
815 | |||
816 | pH264VEComp->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset = 2; //Existing | ||
817 | |||
818 | pH264VEComp->pVidEncDynamicParams->interCodingParams.interCodingPreset = 2; //Existing | ||
819 | |||
820 | pH264VEComp->pVidEncDynamicParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_EXISTING; | ||
821 | |||
822 | pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = 2; //Existing | ||
823 | |||
824 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
825 | pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_CODEC; | ||
826 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
827 | |||
828 | eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_SETPARAMS, | ||
829 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
830 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval); | ||
831 | if( retval == VIDENC2_EFAIL ) { | ||
832 | ALOGE("pH264VEComp->pVidEncStatus->videnc2Status.extendedError = %x", | ||
833 | (OMX_U32)pH264VEComp->pVidEncStatus->videnc2Status.extendedError); | ||
834 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError); | ||
835 | OMX_CHECK(eError == OMX_ErrorNone, eError); | ||
836 | } | ||
837 | |||
838 | |||
839 | EXIT: | ||
840 | return (eError); | ||
841 | } | ||
842 | |||
843 | OMX_ERRORTYPE OMXH264VE_GetNumCodecLockedBuffers(OMX_HANDLETYPE hComponent, OMX_U32 *nLockedBuffCount) | ||
844 | { | ||
845 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
846 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
847 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
848 | OMX_U32 LBuffLockedCount = 0; | ||
849 | OMX_U32 i; | ||
850 | |||
851 | /* Check the input parameters */ | ||
852 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
853 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
854 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
855 | |||
856 | for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) { | ||
857 | if((pH264VEComp->pCodecInBufferArray[i]) && | ||
858 | ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate))->bufSt == OWNED_BY_CODEC ) { | ||
859 | LBuffLockedCount++; | ||
860 | |||
861 | } | ||
862 | } | ||
863 | |||
864 | *nLockedBuffCount=LBuffLockedCount; | ||
865 | |||
866 | EXIT: | ||
867 | return (eError); | ||
868 | } | ||
869 | |||
870 | OMX_ERRORTYPE OMXH264VE_VISACONTROL(VIDENC2_Handle handle, IVIDENC2_Cmd id, IVIDENC2_DynamicParams *dynParams, | ||
871 | IVIDENC2_Status *status, OMX_HANDLETYPE hComponent, XDAS_Int32 *retval) | ||
872 | { | ||
873 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
874 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
875 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
876 | (void)handle; | ||
877 | |||
878 | /*Check for the Params*/ | ||
879 | OMX_CHECK(((hComponent != NULL) && (dynParams != NULL) && (status != NULL) && (retval != NULL)), OMX_ErrorBadParameter); | ||
880 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
881 | pH264VEComp = pHandle->pComponentPrivate; | ||
882 | |||
883 | (*retval) = VIDENC2_control(pH264VEComp->pVidEncHandle, id, dynParams, status); | ||
884 | |||
885 | EXIT: | ||
886 | return (eError); | ||
887 | } | ||
888 | |||
889 | |||
890 | OMX_ERRORTYPE OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(OMX_HANDLETYPE hComponent, XDAS_Int32 *retval) | ||
891 | { | ||
892 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
893 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
894 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
895 | PARAMS_UPDATE_STATUS bLCallxDMSetParams = NO_PARAM_CHANGE; | ||
896 | OMX_U32 sLretval = VIDENC2_EOK; | ||
897 | |||
898 | /*Check for the Params*/ | ||
899 | OMX_CHECK(((hComponent != NULL) && (retval != NULL)), OMX_ErrorBadParameter); | ||
900 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
901 | pH264VEComp = pHandle->pComponentPrivate; | ||
902 | |||
903 | OSAL_Info("Before the Codec Process call"); | ||
904 | sLretval = VIDENC2_process(pH264VEComp->pVidEncHandle, | ||
905 | (pH264VEComp->pVedEncInBufs), | ||
906 | (pH264VEComp->pVedEncOutBufs), | ||
907 | (IVIDENC2_InArgs *)(pH264VEComp->pVidEncInArgs), | ||
908 | (IVIDENC2_OutArgs *)(pH264VEComp->pVidEncOutArgs)); | ||
909 | |||
910 | if( sLretval == (OMX_U32)VIDENC2_EFAIL ) { | ||
911 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncOutArgs->videnc2OutArgs.extendedError, eError); | ||
912 | if( eError != OMX_ErrorNone ) { | ||
913 | ALOGE("Got error 0x%x from the Codec Process call", eError); | ||
914 | goto UPDATE_PARAMS; | ||
915 | } | ||
916 | } | ||
917 | |||
918 | /* Get the Codec Status Parameters if there has been a setconfig which has been translated to the codec */ | ||
919 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
920 | bLCallxDMSetParams=pH264VEComp->bCallxDMSetParams; | ||
921 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
922 | |||
923 | if( bLCallxDMSetParams == PARAMS_UPDATED_AT_CODEC ) { | ||
924 | OSAL_Info("Update the Codec Params after Codec Process call: call xDM control->GetStatus"); | ||
925 | sLretval = VIDENC2_control(pH264VEComp->pVidEncHandle, XDM_GETSTATUS, | ||
926 | (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams), | ||
927 | (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus)); | ||
928 | if( sLretval == (OMX_U32)VIDENC2_EFAIL ) { | ||
929 | OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncOutArgs->videnc2OutArgs.extendedError, eError); | ||
930 | if( eError != OMX_ErrorNone ) { | ||
931 | OSAL_ErrorTrace("Got error 0x%x from the Codec Get Status Control call", eError); | ||
932 | goto UPDATE_PARAMS; | ||
933 | } | ||
934 | } | ||
935 | } | ||
936 | |||
937 | UPDATE_PARAMS: | ||
938 | if( eError == OMX_ErrorNone ) { | ||
939 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
940 | bLCallxDMSetParams = pH264VEComp->bCallxDMSetParams; | ||
941 | if( bLCallxDMSetParams == PARAMS_UPDATED_AT_CODEC ) { | ||
942 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
943 | eError= OMXH264VE_UpdateParams(hComponent); | ||
944 | OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND); | ||
945 | pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE; | ||
946 | } | ||
947 | OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex); | ||
948 | } | ||
949 | |||
950 | EXIT: | ||
951 | if( retval ) { | ||
952 | *retval = sLretval; | ||
953 | } | ||
954 | |||
955 | return (eError); | ||
956 | } | ||
957 | |||
958 | /* Function to check the max bit rate supported as per profile & level settings*/ | ||
959 | OMX_ERRORTYPE OMXH264VE_CheckBitRateCap(OMX_U32 targetBitRate, OMX_HANDLETYPE hComponent) | ||
960 | { | ||
961 | OMX_COMPONENTTYPE *pHandle = NULL; | ||
962 | OMXH264VidEncComp *pH264VEComp = NULL; | ||
963 | OMX_ERRORTYPE eError = OMX_ErrorNone; | ||
964 | OMX_VIDEO_AVCLEVELTYPE eOMXLevel; | ||
965 | OMX_U32 nTableIndex = 0xFFFFFFFF; | ||
966 | |||
967 | /* Check the input parameters */ | ||
968 | OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter); | ||
969 | pHandle = (OMX_COMPONENTTYPE *)hComponent; | ||
970 | pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate; | ||
971 | OMX_CHECK((pH264VEComp != NULL), OMX_ErrorBadParameter); | ||
972 | |||
973 | MAP_CODEC_TO_OMX_AVCLEVEL(pH264VEComp->pVidEncStaticParams->videnc2Params.level, eOMXLevel, nTableIndex, eError); | ||
974 | OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting); | ||
975 | OMX_CHECK(nTableIndex != 0xFFFFFFFF, OMX_ErrorUnsupportedSetting); | ||
976 | |||
977 | if( pH264VEComp->pVidEncStaticParams->videnc2Params.profile == IH264_HIGH_PROFILE ) { | ||
978 | ALOGE(" HIGH PROFILE, Level %d Max Bit Rate Supported = %d", eOMXLevel, OMX_H264_HP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport); | ||
979 | OMX_CHECK(targetBitRate <= OMX_H264_HP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport, OMX_ErrorUnsupportedSetting); | ||
980 | } else { | ||
981 | ALOGE(" BASE/MAIN PROFILE, Level %d Max Bit Rate Supported = %d", eOMXLevel, OMX_H264_BP_MP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport); | ||
982 | OMX_CHECK(targetBitRate <= OMX_H264_BP_MP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport, OMX_ErrorUnsupportedSetting); | ||
983 | } | ||
984 | |||
985 | EXIT: | ||
986 | return (eError); | ||
987 | } | ||
988 | |||
989 | |||