Commit | Line | Data |
---|---|---|
c6f4bc34 YK |
1 | /* |
2 | * | |
3 | * Copyright 2012 Samsung Electronics S.LSI Co. LTD | |
4 | * | |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | ||
18 | /* | |
19 | * @file Exynos_OMX_VencControl.c | |
20 | * @brief | |
21 | * @author SeungBeom Kim (sbcrux.kim@samsung.com) | |
22 | * @version 2.0.0 | |
23 | * @history | |
24 | * 2012.02.20 : Create | |
25 | */ | |
26 | ||
27 | #include <stdio.h> | |
28 | #include <stdlib.h> | |
29 | #include <string.h> | |
30 | #include "Exynos_OMX_Macros.h" | |
31 | #include "Exynos_OSAL_Event.h" | |
32 | #include "Exynos_OMX_Venc.h" | |
33 | #include "Exynos_OMX_VencControl.h" | |
34 | #include "Exynos_OMX_Basecomponent.h" | |
35 | #include "Exynos_OSAL_Thread.h" | |
36 | #include "Exynos_OSAL_Semaphore.h" | |
37 | #include "Exynos_OSAL_Mutex.h" | |
38 | #include "Exynos_OSAL_ETC.h" | |
39 | #include "Exynos_OSAL_SharedMemory.h" | |
40 | ||
41 | #ifdef USE_ANB | |
42 | #include "Exynos_OSAL_Android.h" | |
43 | #endif | |
44 | ||
45 | #undef EXYNOS_LOG_TAG | |
46 | #define EXYNOS_LOG_TAG "EXYNOS_VIDEO_ENCCONTROL" | |
47 | #define EXYNOS_LOG_OFF | |
48 | //#define EXYNOS_TRACE_ON | |
49 | #include "Exynos_OSAL_Log.h" | |
50 | ||
51 | ||
52 | OMX_ERRORTYPE Exynos_OMX_UseBuffer( | |
53 | OMX_IN OMX_HANDLETYPE hComponent, | |
54 | OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, | |
55 | OMX_IN OMX_U32 nPortIndex, | |
56 | OMX_IN OMX_PTR pAppPrivate, | |
57 | OMX_IN OMX_U32 nSizeBytes, | |
58 | OMX_IN OMX_U8 *pBuffer) | |
59 | { | |
e4e150b8 HK |
60 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
61 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
62 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
63 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
64 | OMX_BUFFERHEADERTYPE *pTempBufferHdr = NULL; | |
65 | OMX_U32 i = 0; | |
c6f4bc34 YK |
66 | |
67 | FunctionIn(); | |
68 | ||
69 | if (hComponent == NULL) { | |
70 | ret = OMX_ErrorBadParameter; | |
71 | goto EXIT; | |
72 | } | |
73 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
e4e150b8 | 74 | |
c6f4bc34 YK |
75 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
76 | if (ret != OMX_ErrorNone) { | |
77 | goto EXIT; | |
78 | } | |
79 | ||
80 | if (pOMXComponent->pComponentPrivate == NULL) { | |
81 | ret = OMX_ErrorBadParameter; | |
82 | goto EXIT; | |
83 | } | |
84 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
85 | ||
c6f4bc34 YK |
86 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { |
87 | ret = OMX_ErrorBadPortIndex; | |
88 | goto EXIT; | |
89 | } | |
e4e150b8 HK |
90 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
91 | ||
c6f4bc34 YK |
92 | if (pExynosPort->portState != OMX_StateIdle) { |
93 | ret = OMX_ErrorIncorrectStateOperation; | |
94 | goto EXIT; | |
95 | } | |
96 | ||
97 | if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) { | |
98 | ret = OMX_ErrorBadPortIndex; | |
99 | goto EXIT; | |
100 | } | |
101 | ||
e4e150b8 HK |
102 | pTempBufferHdr = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); |
103 | if (pTempBufferHdr == NULL) { | |
c6f4bc34 YK |
104 | ret = OMX_ErrorInsufficientResources; |
105 | goto EXIT; | |
106 | } | |
e4e150b8 | 107 | Exynos_OSAL_Memset(pTempBufferHdr, 0, sizeof(OMX_BUFFERHEADERTYPE)); |
c6f4bc34 YK |
108 | |
109 | for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) { | |
110 | if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { | |
e4e150b8 | 111 | pExynosPort->extendBufferHeader[i].OMXBufferHeader = pTempBufferHdr; |
c6f4bc34 | 112 | pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED); |
e4e150b8 HK |
113 | INIT_SET_SIZE_VERSION(pTempBufferHdr, OMX_BUFFERHEADERTYPE); |
114 | pTempBufferHdr->pBuffer = pBuffer; | |
115 | pTempBufferHdr->nAllocLen = nSizeBytes; | |
116 | pTempBufferHdr->pAppPrivate = pAppPrivate; | |
c6f4bc34 | 117 | if (nPortIndex == INPUT_PORT_INDEX) |
e4e150b8 | 118 | pTempBufferHdr->nInputPortIndex = INPUT_PORT_INDEX; |
c6f4bc34 | 119 | else |
e4e150b8 | 120 | pTempBufferHdr->nOutputPortIndex = OUTPUT_PORT_INDEX; |
c6f4bc34 YK |
121 | |
122 | pExynosPort->assignedBufferNum++; | |
123 | if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) { | |
124 | pExynosPort->portDefinition.bPopulated = OMX_TRUE; | |
125 | /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */ | |
126 | Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource); | |
127 | /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */ | |
128 | } | |
e4e150b8 | 129 | *ppBufferHdr = pTempBufferHdr; |
c6f4bc34 YK |
130 | ret = OMX_ErrorNone; |
131 | goto EXIT; | |
132 | } | |
133 | } | |
134 | ||
e4e150b8 | 135 | Exynos_OSAL_Free(pTempBufferHdr); |
c6f4bc34 YK |
136 | ret = OMX_ErrorInsufficientResources; |
137 | ||
138 | EXIT: | |
139 | FunctionOut(); | |
140 | ||
141 | return ret; | |
142 | } | |
143 | ||
144 | OMX_ERRORTYPE Exynos_OMX_AllocateBuffer( | |
145 | OMX_IN OMX_HANDLETYPE hComponent, | |
e4e150b8 | 146 | OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, |
c6f4bc34 YK |
147 | OMX_IN OMX_U32 nPortIndex, |
148 | OMX_IN OMX_PTR pAppPrivate, | |
149 | OMX_IN OMX_U32 nSizeBytes) | |
150 | { | |
e4e150b8 HK |
151 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
152 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
153 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
154 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
155 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
156 | OMX_BUFFERHEADERTYPE *pTempBufferHdr = NULL; | |
157 | OMX_U8 *pTempBuffer = NULL; | |
158 | int fdTempBuffer = -1; | |
026e5b24 | 159 | MEMORY_TYPE eMemType = SYSTEM_MEMORY; |
e4e150b8 | 160 | OMX_U32 i = 0; |
c6f4bc34 YK |
161 | |
162 | FunctionIn(); | |
163 | ||
164 | if (hComponent == NULL) { | |
165 | ret = OMX_ErrorBadParameter; | |
166 | goto EXIT; | |
167 | } | |
168 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
e4e150b8 | 169 | |
c6f4bc34 YK |
170 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
171 | if (ret != OMX_ErrorNone) { | |
172 | goto EXIT; | |
173 | } | |
174 | ||
175 | if (pOMXComponent->pComponentPrivate == NULL) { | |
176 | ret = OMX_ErrorBadParameter; | |
177 | goto EXIT; | |
178 | } | |
179 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
e4e150b8 HK |
180 | |
181 | if (pExynosComponent->hComponentHandle == NULL) { | |
182 | ret = OMX_ErrorBadParameter; | |
183 | goto EXIT; | |
184 | } | |
c6f4bc34 YK |
185 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; |
186 | ||
c6f4bc34 YK |
187 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { |
188 | ret = OMX_ErrorBadPortIndex; | |
189 | goto EXIT; | |
190 | } | |
e4e150b8 | 191 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
c6f4bc34 YK |
192 | /* |
193 | if (pExynosPort->portState != OMX_StateIdle ) { | |
194 | ret = OMX_ErrorIncorrectStateOperation; | |
195 | goto EXIT; | |
196 | } | |
197 | */ | |
198 | if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) { | |
199 | ret = OMX_ErrorBadPortIndex; | |
200 | goto EXIT; | |
201 | } | |
202 | ||
10db72aa SK |
203 | if ((pVideoEnc->bDRMPlayerMode == OMX_TRUE) && |
204 | (nPortIndex == OUTPUT_PORT_INDEX)) { | |
205 | eMemType = SECURE_MEMORY; | |
206 | } else if (pExynosPort->bNeedContigMem == OMX_TRUE) { | |
c31a957e TK |
207 | eMemType = CONTIG_MEMORY; |
208 | } else if ((nPortIndex == INPUT_PORT_INDEX) && | |
10db72aa | 209 | (pExynosPort->bufferProcessType & BUFFER_SHARE)) { |
e4e150b8 | 210 | eMemType = NORMAL_MEMORY; |
026e5b24 | 211 | } |
e4e150b8 HK |
212 | |
213 | pTempBuffer = Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, nSizeBytes, eMemType); | |
214 | if (pTempBuffer == NULL) { | |
c6f4bc34 YK |
215 | ret = OMX_ErrorInsufficientResources; |
216 | goto EXIT; | |
217 | } | |
e4e150b8 | 218 | fdTempBuffer = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, pTempBuffer); |
c6f4bc34 | 219 | |
e4e150b8 HK |
220 | pTempBufferHdr = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); |
221 | if (pTempBufferHdr == NULL) { | |
222 | Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pTempBuffer); | |
c6f4bc34 YK |
223 | ret = OMX_ErrorInsufficientResources; |
224 | goto EXIT; | |
225 | } | |
e4e150b8 | 226 | Exynos_OSAL_Memset(pTempBufferHdr, 0, sizeof(OMX_BUFFERHEADERTYPE)); |
c6f4bc34 YK |
227 | |
228 | for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) { | |
229 | if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { | |
e4e150b8 HK |
230 | pExynosPort->extendBufferHeader[i].OMXBufferHeader = pTempBufferHdr; |
231 | pExynosPort->extendBufferHeader[i].buf_fd[0] = fdTempBuffer; | |
c6f4bc34 | 232 | pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED); |
e4e150b8 | 233 | INIT_SET_SIZE_VERSION(pTempBufferHdr, OMX_BUFFERHEADERTYPE); |
10db72aa SK |
234 | if (eMemType == SECURE_MEMORY) |
235 | pTempBufferHdr->pBuffer = fdTempBuffer; | |
236 | else | |
237 | pTempBufferHdr->pBuffer = pTempBuffer; | |
e4e150b8 HK |
238 | pTempBufferHdr->nAllocLen = nSizeBytes; |
239 | pTempBufferHdr->pAppPrivate = pAppPrivate; | |
c6f4bc34 | 240 | if (nPortIndex == INPUT_PORT_INDEX) |
e4e150b8 | 241 | pTempBufferHdr->nInputPortIndex = INPUT_PORT_INDEX; |
c6f4bc34 | 242 | else |
e4e150b8 | 243 | pTempBufferHdr->nOutputPortIndex = OUTPUT_PORT_INDEX; |
c6f4bc34 YK |
244 | pExynosPort->assignedBufferNum++; |
245 | if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) { | |
246 | pExynosPort->portDefinition.bPopulated = OMX_TRUE; | |
247 | /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */ | |
248 | Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource); | |
249 | /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */ | |
250 | } | |
e4e150b8 | 251 | *ppBufferHdr = pTempBufferHdr; |
c6f4bc34 YK |
252 | ret = OMX_ErrorNone; |
253 | goto EXIT; | |
254 | } | |
255 | } | |
256 | ||
e4e150b8 HK |
257 | Exynos_OSAL_Free(pTempBufferHdr); |
258 | Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pTempBuffer); | |
c6f4bc34 YK |
259 | |
260 | ret = OMX_ErrorInsufficientResources; | |
261 | ||
262 | EXIT: | |
263 | FunctionOut(); | |
264 | ||
265 | return ret; | |
266 | } | |
267 | ||
268 | OMX_ERRORTYPE Exynos_OMX_FreeBuffer( | |
e4e150b8 HK |
269 | OMX_IN OMX_HANDLETYPE hComponent, |
270 | OMX_IN OMX_U32 nPortIndex, | |
c6f4bc34 YK |
271 | OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr) |
272 | { | |
e4e150b8 HK |
273 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
274 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
275 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
276 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
277 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
278 | OMX_BUFFERHEADERTYPE *pOMXBufferHdr = NULL; | |
279 | OMX_U32 i = 0; | |
c6f4bc34 YK |
280 | |
281 | FunctionIn(); | |
282 | ||
283 | if (hComponent == NULL) { | |
284 | ret = OMX_ErrorBadParameter; | |
285 | goto EXIT; | |
286 | } | |
287 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
e4e150b8 | 288 | |
c6f4bc34 YK |
289 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
290 | if (ret != OMX_ErrorNone) { | |
291 | goto EXIT; | |
292 | } | |
293 | ||
294 | if (pOMXComponent->pComponentPrivate == NULL) { | |
295 | ret = OMX_ErrorBadParameter; | |
296 | goto EXIT; | |
297 | } | |
298 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
e4e150b8 HK |
299 | |
300 | if (pExynosComponent->hComponentHandle == NULL) { | |
301 | ret = OMX_ErrorBadParameter; | |
302 | goto EXIT; | |
303 | } | |
c6f4bc34 | 304 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; |
e4e150b8 HK |
305 | |
306 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { | |
307 | ret = OMX_ErrorBadPortIndex; | |
308 | goto EXIT; | |
309 | } | |
c6f4bc34 YK |
310 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
311 | ||
312 | if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) { | |
313 | ret = OMX_ErrorBadPortIndex; | |
314 | goto EXIT; | |
315 | } | |
316 | ||
4650bb72 TK |
317 | if (((pExynosPort->portState != OMX_StateLoaded) && |
318 | (pExynosPort->portState != OMX_StateInvalid)) && | |
319 | (pExynosPort->portDefinition.bEnabled != OMX_FALSE)) { | |
c6f4bc34 YK |
320 | (*(pExynosComponent->pCallbacks->EventHandler)) (pOMXComponent, |
321 | pExynosComponent->callbackData, | |
322 | (OMX_U32)OMX_EventError, | |
323 | (OMX_U32)OMX_ErrorPortUnpopulated, | |
324 | nPortIndex, NULL); | |
4650bb72 TK |
325 | ret = OMX_ErrorInvalidState; |
326 | goto EXIT; | |
c6f4bc34 YK |
327 | } |
328 | ||
329 | for (i = 0; i < /*pExynosPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) { | |
e4e150b8 HK |
330 | if ((pExynosPort->bufferStateAllocate[i] != BUFFER_STATE_FREE) && |
331 | (pExynosPort->extendBufferHeader[i].OMXBufferHeader != NULL)) { | |
332 | pOMXBufferHdr = pExynosPort->extendBufferHeader[i].OMXBufferHeader; | |
333 | ||
334 | if (pOMXBufferHdr->pBuffer == pBufferHdr->pBuffer) { | |
c6f4bc34 | 335 | if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) { |
10db72aa SK |
336 | if ((pVideoEnc->bDRMPlayerMode == OMX_TRUE) && |
337 | (nPortIndex == OUTPUT_PORT_INDEX)) { | |
338 | OMX_PTR mapBuffer = Exynos_OSAL_SharedMemory_IONToVirt(pVideoEnc->hSharedMemory, (int)pOMXBufferHdr->pBuffer); | |
339 | Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, mapBuffer); | |
340 | } else { | |
341 | Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pOMXBufferHdr->pBuffer); | |
342 | } | |
e4e150b8 | 343 | pOMXBufferHdr->pBuffer = NULL; |
c6f4bc34 YK |
344 | pBufferHdr->pBuffer = NULL; |
345 | } else if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) { | |
346 | ; /* None*/ | |
347 | } | |
348 | pExynosPort->assignedBufferNum--; | |
e4e150b8 | 349 | |
c6f4bc34 | 350 | if (pExynosPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) { |
e4e150b8 | 351 | Exynos_OSAL_Free(pOMXBufferHdr); |
c6f4bc34 YK |
352 | pExynosPort->extendBufferHeader[i].OMXBufferHeader = NULL; |
353 | pBufferHdr = NULL; | |
354 | } | |
e4e150b8 | 355 | |
c6f4bc34 YK |
356 | pExynosPort->bufferStateAllocate[i] = BUFFER_STATE_FREE; |
357 | ret = OMX_ErrorNone; | |
358 | goto EXIT; | |
359 | } | |
360 | } | |
361 | } | |
362 | ||
363 | EXIT: | |
e4e150b8 HK |
364 | if ((ret == OMX_ErrorNone) && |
365 | (pExynosPort->assignedBufferNum == 0)) { | |
366 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosPort->unloadedResource signal set"); | |
367 | /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */ | |
368 | Exynos_OSAL_SemaphorePost(pExynosPort->unloadedResource); | |
369 | /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */ | |
370 | pExynosPort->portDefinition.bPopulated = OMX_FALSE; | |
c6f4bc34 YK |
371 | } |
372 | ||
373 | FunctionOut(); | |
374 | ||
375 | return ret; | |
376 | } | |
377 | ||
e4e150b8 HK |
378 | OMX_ERRORTYPE Exynos_OMX_AllocateTunnelBuffer( |
379 | EXYNOS_OMX_BASEPORT *pOMXBasePort, | |
380 | OMX_U32 nPortIndex) | |
c6f4bc34 | 381 | { |
e4e150b8 HK |
382 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
383 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
384 | OMX_BUFFERHEADERTYPE *pTempBufferHdr = NULL; | |
385 | OMX_U8 *pTempBuffer = NULL; | |
386 | OMX_U32 nBufferSize = 0; | |
c6f4bc34 YK |
387 | OMX_PARAM_PORTDEFINITIONTYPE portDefinition; |
388 | ||
389 | ret = OMX_ErrorTunnelingUnsupported; | |
390 | EXIT: | |
391 | return ret; | |
392 | } | |
393 | ||
e4e150b8 HK |
394 | OMX_ERRORTYPE Exynos_OMX_FreeTunnelBuffer( |
395 | EXYNOS_OMX_BASEPORT *pOMXBasePort, | |
396 | OMX_U32 nPortIndex) | |
c6f4bc34 | 397 | { |
e4e150b8 HK |
398 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
399 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
400 | OMX_BUFFERHEADERTYPE *pTempBufferHdr = NULL; | |
401 | OMX_U8 *pTempBuffer = NULL; | |
402 | OMX_U32 nBufferSize = 0; | |
c6f4bc34 YK |
403 | |
404 | ret = OMX_ErrorTunnelingUnsupported; | |
405 | EXIT: | |
406 | return ret; | |
407 | } | |
408 | ||
409 | OMX_ERRORTYPE Exynos_OMX_ComponentTunnelRequest( | |
410 | OMX_IN OMX_HANDLETYPE hComp, | |
411 | OMX_IN OMX_U32 nPort, | |
412 | OMX_IN OMX_HANDLETYPE hTunneledComp, | |
413 | OMX_IN OMX_U32 nTunneledPort, | |
414 | OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup) | |
415 | { | |
416 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
417 | ||
418 | ret = OMX_ErrorTunnelingUnsupported; | |
419 | EXIT: | |
420 | return ret; | |
421 | } | |
422 | ||
e4e150b8 HK |
423 | OMX_ERRORTYPE Exynos_OMX_GetFlushBuffer( |
424 | EXYNOS_OMX_BASEPORT *pExynosPort, | |
425 | EXYNOS_OMX_DATABUFFER *pDataBuffer[]) | |
c6f4bc34 YK |
426 | { |
427 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
428 | ||
429 | FunctionIn(); | |
430 | ||
431 | *pDataBuffer = NULL; | |
432 | ||
433 | if (pExynosPort->portWayType == WAY1_PORT) { | |
434 | *pDataBuffer = &pExynosPort->way.port1WayDataBuffer.dataBuffer; | |
435 | } else if (pExynosPort->portWayType == WAY2_PORT) { | |
e4e150b8 HK |
436 | pDataBuffer[0] = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); |
437 | pDataBuffer[1] = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer); | |
c6f4bc34 YK |
438 | } |
439 | ||
440 | EXIT: | |
441 | FunctionOut(); | |
442 | ||
443 | return ret; | |
444 | } | |
445 | ||
e4e150b8 HK |
446 | OMX_ERRORTYPE Exynos_OMX_FlushPort( |
447 | OMX_COMPONENTTYPE *pOMXComponent, | |
448 | OMX_S32 nPortIndex) | |
c6f4bc34 | 449 | { |
e4e150b8 HK |
450 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
451 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
452 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
453 | OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; | |
454 | EXYNOS_OMX_DATABUFFER *pDataBuffer[2] = {NULL, NULL}; | |
455 | EXYNOS_OMX_MESSAGE *pMessage = NULL; | |
456 | OMX_S32 nSemaCnt = 0; | |
457 | int i = 0; | |
458 | ||
c6f4bc34 YK |
459 | FunctionIn(); |
460 | ||
e4e150b8 HK |
461 | if (pOMXComponent == NULL) { |
462 | ret = OMX_ErrorBadParameter; | |
463 | goto EXIT; | |
464 | } | |
465 | ||
466 | if (pOMXComponent->pComponentPrivate == NULL) { | |
467 | ret = OMX_ErrorBadParameter; | |
468 | goto EXIT; | |
469 | } | |
470 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
471 | ||
472 | if ((nPortIndex < 0) || | |
473 | (nPortIndex >= pExynosComponent->portParam.nPorts)) { | |
474 | ret = OMX_ErrorBadPortIndex; | |
475 | goto EXIT; | |
476 | } | |
477 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; | |
c6f4bc34 YK |
478 | |
479 | while (Exynos_OSAL_GetElemNum(&pExynosPort->bufferQ) > 0) { | |
e4e150b8 HK |
480 | Exynos_OSAL_Get_SemaphoreCount(pExynosPort->bufferSemID, &nSemaCnt); |
481 | if (nSemaCnt == 0) | |
482 | Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID); | |
483 | ||
484 | Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); | |
485 | pMessage = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); | |
486 | if ((pMessage != NULL) && | |
487 | (pMessage->messageType != EXYNOS_OMX_CommandFakeBuffer)) { | |
488 | pBufferHdr = (OMX_BUFFERHEADERTYPE *)pMessage->pCmdData; | |
489 | pBufferHdr->nFilledLen = 0; | |
490 | ||
491 | if (nPortIndex == OUTPUT_PORT_INDEX) { | |
492 | Exynos_OMX_OutputBufferReturn(pOMXComponent, pBufferHdr); | |
493 | } else if (nPortIndex == INPUT_PORT_INDEX) { | |
494 | Exynos_OMX_InputBufferReturn(pOMXComponent, pBufferHdr); | |
c6f4bc34 YK |
495 | } |
496 | } | |
e4e150b8 HK |
497 | Exynos_OSAL_Free(pMessage); |
498 | pMessage = NULL; | |
c6f4bc34 YK |
499 | } |
500 | ||
e4e150b8 HK |
501 | Exynos_OMX_GetFlushBuffer(pExynosPort, pDataBuffer); |
502 | if ((pDataBuffer[0] != NULL) && | |
503 | (pDataBuffer[0]->dataValid == OMX_TRUE)) { | |
504 | if (nPortIndex == INPUT_PORT_INDEX) | |
3858590d | 505 | Exynos_InputBufferReturn(pOMXComponent, pDataBuffer[0]); |
e4e150b8 | 506 | else if (nPortIndex == OUTPUT_PORT_INDEX) |
3858590d | 507 | Exynos_OutputBufferReturn(pOMXComponent, pDataBuffer[0]); |
e4e150b8 HK |
508 | } |
509 | if ((pDataBuffer[1] != NULL) && | |
510 | (pDataBuffer[1]->dataValid == OMX_TRUE)) { | |
511 | if (nPortIndex == INPUT_PORT_INDEX) | |
3858590d | 512 | Exynos_InputBufferReturn(pOMXComponent, pDataBuffer[1]); |
e4e150b8 | 513 | else if (nPortIndex == OUTPUT_PORT_INDEX) |
3858590d | 514 | Exynos_OutputBufferReturn(pOMXComponent, pDataBuffer[1]); |
c6f4bc34 YK |
515 | } |
516 | ||
517 | if (pExynosComponent->bMultiThreadProcess == OMX_TRUE) { | |
24ec2c82 | 518 | if (pExynosPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 | 519 | if (pExynosPort->processData.bufferHeader != NULL) { |
e4e150b8 | 520 | if (nPortIndex == INPUT_PORT_INDEX) { |
323488ff SK |
521 | #ifdef USE_METADATABUFFERTYPE |
522 | if ((pExynosPort->bStoreMetaData == OMX_TRUE) && | |
523 | (pExynosPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque)) { | |
524 | OMX_PTR ppBuf[MAX_BUFFER_PLANE]; | |
433e798a EC |
525 | if (OMX_ErrorNone == |
526 | Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pExynosPort->processData.bufferHeader->pBuffer, ppBuf)) | |
9d7f3c95 | 527 | Exynos_OSAL_UnlockANBHandle((OMX_U32)ppBuf[0]); |
323488ff SK |
528 | } |
529 | #endif | |
c6f4bc34 | 530 | Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader); |
e4e150b8 | 531 | } else if (nPortIndex == OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
532 | Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader); |
533 | } | |
534 | } | |
535 | Exynos_ResetCodecData(&pExynosPort->processData); | |
536 | ||
e4e150b8 | 537 | for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) { |
c6f4bc34 | 538 | if (pExynosPort->extendBufferHeader[i].bBufferInOMX == OMX_TRUE) { |
e4e150b8 HK |
539 | if (nPortIndex == OUTPUT_PORT_INDEX) { |
540 | Exynos_OMX_OutputBufferReturn(pOMXComponent, | |
541 | pExynosPort->extendBufferHeader[i].OMXBufferHeader); | |
542 | } else if (nPortIndex == INPUT_PORT_INDEX) { | |
323488ff SK |
543 | #ifdef USE_METADATABUFFERTYPE |
544 | if ((pExynosPort->bStoreMetaData == OMX_TRUE) && | |
545 | (pExynosPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque)) { | |
546 | OMX_PTR ppBuf[MAX_BUFFER_PLANE]; | |
433e798a EC |
547 | if (OMX_ErrorNone == |
548 | Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer, ppBuf)) | |
9d7f3c95 | 549 | Exynos_OSAL_UnlockANBHandle((OMX_U32)ppBuf[0]); |
323488ff SK |
550 | } |
551 | #endif | |
e4e150b8 HK |
552 | Exynos_OMX_InputBufferReturn(pOMXComponent, |
553 | pExynosPort->extendBufferHeader[i].OMXBufferHeader); | |
c6f4bc34 YK |
554 | } |
555 | } | |
556 | } | |
557 | } | |
558 | } else { | |
559 | Exynos_ResetCodecData(&pExynosPort->processData); | |
560 | } | |
561 | ||
433e798a EC |
562 | if (pExynosPort->bufferSemID != NULL) { |
563 | while (1) { | |
564 | OMX_S32 cnt = 0; | |
565 | Exynos_OSAL_Get_SemaphoreCount(pExynosPort->bufferSemID, &cnt); | |
566 | if (cnt == 0) | |
567 | break; | |
568 | else if (cnt > 0) | |
569 | Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); | |
570 | else if (cnt < 0) | |
571 | Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID); | |
572 | Exynos_OSAL_SleepMillisec(0); | |
573 | } | |
c6f4bc34 YK |
574 | } |
575 | Exynos_OSAL_ResetQueue(&pExynosPort->bufferQ); | |
576 | ||
577 | EXIT: | |
578 | FunctionOut(); | |
579 | ||
580 | return ret; | |
581 | } | |
582 | ||
e4e150b8 HK |
583 | OMX_ERRORTYPE Exynos_OMX_BufferFlush( |
584 | OMX_COMPONENTTYPE *pOMXComponent, | |
585 | OMX_S32 nPortIndex, | |
586 | OMX_BOOL bEvent) | |
c6f4bc34 | 587 | { |
e4e150b8 HK |
588 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
589 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
590 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
591 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
592 | EXYNOS_OMX_DATABUFFER *pDataBuffer[2] = {NULL, NULL}; | |
593 | OMX_U32 i = 0; | |
c6f4bc34 YK |
594 | |
595 | FunctionIn(); | |
596 | ||
597 | if (pOMXComponent == NULL) { | |
598 | ret = OMX_ErrorBadParameter; | |
599 | goto EXIT; | |
600 | } | |
e4e150b8 | 601 | |
c6f4bc34 YK |
602 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
603 | if (ret != OMX_ErrorNone) { | |
604 | goto EXIT; | |
605 | } | |
606 | ||
607 | if (pOMXComponent->pComponentPrivate == NULL) { | |
608 | ret = OMX_ErrorBadParameter; | |
609 | goto EXIT; | |
610 | } | |
611 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
e4e150b8 HK |
612 | |
613 | if (pExynosComponent->hComponentHandle == NULL) { | |
614 | ret = OMX_ErrorBadParameter; | |
615 | goto EXIT; | |
616 | } | |
c6f4bc34 YK |
617 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; |
618 | ||
e4e150b8 HK |
619 | if ((nPortIndex < 0) || |
620 | (nPortIndex >= pExynosComponent->portParam.nPorts)) { | |
621 | ret = OMX_ErrorBadPortIndex; | |
622 | goto EXIT; | |
623 | } | |
624 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; | |
625 | ||
c6f4bc34 YK |
626 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush start, port:%d", nPortIndex); |
627 | ||
e4e150b8 | 628 | pExynosPort->bIsPortFlushed = OMX_TRUE; |
c6f4bc34 YK |
629 | |
630 | if (pExynosComponent->bMultiThreadProcess == OMX_FALSE) { | |
631 | Exynos_OSAL_SignalSet(pExynosComponent->pauseEvent); | |
632 | } else { | |
e4e150b8 | 633 | Exynos_OSAL_SignalSet(pExynosPort->pauseEvent); |
c6f4bc34 YK |
634 | } |
635 | ||
e4e150b8 HK |
636 | Exynos_OMX_GetFlushBuffer(pExynosPort, pDataBuffer); |
637 | if (pDataBuffer[0] == NULL) { | |
638 | ret = OMX_ErrorBadParameter; | |
639 | goto EXIT; | |
640 | } | |
c6f4bc34 | 641 | |
e4e150b8 | 642 | if (pExynosPort->bufferProcessType & BUFFER_COPY) |
c6f4bc34 | 643 | Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID); |
433e798a EC |
644 | |
645 | if (pExynosPort->bufferSemID != NULL) { | |
646 | while (1) { | |
647 | OMX_S32 cnt = 0; | |
648 | Exynos_OSAL_Get_SemaphoreCount(pExynosPort->bufferSemID, &cnt); | |
649 | if (cnt > 0) | |
650 | break; | |
651 | else | |
652 | Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID); | |
653 | Exynos_OSAL_SleepMillisec(0); | |
654 | } | |
655 | } | |
c6f4bc34 YK |
656 | |
657 | pVideoEnc->exynos_codec_bufferProcessRun(pOMXComponent, nPortIndex); | |
e4e150b8 HK |
658 | |
659 | Exynos_OSAL_MutexLock(pDataBuffer[0]->bufferMutex); | |
c6f4bc34 | 660 | pVideoEnc->exynos_codec_stop(pOMXComponent, nPortIndex); |
e4e150b8 HK |
661 | |
662 | if (pDataBuffer[1] != NULL) | |
663 | Exynos_OSAL_MutexLock(pDataBuffer[1]->bufferMutex); | |
664 | ||
c6f4bc34 | 665 | ret = Exynos_OMX_FlushPort(pOMXComponent, nPortIndex); |
e4e150b8 HK |
666 | if (ret != OMX_ErrorNone) |
667 | goto EXIT; | |
668 | ||
669 | if (pExynosPort->bufferProcessType & BUFFER_COPY) | |
c6f4bc34 YK |
670 | pVideoEnc->exynos_codec_enqueueAllBuffer(pOMXComponent, nPortIndex); |
671 | Exynos_ResetCodecData(&pExynosPort->processData); | |
672 | ||
673 | if (ret == OMX_ErrorNone) { | |
674 | if (nPortIndex == INPUT_PORT_INDEX) { | |
675 | pExynosComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE; | |
676 | pExynosComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE; | |
677 | Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); | |
678 | Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); | |
679 | pExynosComponent->getAllDelayBuffer = OMX_FALSE; | |
680 | pExynosComponent->bSaveFlagEOS = OMX_FALSE; | |
e100a12d | 681 | pExynosComponent->bBehaviorEOS = OMX_FALSE; |
c6f4bc34 YK |
682 | pExynosComponent->reInputData = OMX_FALSE; |
683 | } | |
684 | ||
e4e150b8 | 685 | pExynosPort->bIsPortFlushed = OMX_FALSE; |
c6f4bc34 YK |
686 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush EventCmdComplete, port:%d", nPortIndex); |
687 | if (bEvent == OMX_TRUE) | |
688 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
689 | pExynosComponent->callbackData, | |
690 | OMX_EventCmdComplete, | |
691 | OMX_CommandFlush, nPortIndex, NULL); | |
692 | } | |
e4e150b8 HK |
693 | |
694 | if (pDataBuffer[1] != NULL) | |
695 | Exynos_OSAL_MutexUnlock(pDataBuffer[1]->bufferMutex); | |
696 | ||
697 | Exynos_OSAL_MutexUnlock(pDataBuffer[0]->bufferMutex); | |
c6f4bc34 YK |
698 | |
699 | EXIT: | |
700 | if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pExynosComponent != NULL)) { | |
701 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR,"%s : %d", __FUNCTION__, __LINE__); | |
702 | pExynosComponent->pCallbacks->EventHandler(pOMXComponent, | |
703 | pExynosComponent->callbackData, | |
704 | OMX_EventError, | |
705 | ret, 0, NULL); | |
706 | } | |
707 | ||
708 | FunctionOut(); | |
709 | ||
710 | return ret; | |
711 | } | |
712 | ||
e4e150b8 | 713 | OMX_ERRORTYPE Exynos_InputBufferReturn( |
3858590d TK |
714 | OMX_COMPONENTTYPE *pOMXComponent, |
715 | EXYNOS_OMX_DATABUFFER *pDataBuffer) | |
c6f4bc34 | 716 | { |
e4e150b8 HK |
717 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
718 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
719 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
e4e150b8 | 720 | OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; |
c6f4bc34 YK |
721 | |
722 | FunctionIn(); | |
723 | ||
e4e150b8 HK |
724 | if (pOMXComponent == NULL) { |
725 | ret = OMX_ErrorBadParameter; | |
726 | goto EXIT; | |
727 | } | |
728 | ||
729 | if (pOMXComponent->pComponentPrivate == NULL) { | |
730 | ret = OMX_ErrorBadParameter; | |
731 | goto EXIT; | |
732 | } | |
733 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
734 | pExynosPort = &(pExynosComponent->pExynosPort[INPUT_PORT_INDEX]); | |
735 | ||
e4e150b8 HK |
736 | if (pDataBuffer != NULL) |
737 | pBufferHdr = pDataBuffer->bufferHeader; | |
c6f4bc34 | 738 | |
e4e150b8 HK |
739 | if (pBufferHdr != NULL) { |
740 | if (pExynosPort->markType.hMarkTargetComponent != NULL) { | |
3858590d TK |
741 | pBufferHdr->hMarkTargetComponent = pExynosPort->markType.hMarkTargetComponent; |
742 | pBufferHdr->pMarkData = pExynosPort->markType.pMarkData; | |
743 | pExynosPort->markType.hMarkTargetComponent = NULL; | |
744 | pExynosPort->markType.pMarkData = NULL; | |
c6f4bc34 YK |
745 | } |
746 | ||
e4e150b8 HK |
747 | if (pBufferHdr->hMarkTargetComponent != NULL) { |
748 | if (pBufferHdr->hMarkTargetComponent == pOMXComponent) { | |
c6f4bc34 YK |
749 | pExynosComponent->pCallbacks->EventHandler(pOMXComponent, |
750 | pExynosComponent->callbackData, | |
751 | OMX_EventMark, | |
e4e150b8 | 752 | 0, 0, pBufferHdr->pMarkData); |
c6f4bc34 | 753 | } else { |
3858590d TK |
754 | pExynosComponent->propagateMarkType.hMarkTargetComponent = pBufferHdr->hMarkTargetComponent; |
755 | pExynosComponent->propagateMarkType.pMarkData = pBufferHdr->pMarkData; | |
c6f4bc34 YK |
756 | } |
757 | } | |
758 | ||
3858590d TK |
759 | pBufferHdr->nFilledLen = 0; |
760 | pBufferHdr->nOffset = 0; | |
e4e150b8 | 761 | Exynos_OMX_InputBufferReturn(pOMXComponent, pBufferHdr); |
c6f4bc34 YK |
762 | } |
763 | ||
764 | /* reset dataBuffer */ | |
e4e150b8 | 765 | Exynos_ResetDataBuffer(pDataBuffer); |
c6f4bc34 YK |
766 | |
767 | EXIT: | |
768 | FunctionOut(); | |
769 | ||
770 | return ret; | |
771 | } | |
772 | ||
e4e150b8 HK |
773 | OMX_ERRORTYPE Exynos_InputBufferGetQueue( |
774 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent) | |
c6f4bc34 | 775 | { |
e4e150b8 HK |
776 | OMX_ERRORTYPE ret = OMX_ErrorUndefined; |
777 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
778 | EXYNOS_OMX_MESSAGE *pMessage = NULL; | |
779 | EXYNOS_OMX_DATABUFFER *pDataBuffer = NULL; | |
c6f4bc34 YK |
780 | |
781 | FunctionIn(); | |
782 | ||
e4e150b8 HK |
783 | if (pExynosComponent == NULL) { |
784 | ret = OMX_ErrorBadParameter; | |
785 | goto EXIT; | |
786 | } | |
787 | pExynosPort = &(pExynosComponent->pExynosPort[INPUT_PORT_INDEX]); | |
788 | pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); | |
c6f4bc34 YK |
789 | |
790 | if (pExynosComponent->currentState != OMX_StateExecuting) { | |
791 | ret = OMX_ErrorUndefined; | |
792 | goto EXIT; | |
793 | } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) && | |
794 | (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) { | |
795 | Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); | |
e4e150b8 HK |
796 | if (pDataBuffer->dataValid != OMX_TRUE) { |
797 | pMessage = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); | |
798 | if (pMessage == NULL) { | |
c6f4bc34 YK |
799 | ret = OMX_ErrorUndefined; |
800 | goto EXIT; | |
801 | } | |
e4e150b8 HK |
802 | if (pMessage->messageType == EXYNOS_OMX_CommandFakeBuffer) { |
803 | Exynos_OSAL_Free(pMessage); | |
c6f4bc34 YK |
804 | ret = OMX_ErrorCodecFlush; |
805 | goto EXIT; | |
806 | } | |
807 | ||
e4e150b8 HK |
808 | pDataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(pMessage->pCmdData); |
809 | pDataBuffer->allocSize = pDataBuffer->bufferHeader->nAllocLen; | |
810 | pDataBuffer->dataLen = pDataBuffer->bufferHeader->nFilledLen; | |
811 | pDataBuffer->remainDataLen = pDataBuffer->dataLen; | |
812 | pDataBuffer->usedDataLen = 0; | |
813 | pDataBuffer->dataValid = OMX_TRUE; | |
814 | pDataBuffer->nFlags = pDataBuffer->bufferHeader->nFlags; | |
815 | pDataBuffer->timeStamp = pDataBuffer->bufferHeader->nTimeStamp; | |
c6f4bc34 | 816 | |
e4e150b8 | 817 | Exynos_OSAL_Free(pMessage); |
c6f4bc34 | 818 | |
e4e150b8 HK |
819 | if (pDataBuffer->allocSize <= pDataBuffer->dataLen) |
820 | Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", pDataBuffer->allocSize, pDataBuffer->dataLen); | |
c6f4bc34 YK |
821 | } |
822 | ret = OMX_ErrorNone; | |
823 | } | |
824 | EXIT: | |
825 | FunctionOut(); | |
826 | ||
827 | return ret; | |
828 | } | |
829 | ||
e4e150b8 | 830 | OMX_ERRORTYPE Exynos_OutputBufferReturn( |
3858590d TK |
831 | OMX_COMPONENTTYPE *pOMXComponent, |
832 | EXYNOS_OMX_DATABUFFER *pDataBuffer) | |
c6f4bc34 | 833 | { |
e4e150b8 HK |
834 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
835 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
836 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
e4e150b8 | 837 | OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; |
c6f4bc34 YK |
838 | |
839 | FunctionIn(); | |
840 | ||
e4e150b8 HK |
841 | if (pOMXComponent == NULL) { |
842 | ret = OMX_ErrorBadParameter; | |
843 | goto EXIT; | |
844 | } | |
c6f4bc34 | 845 | |
e4e150b8 HK |
846 | if (pOMXComponent->pComponentPrivate == NULL) { |
847 | ret = OMX_ErrorBadParameter; | |
848 | goto EXIT; | |
849 | } | |
850 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
851 | pExynosPort = &(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]); | |
852 | ||
3858590d TK |
853 | if (pDataBuffer != NULL) |
854 | pBufferHdr = pDataBuffer->bufferHeader; | |
e4e150b8 HK |
855 | |
856 | if (pBufferHdr != NULL) { | |
857 | pBufferHdr->nFilledLen = pDataBuffer->remainDataLen; | |
858 | pBufferHdr->nOffset = 0; | |
859 | pBufferHdr->nFlags = pDataBuffer->nFlags; | |
860 | pBufferHdr->nTimeStamp = pDataBuffer->timeStamp; | |
c6f4bc34 YK |
861 | |
862 | if (pExynosComponent->propagateMarkType.hMarkTargetComponent != NULL) { | |
e4e150b8 HK |
863 | pBufferHdr->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent; |
864 | pBufferHdr->pMarkData = pExynosComponent->propagateMarkType.pMarkData; | |
3858590d TK |
865 | pExynosComponent->propagateMarkType.hMarkTargetComponent = NULL; |
866 | pExynosComponent->propagateMarkType.pMarkData = NULL; | |
c6f4bc34 YK |
867 | } |
868 | ||
e4e150b8 | 869 | if ((pBufferHdr->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { |
e4e150b8 | 870 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "event OMX_BUFFERFLAG_EOS!!!"); |
c6f4bc34 YK |
871 | pExynosComponent->pCallbacks->EventHandler(pOMXComponent, |
872 | pExynosComponent->callbackData, | |
873 | OMX_EventBufferFlag, | |
874 | OUTPUT_PORT_INDEX, | |
e4e150b8 | 875 | pBufferHdr->nFlags, NULL); |
c6f4bc34 YK |
876 | } |
877 | ||
e4e150b8 | 878 | Exynos_OMX_OutputBufferReturn(pOMXComponent, pBufferHdr); |
c6f4bc34 YK |
879 | } |
880 | ||
881 | /* reset dataBuffer */ | |
e4e150b8 | 882 | Exynos_ResetDataBuffer(pDataBuffer); |
c6f4bc34 YK |
883 | |
884 | EXIT: | |
885 | FunctionOut(); | |
886 | ||
887 | return ret; | |
888 | } | |
889 | ||
e4e150b8 HK |
890 | OMX_ERRORTYPE Exynos_OutputBufferGetQueue( |
891 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent) | |
c6f4bc34 | 892 | { |
e4e150b8 HK |
893 | OMX_ERRORTYPE ret = OMX_ErrorUndefined; |
894 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
895 | EXYNOS_OMX_MESSAGE *pMessage = NULL; | |
896 | EXYNOS_OMX_DATABUFFER *pDataBuffer = NULL; | |
c6f4bc34 YK |
897 | |
898 | FunctionIn(); | |
899 | ||
e4e150b8 HK |
900 | if (pExynosComponent == NULL) { |
901 | ret = OMX_ErrorBadParameter; | |
902 | goto EXIT; | |
903 | } | |
904 | pExynosPort = &(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]); | |
905 | ||
24ec2c82 | 906 | if (pExynosPort->bufferProcessType & BUFFER_COPY) { |
e4e150b8 | 907 | pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer); |
24ec2c82 | 908 | } else if (pExynosPort->bufferProcessType & BUFFER_SHARE) { |
e4e150b8 | 909 | pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); |
9c39c5ff TK |
910 | } else { |
911 | ret = OMX_ErrorUndefined; | |
912 | goto EXIT; | |
c6f4bc34 YK |
913 | } |
914 | ||
915 | if (pExynosComponent->currentState != OMX_StateExecuting) { | |
916 | ret = OMX_ErrorUndefined; | |
917 | goto EXIT; | |
918 | } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) && | |
e4e150b8 | 919 | (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) { |
c6f4bc34 | 920 | Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); |
9c39c5ff | 921 | if (pDataBuffer->dataValid != OMX_TRUE) { |
e4e150b8 HK |
922 | pMessage = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); |
923 | if (pMessage == NULL) { | |
c6f4bc34 YK |
924 | ret = OMX_ErrorUndefined; |
925 | goto EXIT; | |
926 | } | |
e4e150b8 HK |
927 | if (pMessage->messageType == EXYNOS_OMX_CommandFakeBuffer) { |
928 | Exynos_OSAL_Free(pMessage); | |
c6f4bc34 YK |
929 | ret = OMX_ErrorCodecFlush; |
930 | goto EXIT; | |
931 | } | |
932 | ||
e4e150b8 HK |
933 | pDataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(pMessage->pCmdData); |
934 | pDataBuffer->allocSize = pDataBuffer->bufferHeader->nAllocLen; | |
935 | pDataBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen; | |
936 | pDataBuffer->remainDataLen = pDataBuffer->dataLen; | |
937 | pDataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; | |
938 | pDataBuffer->dataValid = OMX_TRUE; | |
939 | /* pDataBuffer->nFlags = pDataBuffer->bufferHeader->nFlags; */ | |
940 | /* pDtaBuffer->nTimeStamp = pDataBuffer->bufferHeader->nTimeStamp; */ | |
c6f4bc34 | 941 | /* |
24ec2c82 | 942 | if (pExynosPort->bufferProcessType & BUFFER_SHARE) |
e4e150b8 | 943 | pDataBuffer->pPrivate = pDataBuffer->bufferHeader->pOutputPortPrivate; |
24ec2c82 | 944 | else if (pExynosPort->bufferProcessType & BUFFER_COPY) { |
e4e150b8 HK |
945 | pExynosPort->processData.dataBuffer = pDataBuffer->bufferHeader->pBuffer; |
946 | pExynosPort->processData.allocSize = pDataBuffer->bufferHeader->nAllocLen; | |
c6f4bc34 YK |
947 | } |
948 | */ | |
e4e150b8 | 949 | Exynos_OSAL_Free(pMessage); |
c6f4bc34 YK |
950 | } |
951 | ret = OMX_ErrorNone; | |
952 | } | |
953 | EXIT: | |
954 | FunctionOut(); | |
955 | ||
956 | return ret; | |
c6f4bc34 YK |
957 | } |
958 | ||
e4e150b8 HK |
959 | OMX_BUFFERHEADERTYPE *Exynos_OutputBufferGetQueue_Direct( |
960 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent) | |
c6f4bc34 | 961 | { |
e4e150b8 HK |
962 | OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; |
963 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
964 | EXYNOS_OMX_MESSAGE *pMessage = NULL; | |
c6f4bc34 YK |
965 | |
966 | FunctionIn(); | |
967 | ||
e4e150b8 HK |
968 | if (pExynosComponent == NULL) { |
969 | pBufferHdr = NULL; | |
970 | goto EXIT; | |
971 | } | |
972 | pExynosPort = &(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]); | |
973 | ||
c6f4bc34 | 974 | if (pExynosComponent->currentState != OMX_StateExecuting) { |
e4e150b8 | 975 | pBufferHdr = NULL; |
c6f4bc34 YK |
976 | goto EXIT; |
977 | } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) && | |
e4e150b8 | 978 | (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) { |
c6f4bc34 YK |
979 | Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); |
980 | ||
e4e150b8 HK |
981 | pMessage = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); |
982 | if (pMessage == NULL) { | |
983 | pBufferHdr = NULL; | |
c6f4bc34 YK |
984 | goto EXIT; |
985 | } | |
e4e150b8 HK |
986 | if (pMessage->messageType == EXYNOS_OMX_CommandFakeBuffer) { |
987 | Exynos_OSAL_Free(pMessage); | |
988 | pBufferHdr = NULL; | |
c6f4bc34 YK |
989 | goto EXIT; |
990 | } | |
991 | ||
e4e150b8 HK |
992 | pBufferHdr = (OMX_BUFFERHEADERTYPE *)(pMessage->pCmdData); |
993 | Exynos_OSAL_Free(pMessage); | |
c6f4bc34 YK |
994 | } |
995 | ||
996 | EXIT: | |
997 | FunctionOut(); | |
998 | ||
e4e150b8 | 999 | return pBufferHdr; |
c6f4bc34 YK |
1000 | } |
1001 | ||
e4e150b8 HK |
1002 | OMX_ERRORTYPE Exynos_CodecBufferEnqueue( |
1003 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent, | |
1004 | OMX_U32 nPortIndex, | |
1005 | OMX_PTR pData) | |
c6f4bc34 | 1006 | { |
e4e150b8 | 1007 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
c6f4bc34 YK |
1008 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; |
1009 | ||
1010 | FunctionIn(); | |
1011 | ||
e4e150b8 HK |
1012 | if (pExynosComponent == NULL) { |
1013 | ret = OMX_ErrorBadParameter; | |
1014 | goto EXIT; | |
1015 | } | |
c6f4bc34 | 1016 | |
e4e150b8 HK |
1017 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { |
1018 | ret = OMX_ErrorBadPortIndex; | |
1019 | goto EXIT; | |
1020 | } | |
1021 | pExynosPort = &(pExynosComponent->pExynosPort[nPortIndex]); | |
1022 | ||
1023 | if (pData == NULL) { | |
c6f4bc34 YK |
1024 | ret = OMX_ErrorInsufficientResources; |
1025 | goto EXIT; | |
1026 | } | |
1027 | ||
e4e150b8 | 1028 | ret = Exynos_OSAL_Queue(&pExynosPort->codecBufferQ, (void *)pData); |
c6f4bc34 YK |
1029 | if (ret != 0) { |
1030 | ret = OMX_ErrorUndefined; | |
1031 | goto EXIT; | |
1032 | } | |
1033 | Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID); | |
1034 | ||
1035 | ret = OMX_ErrorNone; | |
1036 | ||
1037 | EXIT: | |
1038 | FunctionOut(); | |
1039 | ||
1040 | return ret; | |
1041 | } | |
1042 | ||
e4e150b8 HK |
1043 | OMX_ERRORTYPE Exynos_CodecBufferDequeue( |
1044 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent, | |
1045 | OMX_U32 nPortIndex, | |
1046 | OMX_PTR *pData) | |
c6f4bc34 | 1047 | { |
e4e150b8 | 1048 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
c6f4bc34 | 1049 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; |
e4e150b8 | 1050 | OMX_PTR pTempData = NULL; |
c6f4bc34 YK |
1051 | |
1052 | FunctionIn(); | |
1053 | ||
e4e150b8 HK |
1054 | if (pExynosComponent == NULL) { |
1055 | ret = OMX_ErrorBadParameter; | |
c6f4bc34 YK |
1056 | goto EXIT; |
1057 | } | |
c6f4bc34 | 1058 | |
e4e150b8 HK |
1059 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { |
1060 | ret = OMX_ErrorBadPortIndex; | |
1061 | goto EXIT; | |
1062 | } | |
1063 | pExynosPort = &(pExynosComponent->pExynosPort[nPortIndex]); | |
1064 | ||
1065 | Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID); | |
1066 | pTempData = (OMX_PTR)Exynos_OSAL_Dequeue(&pExynosPort->codecBufferQ); | |
1067 | if (pTempData != NULL) { | |
1068 | *pData = (OMX_PTR)pTempData; | |
1069 | ret = OMX_ErrorNone; | |
1070 | } else { | |
1071 | *pData = NULL; | |
1072 | ret = OMX_ErrorUndefined; | |
1073 | } | |
c6f4bc34 YK |
1074 | |
1075 | EXIT: | |
1076 | FunctionOut(); | |
1077 | ||
1078 | return ret; | |
1079 | } | |
1080 | ||
e4e150b8 HK |
1081 | OMX_ERRORTYPE Exynos_CodecBufferReset( |
1082 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent, | |
1083 | OMX_U32 nPortIndex) | |
c6f4bc34 | 1084 | { |
e4e150b8 HK |
1085 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1086 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 YK |
1087 | |
1088 | FunctionIn(); | |
1089 | ||
e4e150b8 HK |
1090 | if (pExynosComponent == NULL) { |
1091 | ret = OMX_ErrorBadParameter; | |
1092 | goto EXIT; | |
1093 | } | |
1094 | ||
1095 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { | |
1096 | ret = OMX_ErrorBadPortIndex; | |
1097 | goto EXIT; | |
1098 | } | |
1099 | pExynosPort = &(pExynosComponent->pExynosPort[nPortIndex]); | |
c6f4bc34 YK |
1100 | |
1101 | ret = Exynos_OSAL_ResetQueue(&pExynosPort->codecBufferQ); | |
1102 | if (ret != 0) { | |
1103 | ret = OMX_ErrorUndefined; | |
1104 | goto EXIT; | |
1105 | } | |
e4e150b8 | 1106 | |
c6f4bc34 YK |
1107 | while (1) { |
1108 | int cnt = 0; | |
1109 | Exynos_OSAL_Get_SemaphoreCount(pExynosPort->codecSemID, &cnt); | |
1110 | if (cnt > 0) | |
1111 | Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID); | |
1112 | else | |
1113 | break; | |
1114 | } | |
1115 | ret = OMX_ErrorNone; | |
1116 | ||
1117 | EXIT: | |
1118 | FunctionOut(); | |
1119 | ||
1120 | return ret; | |
1121 | } | |
1122 | ||
1123 | OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetParameter( | |
1124 | OMX_IN OMX_HANDLETYPE hComponent, | |
1125 | OMX_IN OMX_INDEXTYPE nParamIndex, | |
e4e150b8 | 1126 | OMX_INOUT OMX_PTR pComponentParameterStructure) |
c6f4bc34 | 1127 | { |
e4e150b8 HK |
1128 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1129 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1130 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1131 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 YK |
1132 | |
1133 | FunctionIn(); | |
1134 | ||
1135 | if (hComponent == NULL) { | |
1136 | ret = OMX_ErrorBadParameter; | |
1137 | goto EXIT; | |
1138 | } | |
1139 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
e4e150b8 | 1140 | |
c6f4bc34 YK |
1141 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
1142 | if (ret != OMX_ErrorNone) { | |
1143 | goto EXIT; | |
1144 | } | |
1145 | ||
1146 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1147 | ret = OMX_ErrorBadParameter; | |
1148 | goto EXIT; | |
1149 | } | |
1150 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1151 | ||
e4e150b8 | 1152 | if (pExynosComponent->currentState == OMX_StateInvalid) { |
c6f4bc34 YK |
1153 | ret = OMX_ErrorInvalidState; |
1154 | goto EXIT; | |
1155 | } | |
1156 | ||
e4e150b8 | 1157 | if (pComponentParameterStructure == NULL) { |
c6f4bc34 YK |
1158 | ret = OMX_ErrorBadParameter; |
1159 | goto EXIT; | |
1160 | } | |
1161 | ||
1162 | switch (nParamIndex) { | |
1163 | case OMX_IndexParamVideoInit: | |
1164 | { | |
e4e150b8 HK |
1165 | OMX_PORT_PARAM_TYPE *pPortParam = (OMX_PORT_PARAM_TYPE *)pComponentParameterStructure; |
1166 | ret = Exynos_OMX_Check_SizeVersion(pPortParam, sizeof(OMX_PORT_PARAM_TYPE)); | |
c6f4bc34 YK |
1167 | if (ret != OMX_ErrorNone) { |
1168 | goto EXIT; | |
1169 | } | |
1170 | ||
e4e150b8 HK |
1171 | pPortParam->nPorts = pExynosComponent->portParam.nPorts; |
1172 | pPortParam->nStartPortNumber = pExynosComponent->portParam.nStartPortNumber; | |
c6f4bc34 YK |
1173 | ret = OMX_ErrorNone; |
1174 | } | |
1175 | break; | |
1176 | case OMX_IndexParamVideoPortFormat: | |
1177 | { | |
e4e150b8 HK |
1178 | OMX_VIDEO_PARAM_PORTFORMATTYPE *pPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pComponentParameterStructure; |
1179 | OMX_U32 nPortIndex = pPortFormat->nPortIndex; | |
1180 | OMX_U32 nIndex = pPortFormat->nIndex; | |
1181 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
1182 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | |
1183 | OMX_U32 nSupportFormat = 0; | |
1184 | ||
1185 | ret = Exynos_OMX_Check_SizeVersion(pPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); | |
c6f4bc34 YK |
1186 | if (ret != OMX_ErrorNone) { |
1187 | goto EXIT; | |
1188 | } | |
1189 | ||
e4e150b8 | 1190 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { |
c6f4bc34 YK |
1191 | ret = OMX_ErrorBadPortIndex; |
1192 | goto EXIT; | |
1193 | } | |
1194 | ||
e4e150b8 | 1195 | if (nPortIndex == INPUT_PORT_INDEX) { |
c6f4bc34 | 1196 | pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; |
e4e150b8 | 1197 | pPortDef = &pExynosPort->portDefinition; |
c6f4bc34 | 1198 | |
e4e150b8 | 1199 | switch (nIndex) { |
c6f4bc34 | 1200 | case supportFormat_0: |
e4e150b8 HK |
1201 | pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; |
1202 | pPortFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar; | |
1203 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; | |
c6f4bc34 YK |
1204 | break; |
1205 | case supportFormat_1: | |
e4e150b8 HK |
1206 | pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; |
1207 | pPortFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; | |
1208 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; | |
c6f4bc34 YK |
1209 | break; |
1210 | case supportFormat_2: | |
e4e150b8 | 1211 | pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; |
433e798a | 1212 | pPortFormat->eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatNV12Tiled; |
e4e150b8 | 1213 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; |
c6f4bc34 YK |
1214 | break; |
1215 | case supportFormat_3: | |
e4e150b8 | 1216 | pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; |
433e798a | 1217 | pPortFormat->eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatNV21Linear; |
e4e150b8 | 1218 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; |
c6f4bc34 YK |
1219 | break; |
1220 | case supportFormat_4: | |
e4e150b8 HK |
1221 | pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; |
1222 | pPortFormat->eColorFormat = OMX_COLOR_FormatAndroidOpaque; | |
1223 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; | |
c6f4bc34 | 1224 | break; |
433e798a EC |
1225 | #ifdef USE_ENCODER_RGBINPUT_SUPPORT |
1226 | case supportFormat_5: | |
1227 | pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; | |
1228 | pPortFormat->eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatYVU420Planar; | |
1229 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; | |
1230 | break; | |
1231 | case supportFormat_6: | |
1232 | pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; | |
1233 | pPortFormat->eColorFormat = OMX_COLOR_Format32bitARGB8888; | |
1234 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; | |
1235 | break; | |
1236 | case supportFormat_7: | |
1237 | pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; | |
1238 | pPortFormat->eColorFormat = OMX_COLOR_Format32bitBGRA8888; | |
1239 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; | |
1240 | break; | |
1241 | #endif | |
c6f4bc34 | 1242 | default: |
e4e150b8 | 1243 | if (nIndex > supportFormat_0) { |
c6f4bc34 YK |
1244 | ret = OMX_ErrorNoMore; |
1245 | goto EXIT; | |
1246 | } | |
1247 | break; | |
1248 | } | |
e4e150b8 HK |
1249 | } else if (nPortIndex == OUTPUT_PORT_INDEX) { |
1250 | nSupportFormat = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; | |
1251 | if (nIndex > nSupportFormat) { | |
c6f4bc34 YK |
1252 | ret = OMX_ErrorNoMore; |
1253 | goto EXIT; | |
1254 | } | |
1255 | ||
1256 | pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
e4e150b8 | 1257 | pPortDef = &pExynosPort->portDefinition; |
c6f4bc34 | 1258 | |
e4e150b8 HK |
1259 | pPortFormat->eCompressionFormat = pPortDef->format.video.eCompressionFormat; |
1260 | pPortFormat->eColorFormat = pPortDef->format.video.eColorFormat; | |
1261 | pPortFormat->xFramerate = pPortDef->format.video.xFramerate; | |
c6f4bc34 YK |
1262 | } |
1263 | ret = OMX_ErrorNone; | |
1264 | } | |
1265 | break; | |
1266 | case OMX_IndexParamVideoBitrate: | |
1267 | { | |
e4e150b8 HK |
1268 | OMX_VIDEO_PARAM_BITRATETYPE *pVideoBitrate = (OMX_VIDEO_PARAM_BITRATETYPE *)pComponentParameterStructure; |
1269 | OMX_U32 nPortIndex = pVideoBitrate->nPortIndex; | |
1270 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
1271 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
1272 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | |
c6f4bc34 | 1273 | |
e4e150b8 | 1274 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1275 | ret = OMX_ErrorBadPortIndex; |
1276 | goto EXIT; | |
1277 | } else { | |
1278 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
e4e150b8 HK |
1279 | if (pVideoEnc == NULL) { |
1280 | ret = OMX_ErrorBadParameter; | |
1281 | goto EXIT; | |
1282 | } | |
1283 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; | |
1284 | pPortDef = &pExynosPort->portDefinition; | |
c6f4bc34 | 1285 | |
e4e150b8 HK |
1286 | pVideoBitrate->eControlRate = pVideoEnc->eControlRate[nPortIndex]; |
1287 | pVideoBitrate->nTargetBitrate = pPortDef->format.video.nBitrate; | |
c6f4bc34 YK |
1288 | } |
1289 | ret = OMX_ErrorNone; | |
1290 | } | |
1291 | break; | |
1292 | case OMX_IndexParamVideoQuantization: | |
1293 | { | |
e4e150b8 HK |
1294 | OMX_VIDEO_PARAM_QUANTIZATIONTYPE *pVideoQuantization = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pComponentParameterStructure; |
1295 | OMX_U32 nPortIndex = pVideoQuantization->nPortIndex; | |
1296 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
1297 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
1298 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | |
c6f4bc34 | 1299 | |
e4e150b8 | 1300 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1301 | ret = OMX_ErrorBadPortIndex; |
1302 | goto EXIT; | |
1303 | } else { | |
1304 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
e4e150b8 HK |
1305 | if (pVideoEnc == NULL) { |
1306 | ret = OMX_ErrorBadParameter; | |
1307 | goto EXIT; | |
1308 | } | |
1309 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; | |
1310 | pPortDef = &pExynosPort->portDefinition; | |
c6f4bc34 | 1311 | |
e4e150b8 HK |
1312 | pVideoQuantization->nQpI = pVideoEnc->quantization.nQpI; |
1313 | pVideoQuantization->nQpP = pVideoEnc->quantization.nQpP; | |
1314 | pVideoQuantization->nQpB = pVideoEnc->quantization.nQpB; | |
c6f4bc34 YK |
1315 | } |
1316 | ret = OMX_ErrorNone; | |
c6f4bc34 YK |
1317 | } |
1318 | break; | |
1319 | case OMX_IndexParamPortDefinition: | |
1320 | { | |
e4e150b8 HK |
1321 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure; |
1322 | OMX_U32 nPortIndex = pPortDef->nPortIndex; | |
1323 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 | 1324 | |
e4e150b8 | 1325 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { |
c6f4bc34 YK |
1326 | ret = OMX_ErrorBadPortIndex; |
1327 | goto EXIT; | |
1328 | } | |
e4e150b8 HK |
1329 | |
1330 | ret = Exynos_OMX_Check_SizeVersion(pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); | |
c6f4bc34 YK |
1331 | if (ret != OMX_ErrorNone) { |
1332 | goto EXIT; | |
1333 | } | |
1334 | ||
e4e150b8 HK |
1335 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
1336 | Exynos_OSAL_Memcpy(pPortDef, &pExynosPort->portDefinition, pPortDef->nSize); | |
c6f4bc34 YK |
1337 | |
1338 | #ifdef USE_STOREMETADATA | |
e4e150b8 HK |
1339 | if ((nPortIndex == 0) && |
1340 | (pExynosPort->bStoreMetaData == OMX_TRUE)) { | |
1341 | pPortDef->nBufferSize = MAX_INPUT_METADATA_BUFFER_SIZE; | |
c6f4bc34 YK |
1342 | } |
1343 | #endif | |
c31a957e TK |
1344 | } |
1345 | break; | |
1346 | case OMX_IndexVendorNeedContigMemory: | |
1347 | { | |
1348 | EXYNOS_OMX_VIDEO_PARAM_PORTMEMTYPE *pPortMemType = (EXYNOS_OMX_VIDEO_PARAM_PORTMEMTYPE *)pComponentParameterStructure; | |
1349 | OMX_U32 nPortIndex = pPortMemType->nPortIndex; | |
1350 | EXYNOS_OMX_BASEPORT *pExynosPort; | |
1351 | ||
1352 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { | |
1353 | ret = OMX_ErrorBadPortIndex; | |
1354 | goto EXIT; | |
1355 | } | |
1356 | ||
1357 | ret = Exynos_OMX_Check_SizeVersion(pPortMemType, sizeof(EXYNOS_OMX_VIDEO_PARAM_PORTMEMTYPE)); | |
1358 | if (ret != OMX_ErrorNone) | |
1359 | goto EXIT; | |
1360 | ||
1361 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; | |
1362 | ||
1363 | pPortMemType->bNeedContigMem = pExynosPort->bNeedContigMem; | |
c6f4bc34 YK |
1364 | } |
1365 | break; | |
aa4a2b3e TK |
1366 | case OMX_IndexParamVideoIntraRefresh: |
1367 | { | |
1368 | OMX_VIDEO_PARAM_INTRAREFRESHTYPE *pIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)pComponentParameterStructure; | |
1369 | OMX_U32 nPortIndex = pIntraRefresh->nPortIndex; | |
1370 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
1371 | ||
1372 | ret = Exynos_OMX_Check_SizeVersion(pIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE)); | |
1373 | if (ret != OMX_ErrorNone) | |
1374 | goto EXIT; | |
1375 | ||
1376 | if (nPortIndex != OUTPUT_PORT_INDEX) { | |
1377 | ret = OMX_ErrorBadPortIndex; | |
1378 | goto EXIT; | |
1379 | } | |
1380 | ||
1381 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1382 | pIntraRefresh->eRefreshMode = pVideoEnc->intraRefresh.eRefreshMode; | |
1383 | pIntraRefresh->nAirMBs = pVideoEnc->intraRefresh.nAirMBs; | |
1384 | pIntraRefresh->nAirRef = pVideoEnc->intraRefresh.nAirRef; | |
1385 | pIntraRefresh->nCirMBs = pVideoEnc->intraRefresh.nCirMBs; | |
1386 | ||
1387 | ret = OMX_ErrorNone; | |
1388 | } | |
1389 | break; | |
c6f4bc34 YK |
1390 | default: |
1391 | { | |
e4e150b8 | 1392 | ret = Exynos_OMX_GetParameter(hComponent, nParamIndex, pComponentParameterStructure); |
c6f4bc34 YK |
1393 | } |
1394 | break; | |
1395 | } | |
c6f4bc34 YK |
1396 | EXIT: |
1397 | FunctionOut(); | |
1398 | ||
1399 | return ret; | |
1400 | } | |
e4e150b8 | 1401 | |
c6f4bc34 YK |
1402 | OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetParameter( |
1403 | OMX_IN OMX_HANDLETYPE hComponent, | |
e4e150b8 HK |
1404 | OMX_IN OMX_INDEXTYPE nParamIndex, |
1405 | OMX_IN OMX_PTR pComponentParameterStructure) | |
c6f4bc34 | 1406 | { |
e4e150b8 HK |
1407 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1408 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1409 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1410 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 YK |
1411 | |
1412 | FunctionIn(); | |
1413 | ||
1414 | if (hComponent == NULL) { | |
1415 | ret = OMX_ErrorBadParameter; | |
1416 | goto EXIT; | |
1417 | } | |
1418 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
e4e150b8 | 1419 | |
c6f4bc34 YK |
1420 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
1421 | if (ret != OMX_ErrorNone) { | |
1422 | goto EXIT; | |
1423 | } | |
1424 | ||
1425 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1426 | ret = OMX_ErrorBadParameter; | |
1427 | goto EXIT; | |
1428 | } | |
1429 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1430 | ||
e4e150b8 | 1431 | if (pExynosComponent->currentState == OMX_StateInvalid) { |
c6f4bc34 YK |
1432 | ret = OMX_ErrorInvalidState; |
1433 | goto EXIT; | |
1434 | } | |
1435 | ||
e4e150b8 | 1436 | if (pComponentParameterStructure == NULL) { |
c6f4bc34 YK |
1437 | ret = OMX_ErrorBadParameter; |
1438 | goto EXIT; | |
1439 | } | |
1440 | ||
e4e150b8 | 1441 | switch (nParamIndex) { |
c6f4bc34 YK |
1442 | case OMX_IndexParamVideoPortFormat: |
1443 | { | |
e4e150b8 HK |
1444 | OMX_VIDEO_PARAM_PORTFORMATTYPE *pPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pComponentParameterStructure; |
1445 | OMX_U32 nPortIndex = pPortFormat->nPortIndex; | |
1446 | OMX_U32 nIndex = pPortFormat->nIndex; | |
1447 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | |
1448 | OMX_U32 nSupportFormat = 0; | |
1449 | ||
1450 | ret = Exynos_OMX_Check_SizeVersion(pPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); | |
c6f4bc34 YK |
1451 | if (ret != OMX_ErrorNone) { |
1452 | goto EXIT; | |
1453 | } | |
1454 | ||
e4e150b8 | 1455 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { |
c6f4bc34 YK |
1456 | ret = OMX_ErrorBadPortIndex; |
1457 | goto EXIT; | |
c6f4bc34 | 1458 | } |
e4e150b8 HK |
1459 | pPortDef = &(pExynosComponent->pExynosPort[nPortIndex].portDefinition); |
1460 | ||
1461 | pPortDef->format.video.eColorFormat = pPortFormat->eColorFormat; | |
1462 | pPortDef->format.video.eCompressionFormat = pPortFormat->eCompressionFormat; | |
1463 | pPortDef->format.video.xFramerate = pPortFormat->xFramerate; | |
c6f4bc34 YK |
1464 | } |
1465 | break; | |
1466 | case OMX_IndexParamVideoBitrate: | |
1467 | { | |
e4e150b8 HK |
1468 | OMX_VIDEO_PARAM_BITRATETYPE *pVideoBitrate = (OMX_VIDEO_PARAM_BITRATETYPE *)pComponentParameterStructure; |
1469 | OMX_U32 nPortIndex = pVideoBitrate->nPortIndex; | |
1470 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
1471 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
1472 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | |
c6f4bc34 | 1473 | |
e4e150b8 | 1474 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1475 | ret = OMX_ErrorBadPortIndex; |
1476 | goto EXIT; | |
1477 | } else { | |
1478 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
e4e150b8 HK |
1479 | if (pVideoEnc == NULL) { |
1480 | ret = OMX_ErrorBadParameter; | |
1481 | goto EXIT; | |
1482 | } | |
1483 | pPortDef = &(pExynosComponent->pExynosPort[nPortIndex].portDefinition); | |
c6f4bc34 | 1484 | |
e4e150b8 HK |
1485 | pVideoEnc->eControlRate[nPortIndex] = pVideoBitrate->eControlRate; |
1486 | pPortDef->format.video.nBitrate = pVideoBitrate->nTargetBitrate; | |
c6f4bc34 YK |
1487 | } |
1488 | ret = OMX_ErrorNone; | |
1489 | } | |
1490 | break; | |
1491 | case OMX_IndexParamVideoQuantization: | |
1492 | { | |
e4e150b8 HK |
1493 | OMX_VIDEO_PARAM_QUANTIZATIONTYPE *pVideoQuantization = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pComponentParameterStructure; |
1494 | OMX_U32 nPortIndex = pVideoQuantization->nPortIndex; | |
1495 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
1496 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
1497 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; | |
c6f4bc34 | 1498 | |
e4e150b8 | 1499 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1500 | ret = OMX_ErrorBadPortIndex; |
1501 | goto EXIT; | |
1502 | } else { | |
1503 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
e4e150b8 HK |
1504 | if (pVideoEnc == NULL) { |
1505 | ret = OMX_ErrorBadParameter; | |
1506 | goto EXIT; | |
1507 | } | |
1508 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; | |
1509 | pPortDef = &pExynosPort->portDefinition; | |
c6f4bc34 | 1510 | |
e4e150b8 HK |
1511 | pVideoEnc->quantization.nQpI = pVideoQuantization->nQpI; |
1512 | pVideoEnc->quantization.nQpP = pVideoQuantization->nQpP; | |
1513 | pVideoEnc->quantization.nQpB = pVideoQuantization->nQpB; | |
c6f4bc34 YK |
1514 | } |
1515 | ret = OMX_ErrorNone; | |
1516 | } | |
1517 | break; | |
1518 | case OMX_IndexParamPortDefinition: | |
1519 | { | |
e4e150b8 HK |
1520 | OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure; |
1521 | OMX_U32 nPortIndex = pPortDef->nPortIndex; | |
1522 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 YK |
1523 | OMX_U32 width, height, size; |
1524 | ||
e4e150b8 | 1525 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { |
c6f4bc34 YK |
1526 | ret = OMX_ErrorBadPortIndex; |
1527 | goto EXIT; | |
1528 | } | |
e4e150b8 HK |
1529 | |
1530 | ret = Exynos_OMX_Check_SizeVersion(pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); | |
c6f4bc34 YK |
1531 | if (ret != OMX_ErrorNone) { |
1532 | goto EXIT; | |
1533 | } | |
1534 | ||
e4e150b8 | 1535 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
c6f4bc34 | 1536 | |
e4e150b8 HK |
1537 | if ((pExynosComponent->currentState != OMX_StateLoaded) && |
1538 | (pExynosComponent->currentState != OMX_StateWaitForResources)) { | |
c6f4bc34 YK |
1539 | if (pExynosPort->portDefinition.bEnabled == OMX_TRUE) { |
1540 | ret = OMX_ErrorIncorrectStateOperation; | |
1541 | goto EXIT; | |
1542 | } | |
1543 | } | |
e4e150b8 HK |
1544 | |
1545 | if (pPortDef->nBufferCountActual < pExynosPort->portDefinition.nBufferCountMin) { | |
c6f4bc34 YK |
1546 | ret = OMX_ErrorBadParameter; |
1547 | goto EXIT; | |
1548 | } | |
1549 | ||
e4e150b8 HK |
1550 | Exynos_OSAL_Memcpy(&pExynosPort->portDefinition, pPortDef, pPortDef->nSize); |
1551 | if (nPortIndex == INPUT_PORT_INDEX) { | |
1552 | pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
c6f4bc34 YK |
1553 | Exynos_UpdateFrameSize(pOMXComponent); |
1554 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosOutputPort->portDefinition.nBufferSize: %d", | |
e4e150b8 | 1555 | pExynosPort->portDefinition.nBufferSize); |
c6f4bc34 YK |
1556 | } |
1557 | ret = OMX_ErrorNone; | |
1558 | } | |
1559 | break; | |
1560 | #ifdef USE_STOREMETADATA | |
1561 | case OMX_IndexParamStoreMetaDataBuffer: | |
1562 | { | |
298ca87f TK |
1563 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; |
1564 | if (pVideoEnc == NULL) { | |
1565 | ret = OMX_ErrorBadParameter; | |
1566 | goto EXIT; | |
1567 | } | |
1568 | ||
e4e150b8 | 1569 | ret = Exynos_OSAL_SetANBParameter(hComponent, nParamIndex, pComponentParameterStructure); |
298ca87f TK |
1570 | if (ret == OMX_ErrorNone) |
1571 | pVideoEnc->bFirstInput = OMX_TRUE; | |
c6f4bc34 YK |
1572 | } |
1573 | break; | |
1574 | #endif | |
c31a957e TK |
1575 | case OMX_IndexVendorNeedContigMemory: |
1576 | { | |
1577 | EXYNOS_OMX_VIDEO_PARAM_PORTMEMTYPE *pPortMemType = (EXYNOS_OMX_VIDEO_PARAM_PORTMEMTYPE *)pComponentParameterStructure; | |
1578 | OMX_U32 nPortIndex = pPortMemType->nPortIndex; | |
1579 | EXYNOS_OMX_BASEPORT *pExynosPort; | |
1580 | ||
1581 | if (nPortIndex >= pExynosComponent->portParam.nPorts) { | |
1582 | ret = OMX_ErrorBadPortIndex; | |
1583 | goto EXIT; | |
1584 | } | |
1585 | ||
1586 | ret = Exynos_OMX_Check_SizeVersion(pPortMemType, sizeof(EXYNOS_OMX_VIDEO_PARAM_PORTMEMTYPE)); | |
1587 | if (ret != OMX_ErrorNone) | |
1588 | goto EXIT; | |
1589 | ||
1590 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; | |
1591 | ||
1592 | if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) { | |
1593 | if (pExynosPort->portDefinition.bEnabled == OMX_TRUE) { | |
1594 | ret = OMX_ErrorIncorrectStateOperation; | |
1595 | goto EXIT; | |
1596 | } | |
1597 | } | |
1598 | ||
1599 | pExynosPort->bNeedContigMem = pPortMemType->bNeedContigMem; | |
1600 | } | |
1601 | break; | |
aa4a2b3e TK |
1602 | case OMX_IndexParamVideoIntraRefresh: |
1603 | { | |
1604 | OMX_VIDEO_PARAM_INTRAREFRESHTYPE *pIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)pComponentParameterStructure; | |
1605 | OMX_U32 nPortIndex = pIntraRefresh->nPortIndex; | |
1606 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
1607 | ||
1608 | ret = Exynos_OMX_Check_SizeVersion(pIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE)); | |
1609 | if (ret != OMX_ErrorNone) | |
1610 | goto EXIT; | |
1611 | ||
1612 | if (nPortIndex != OUTPUT_PORT_INDEX) { | |
1613 | ret = OMX_ErrorBadPortIndex; | |
1614 | goto EXIT; | |
1615 | } | |
1616 | ||
1617 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1618 | if (pIntraRefresh->eRefreshMode == OMX_VIDEO_IntraRefreshCyclic) { | |
1619 | pVideoEnc->intraRefresh.eRefreshMode = pIntraRefresh->eRefreshMode; | |
1620 | pVideoEnc->intraRefresh.nCirMBs = pIntraRefresh->nCirMBs; | |
1621 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "OMX_VIDEO_IntraRefreshCyclic Enable, nCirMBs: %d", | |
1622 | pVideoEnc->intraRefresh.nCirMBs); | |
1623 | } else { | |
1624 | ret = OMX_ErrorUnsupportedSetting; | |
1625 | goto EXIT; | |
1626 | } | |
1627 | ||
1628 | ret = OMX_ErrorNone; | |
1629 | } | |
1630 | break; | |
c6f4bc34 YK |
1631 | default: |
1632 | { | |
e4e150b8 | 1633 | ret = Exynos_OMX_SetParameter(hComponent, nParamIndex, pComponentParameterStructure); |
c6f4bc34 YK |
1634 | } |
1635 | break; | |
1636 | } | |
c6f4bc34 YK |
1637 | EXIT: |
1638 | FunctionOut(); | |
1639 | ||
1640 | return ret; | |
1641 | } | |
1642 | ||
1643 | OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetConfig( | |
e4e150b8 HK |
1644 | OMX_HANDLETYPE hComponent, |
1645 | OMX_INDEXTYPE nParamIndex, | |
1646 | OMX_PTR pComponentConfigStructure) | |
c6f4bc34 | 1647 | { |
e4e150b8 HK |
1648 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1649 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1650 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
c6f4bc34 YK |
1651 | |
1652 | FunctionIn(); | |
1653 | ||
e4e150b8 HK |
1654 | if ((hComponent == NULL) || |
1655 | (pComponentConfigStructure == NULL)) { | |
c6f4bc34 YK |
1656 | ret = OMX_ErrorBadParameter; |
1657 | goto EXIT; | |
1658 | } | |
1659 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
e4e150b8 | 1660 | |
c6f4bc34 YK |
1661 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
1662 | if (ret != OMX_ErrorNone) { | |
1663 | goto EXIT; | |
1664 | } | |
e4e150b8 | 1665 | |
c6f4bc34 YK |
1666 | if (pOMXComponent->pComponentPrivate == NULL) { |
1667 | ret = OMX_ErrorBadParameter; | |
1668 | goto EXIT; | |
1669 | } | |
1670 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
e4e150b8 | 1671 | |
c6f4bc34 YK |
1672 | if (pExynosComponent->currentState == OMX_StateInvalid) { |
1673 | ret = OMX_ErrorInvalidState; | |
1674 | goto EXIT; | |
1675 | } | |
1676 | ||
e4e150b8 | 1677 | switch (nParamIndex) { |
c6f4bc34 YK |
1678 | case OMX_IndexConfigVideoBitrate: |
1679 | { | |
e4e150b8 HK |
1680 | OMX_VIDEO_CONFIG_BITRATETYPE *pConfigBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure; |
1681 | OMX_U32 nPortIndex = pConfigBitrate->nPortIndex; | |
1682 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 | 1683 | |
e4e150b8 | 1684 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1685 | ret = OMX_ErrorBadPortIndex; |
1686 | goto EXIT; | |
1687 | } else { | |
e4e150b8 HK |
1688 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
1689 | pConfigBitrate->nEncodeBitrate = pExynosPort->portDefinition.format.video.nBitrate; | |
c6f4bc34 YK |
1690 | } |
1691 | } | |
1692 | break; | |
1693 | case OMX_IndexConfigVideoFramerate: | |
1694 | { | |
e4e150b8 HK |
1695 | OMX_CONFIG_FRAMERATETYPE *pConfigFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure; |
1696 | OMX_U32 nPortIndex = pConfigFramerate->nPortIndex; | |
1697 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 | 1698 | |
e4e150b8 | 1699 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1700 | ret = OMX_ErrorBadPortIndex; |
1701 | goto EXIT; | |
1702 | } else { | |
e4e150b8 HK |
1703 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
1704 | pConfigFramerate->xEncodeFramerate = pExynosPort->portDefinition.format.video.xFramerate; | |
c6f4bc34 YK |
1705 | } |
1706 | } | |
1707 | break; | |
ea1234c8 TK |
1708 | case OMX_IndexVendorGetBufferFD: |
1709 | { | |
1710 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1711 | EXYNOS_OMX_VIDEO_CONFIG_BUFFERINFO *pBufferInfo = (EXYNOS_OMX_VIDEO_CONFIG_BUFFERINFO *)pComponentConfigStructure; | |
1712 | ||
1713 | ret = Exynos_OMX_Check_SizeVersion(pBufferInfo, sizeof(EXYNOS_OMX_VIDEO_CONFIG_BUFFERINFO)); | |
1714 | if (ret != OMX_ErrorNone) | |
1715 | goto EXIT; | |
1716 | ||
1717 | pBufferInfo->fd = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, pBufferInfo->pVirAddr); | |
1718 | } | |
1719 | break; | |
c6f4bc34 | 1720 | default: |
e4e150b8 HK |
1721 | { |
1722 | ret = Exynos_OMX_GetConfig(hComponent, nParamIndex, pComponentConfigStructure); | |
1723 | } | |
c6f4bc34 YK |
1724 | break; |
1725 | } | |
c6f4bc34 YK |
1726 | EXIT: |
1727 | FunctionOut(); | |
1728 | ||
1729 | return ret; | |
1730 | } | |
1731 | ||
1732 | OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetConfig( | |
e4e150b8 HK |
1733 | OMX_HANDLETYPE hComponent, |
1734 | OMX_INDEXTYPE nParamIndex, | |
1735 | OMX_PTR pComponentConfigStructure) | |
c6f4bc34 | 1736 | { |
e4e150b8 HK |
1737 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1738 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1739 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
c6f4bc34 YK |
1740 | |
1741 | FunctionIn(); | |
1742 | ||
e4e150b8 HK |
1743 | if ((hComponent == NULL) || |
1744 | (pComponentConfigStructure == NULL)) { | |
c6f4bc34 YK |
1745 | ret = OMX_ErrorBadParameter; |
1746 | goto EXIT; | |
1747 | } | |
1748 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
e4e150b8 | 1749 | |
c6f4bc34 YK |
1750 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
1751 | if (ret != OMX_ErrorNone) { | |
1752 | goto EXIT; | |
1753 | } | |
e4e150b8 | 1754 | |
c6f4bc34 YK |
1755 | if (pOMXComponent->pComponentPrivate == NULL) { |
1756 | ret = OMX_ErrorBadParameter; | |
1757 | goto EXIT; | |
1758 | } | |
1759 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
e4e150b8 | 1760 | |
c6f4bc34 YK |
1761 | if (pExynosComponent->currentState == OMX_StateInvalid) { |
1762 | ret = OMX_ErrorInvalidState; | |
1763 | goto EXIT; | |
1764 | } | |
1765 | ||
e4e150b8 | 1766 | switch (nParamIndex) { |
c6f4bc34 YK |
1767 | case OMX_IndexConfigVideoBitrate: |
1768 | { | |
e4e150b8 HK |
1769 | OMX_VIDEO_CONFIG_BITRATETYPE *pConfigBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure; |
1770 | OMX_U32 nPortIndex = pConfigBitrate->nPortIndex; | |
1771 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 | 1772 | |
e4e150b8 | 1773 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1774 | ret = OMX_ErrorBadPortIndex; |
1775 | goto EXIT; | |
1776 | } else { | |
e4e150b8 HK |
1777 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
1778 | pExynosPort->portDefinition.format.video.nBitrate = pConfigBitrate->nEncodeBitrate; | |
c6f4bc34 YK |
1779 | } |
1780 | } | |
1781 | break; | |
1782 | case OMX_IndexConfigVideoFramerate: | |
1783 | { | |
e4e150b8 HK |
1784 | OMX_CONFIG_FRAMERATETYPE *pConfigFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure; |
1785 | OMX_U32 nPortIndex = pConfigFramerate->nPortIndex; | |
1786 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
c6f4bc34 | 1787 | |
e4e150b8 | 1788 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1789 | ret = OMX_ErrorBadPortIndex; |
1790 | goto EXIT; | |
1791 | } else { | |
e4e150b8 HK |
1792 | pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; |
1793 | pExynosPort->portDefinition.format.video.xFramerate = pConfigFramerate->xEncodeFramerate; | |
c6f4bc34 YK |
1794 | } |
1795 | } | |
1796 | break; | |
1797 | case OMX_IndexConfigVideoIntraVOPRefresh: | |
1798 | { | |
1799 | OMX_CONFIG_INTRAREFRESHVOPTYPE *pIntraRefreshVOP = (OMX_CONFIG_INTRAREFRESHVOPTYPE *)pComponentConfigStructure; | |
e4e150b8 HK |
1800 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; |
1801 | OMX_U32 nPortIndex = pIntraRefreshVOP->nPortIndex; | |
1802 | ||
1803 | if (pExynosComponent->hComponentHandle == NULL) { | |
1804 | ret = OMX_ErrorBadParameter; | |
1805 | goto EXIT; | |
1806 | } | |
1807 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
c6f4bc34 | 1808 | |
e4e150b8 | 1809 | if (nPortIndex != OUTPUT_PORT_INDEX) { |
c6f4bc34 YK |
1810 | ret = OMX_ErrorBadPortIndex; |
1811 | goto EXIT; | |
1812 | } else { | |
e4e150b8 | 1813 | pVideoEnc->IntraRefreshVOP = pIntraRefreshVOP->IntraRefreshVOP; |
c6f4bc34 YK |
1814 | } |
1815 | } | |
1816 | break; | |
433e798a EC |
1817 | #ifdef USE_QOS_CTRL |
1818 | case OMX_IndexVendorSetQosRatio: | |
1819 | { | |
1820 | EXYNOS_OMX_VIDEO_CONFIG_QOSINFO *pQosInfo = (EXYNOS_OMX_VIDEO_CONFIG_QOSINFO *)pComponentConfigStructure; | |
1821 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
1822 | ||
1823 | if (pExynosComponent->hComponentHandle == NULL) { | |
1824 | ret = OMX_ErrorBadParameter; | |
1825 | goto EXIT; | |
1826 | } | |
1827 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1828 | ||
1829 | ret = Exynos_OMX_Check_SizeVersion(pQosInfo, sizeof(EXYNOS_OMX_VIDEO_CONFIG_QOSINFO)); | |
1830 | if (ret != OMX_ErrorNone) | |
1831 | goto EXIT; | |
1832 | ||
1833 | pVideoEnc->nQosRatio = pQosInfo->nQosRatio; | |
1834 | pVideoEnc->bQosChanged = OMX_TRUE; | |
1835 | ||
1836 | ret = OMX_ErrorNone; | |
1837 | } | |
1838 | break; | |
1839 | #endif | |
c6f4bc34 | 1840 | default: |
e4e150b8 HK |
1841 | { |
1842 | ret = Exynos_OMX_SetConfig(hComponent, nParamIndex, pComponentConfigStructure); | |
1843 | } | |
c6f4bc34 YK |
1844 | break; |
1845 | } | |
c6f4bc34 YK |
1846 | EXIT: |
1847 | FunctionOut(); | |
1848 | ||
1849 | return ret; | |
1850 | } | |
1851 | ||
1852 | OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetExtensionIndex( | |
1853 | OMX_IN OMX_HANDLETYPE hComponent, | |
e4e150b8 | 1854 | OMX_IN OMX_STRING szParamName, |
c6f4bc34 YK |
1855 | OMX_OUT OMX_INDEXTYPE *pIndexType) |
1856 | { | |
e4e150b8 HK |
1857 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1858 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1859 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
c6f4bc34 YK |
1860 | |
1861 | FunctionIn(); | |
1862 | ||
1863 | if (hComponent == NULL) { | |
1864 | ret = OMX_ErrorBadParameter; | |
1865 | goto EXIT; | |
1866 | } | |
1867 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
e4e150b8 | 1868 | |
c6f4bc34 YK |
1869 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); |
1870 | if (ret != OMX_ErrorNone) { | |
1871 | goto EXIT; | |
1872 | } | |
1873 | ||
1874 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1875 | ret = OMX_ErrorBadParameter; | |
1876 | goto EXIT; | |
1877 | } | |
1878 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1879 | ||
e4e150b8 | 1880 | if ((szParamName == NULL) || (pIndexType == NULL)) { |
c6f4bc34 YK |
1881 | ret = OMX_ErrorBadParameter; |
1882 | goto EXIT; | |
1883 | } | |
e4e150b8 | 1884 | |
c6f4bc34 YK |
1885 | if (pExynosComponent->currentState == OMX_StateInvalid) { |
1886 | ret = OMX_ErrorInvalidState; | |
1887 | goto EXIT; | |
1888 | } | |
1889 | ||
c31a957e TK |
1890 | if (Exynos_OSAL_Strcmp(szParamName, EXYNOS_INDEX_PARAM_NEED_CONTIG_MEMORY) == 0) { |
1891 | *pIndexType = (OMX_INDEXTYPE) OMX_IndexVendorNeedContigMemory; | |
1892 | ret = OMX_ErrorNone; | |
1893 | goto EXIT; | |
ea1234c8 TK |
1894 | } else if (Exynos_OSAL_Strcmp(szParamName, EXYNOS_INDEX_CONFIG_GET_BUFFER_FD) == 0) { |
1895 | *pIndexType = (OMX_INDEXTYPE) OMX_IndexVendorGetBufferFD; | |
1896 | ret = OMX_ErrorNone; | |
1897 | goto EXIT; | |
c31a957e | 1898 | } |
433e798a EC |
1899 | #ifdef USE_QOS_CTRL |
1900 | else if (Exynos_OSAL_Strcmp(szParamName, EXYNOS_INDEX_CONFIG_SET_QOS_RATIO) == 0) { | |
1901 | *pIndexType = (OMX_INDEXTYPE) OMX_IndexVendorSetQosRatio; | |
1902 | ret = OMX_ErrorNone; | |
1903 | goto EXIT; | |
1904 | } | |
1905 | #endif | |
c31a957e | 1906 | |
c6f4bc34 | 1907 | #ifdef USE_STOREMETADATA |
e4e150b8 HK |
1908 | if (Exynos_OSAL_Strcmp(szParamName, EXYNOS_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) { |
1909 | *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamStoreMetaDataBuffer; | |
c6f4bc34 | 1910 | } else { |
e4e150b8 | 1911 | ret = Exynos_OMX_GetExtensionIndex(hComponent, szParamName, pIndexType); |
c6f4bc34 YK |
1912 | } |
1913 | #else | |
e4e150b8 | 1914 | ret = Exynos_OMX_GetExtensionIndex(hComponent, szParamName, pIndexType); |
c6f4bc34 | 1915 | #endif |
c6f4bc34 YK |
1916 | EXIT: |
1917 | FunctionOut(); | |
1918 | ||
1919 | return ret; | |
1920 | } | |
323488ff SK |
1921 | |
1922 | OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer, OMX_BOOL bNeedUnlock) | |
1923 | { | |
1924 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1925 | ||
1926 | pUseBuffer->bufferHeader = pData->bufferHeader; | |
1927 | pUseBuffer->allocSize = pData->allocSize; | |
1928 | pUseBuffer->dataLen = pData->dataLen; | |
1929 | pUseBuffer->usedDataLen = pData->usedDataLen; | |
1930 | pUseBuffer->remainDataLen = pData->remainDataLen; | |
1931 | pUseBuffer->timeStamp = pData->timeStamp; | |
1932 | pUseBuffer->nFlags = pData->nFlags; | |
1933 | pUseBuffer->pPrivate = pData->pPrivate; | |
1934 | ||
1935 | if ((bNeedUnlock == OMX_TRUE) && (pUseBuffer->bufferHeader != NULL)) { | |
1936 | OMX_PTR ppBuf[MAX_BUFFER_PLANE]; | |
433e798a EC |
1937 | if (OMX_ErrorNone == |
1938 | Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pUseBuffer->bufferHeader->pBuffer, ppBuf)) | |
9d7f3c95 | 1939 | Exynos_OSAL_UnlockANBHandle((OMX_U32)ppBuf[0]); |
323488ff SK |
1940 | } |
1941 | ||
1942 | return ret; | |
1943 | } |