video: changed the memory type about ION
[GitHub/LineageOS/android_hardware_samsung_slsi_openmax.git] / component / video / dec / Exynos_OMX_VdecControl.c
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_VdecControl.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_Vdec.h"
33 #include "Exynos_OMX_VdecControl.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 #include "ExynosVideoApi.h"
46
47 #undef EXYNOS_LOG_TAG
48 #define EXYNOS_LOG_TAG "EXYNOS_VIDEO_DECCONTROL"
49 #define EXYNOS_LOG_OFF
50 //#define EXYNOS_TRACE_ON
51 #include "Exynos_OSAL_Log.h"
52
53
54 OMX_ERRORTYPE Exynos_OMX_UseBuffer(
55 OMX_IN OMX_HANDLETYPE hComponent,
56 OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
57 OMX_IN OMX_U32 nPortIndex,
58 OMX_IN OMX_PTR pAppPrivate,
59 OMX_IN OMX_U32 nSizeBytes,
60 OMX_IN OMX_U8 *pBuffer)
61 {
62 OMX_ERRORTYPE ret = OMX_ErrorNone;
63 OMX_COMPONENTTYPE *pOMXComponent = NULL;
64 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
65 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
66 OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
67 OMX_U32 i = 0;
68
69 FunctionIn();
70
71 if (hComponent == NULL) {
72 ret = OMX_ErrorBadParameter;
73 goto EXIT;
74 }
75 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
76 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
77 if (ret != OMX_ErrorNone) {
78 goto EXIT;
79 }
80
81 if (pOMXComponent->pComponentPrivate == NULL) {
82 ret = OMX_ErrorBadParameter;
83 goto EXIT;
84 }
85 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
86
87 pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
88 if (nPortIndex >= pExynosComponent->portParam.nPorts) {
89 ret = OMX_ErrorBadPortIndex;
90 goto EXIT;
91 }
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
102 temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
103 if (temp_bufferHeader == NULL) {
104 ret = OMX_ErrorInsufficientResources;
105 goto EXIT;
106 }
107 Exynos_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
108
109 for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) {
110 if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
111 pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
112 pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
113 INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
114 temp_bufferHeader->pBuffer = pBuffer;
115 temp_bufferHeader->nAllocLen = nSizeBytes;
116 temp_bufferHeader->pAppPrivate = pAppPrivate;
117 if (nPortIndex == INPUT_PORT_INDEX)
118 temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
119 else
120 temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
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 }
129 *ppBufferHdr = temp_bufferHeader;
130 ret = OMX_ErrorNone;
131 goto EXIT;
132 }
133 }
134
135 Exynos_OSAL_Free(temp_bufferHeader);
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,
146 OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
147 OMX_IN OMX_U32 nPortIndex,
148 OMX_IN OMX_PTR pAppPrivate,
149 OMX_IN OMX_U32 nSizeBytes)
150 {
151 OMX_ERRORTYPE ret = OMX_ErrorNone;
152 OMX_COMPONENTTYPE *pOMXComponent = NULL;
153 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
154 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
155 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
156 OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
157 OMX_U8 *temp_buffer = NULL;
158 int temp_buffer_fd = -1;
159 OMX_U32 i = 0;
160 MEMORY_TYPE mem_type = SYSTEM_MEMORY;
161
162 FunctionIn();
163
164 if (hComponent == NULL) {
165 ret = OMX_ErrorBadParameter;
166 goto EXIT;
167 }
168 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
169 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
170 if (ret != OMX_ErrorNone) {
171 goto EXIT;
172 }
173
174 if (pOMXComponent->pComponentPrivate == NULL) {
175 ret = OMX_ErrorBadParameter;
176 goto EXIT;
177 }
178 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
179 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
180
181 pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
182 if (nPortIndex >= pExynosComponent->portParam.nPorts) {
183 ret = OMX_ErrorBadPortIndex;
184 goto EXIT;
185 }
186 /*
187 if (pExynosPort->portState != OMX_StateIdle ) {
188 ret = OMX_ErrorIncorrectStateOperation;
189 goto EXIT;
190 }
191 */
192 if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) {
193 ret = OMX_ErrorBadPortIndex;
194 goto EXIT;
195 }
196
197 if ((pVideoDec->bDRMPlayerMode == OMX_TRUE) &&
198 (nPortIndex == INPUT_PORT_INDEX)) {
199 mem_type = SECURE_MEMORY;
200 } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
201 (pExynosPort->bufferProcessType & BUFFER_SHARE)) {
202 mem_type = NORMAL_MEMORY;
203 }
204
205 temp_buffer = Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nSizeBytes, mem_type);
206 if (temp_buffer == NULL) {
207 ret = OMX_ErrorInsufficientResources;
208 goto EXIT;
209 }
210 temp_buffer_fd = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, temp_buffer);
211
212 temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
213 if (temp_bufferHeader == NULL) {
214 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, temp_buffer);
215 ret = OMX_ErrorInsufficientResources;
216 goto EXIT;
217 }
218 Exynos_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
219
220 for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) {
221 if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
222 pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
223 pExynosPort->extendBufferHeader[i].buf_fd[0] = temp_buffer_fd;
224 pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED);
225 INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
226 if (mem_type == SECURE_MEMORY)
227 temp_bufferHeader->pBuffer = temp_buffer_fd;
228 else
229 temp_bufferHeader->pBuffer = temp_buffer;
230 temp_bufferHeader->nAllocLen = nSizeBytes;
231 temp_bufferHeader->pAppPrivate = pAppPrivate;
232 if (nPortIndex == INPUT_PORT_INDEX)
233 temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
234 else
235 temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
236 pExynosPort->assignedBufferNum++;
237 if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) {
238 pExynosPort->portDefinition.bPopulated = OMX_TRUE;
239 /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
240 Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource);
241 /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
242 }
243 *ppBuffer = temp_bufferHeader;
244 ret = OMX_ErrorNone;
245 goto EXIT;
246 }
247 }
248
249 Exynos_OSAL_Free(temp_bufferHeader);
250 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, temp_buffer);
251
252 ret = OMX_ErrorInsufficientResources;
253
254 EXIT:
255 FunctionOut();
256
257 return ret;
258 }
259
260 OMX_ERRORTYPE Exynos_OMX_FreeBuffer(
261 OMX_IN OMX_HANDLETYPE hComponent,
262 OMX_IN OMX_U32 nPortIndex,
263 OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr)
264 {
265 OMX_ERRORTYPE ret = OMX_ErrorNone;
266 OMX_COMPONENTTYPE *pOMXComponent = NULL;
267 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
268 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
269 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
270 OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
271 OMX_U8 *temp_buffer = NULL;
272 OMX_U32 i = 0;
273
274 FunctionIn();
275
276 if (hComponent == NULL) {
277 ret = OMX_ErrorBadParameter;
278 goto EXIT;
279 }
280 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
281 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
282 if (ret != OMX_ErrorNone) {
283 goto EXIT;
284 }
285
286 if (pOMXComponent->pComponentPrivate == NULL) {
287 ret = OMX_ErrorBadParameter;
288 goto EXIT;
289 }
290 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
291 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
292 pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
293
294 if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) {
295 ret = OMX_ErrorBadPortIndex;
296 goto EXIT;
297 }
298
299 if ((pExynosPort->portState != OMX_StateLoaded) && (pExynosPort->portState != OMX_StateInvalid)) {
300 (*(pExynosComponent->pCallbacks->EventHandler)) (pOMXComponent,
301 pExynosComponent->callbackData,
302 (OMX_U32)OMX_EventError,
303 (OMX_U32)OMX_ErrorPortUnpopulated,
304 nPortIndex, NULL);
305 }
306
307 for (i = 0; i < /*pExynosPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) {
308 if (((pExynosPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pExynosPort->extendBufferHeader[i].OMXBufferHeader != NULL)) {
309 if (pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer == pBufferHdr->pBuffer) {
310 if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) {
311 if ((pVideoDec->bDRMPlayerMode == OMX_TRUE) && (nPortIndex == INPUT_PORT_INDEX)) {
312 OMX_PTR mapBuffer = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory, (int)pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
313 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, mapBuffer);
314 } else {
315 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
316 }
317 pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer = NULL;
318 pBufferHdr->pBuffer = NULL;
319 } else if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) {
320 ; /* None*/
321 }
322 pExynosPort->assignedBufferNum--;
323 if (pExynosPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) {
324 Exynos_OSAL_Free(pExynosPort->extendBufferHeader[i].OMXBufferHeader);
325 pExynosPort->extendBufferHeader[i].OMXBufferHeader = NULL;
326 pBufferHdr = NULL;
327 }
328 pExynosPort->bufferStateAllocate[i] = BUFFER_STATE_FREE;
329 ret = OMX_ErrorNone;
330 goto EXIT;
331 }
332 }
333 }
334
335 EXIT:
336 if (ret == OMX_ErrorNone) {
337 if (pExynosPort->assignedBufferNum == 0) {
338 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosPort->unloadedResource signal set");
339 /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
340 Exynos_OSAL_SemaphorePost(pExynosPort->unloadedResource);
341 /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
342 pExynosPort->portDefinition.bPopulated = OMX_FALSE;
343 }
344 }
345
346 FunctionOut();
347
348 return ret;
349 }
350
351 OMX_ERRORTYPE Exynos_OMX_AllocateTunnelBuffer(EXYNOS_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
352 {
353 OMX_ERRORTYPE ret = OMX_ErrorNone;
354 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
355 OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
356 OMX_U8 *temp_buffer = NULL;
357 OMX_U32 bufferSize = 0;
358 OMX_PARAM_PORTDEFINITIONTYPE portDefinition;
359
360 ret = OMX_ErrorTunnelingUnsupported;
361 EXIT:
362 return ret;
363 }
364
365 OMX_ERRORTYPE Exynos_OMX_FreeTunnelBuffer(EXYNOS_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
366 {
367 OMX_ERRORTYPE ret = OMX_ErrorNone;
368 EXYNOS_OMX_BASEPORT* pExynosPort = NULL;
369 OMX_BUFFERHEADERTYPE* temp_bufferHeader = NULL;
370 OMX_U8 *temp_buffer = NULL;
371 OMX_U32 bufferSize = 0;
372
373 ret = OMX_ErrorTunnelingUnsupported;
374 EXIT:
375 return ret;
376 }
377
378 OMX_ERRORTYPE Exynos_OMX_ComponentTunnelRequest(
379 OMX_IN OMX_HANDLETYPE hComp,
380 OMX_IN OMX_U32 nPort,
381 OMX_IN OMX_HANDLETYPE hTunneledComp,
382 OMX_IN OMX_U32 nTunneledPort,
383 OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup)
384 {
385 OMX_ERRORTYPE ret = OMX_ErrorNone;
386
387 ret = OMX_ErrorTunnelingUnsupported;
388 EXIT:
389 return ret;
390 }
391
392 OMX_ERRORTYPE Exynos_OMX_GetFlushBuffer(EXYNOS_OMX_BASEPORT *pExynosPort, EXYNOS_OMX_DATABUFFER *pDataBuffer[])
393 {
394 OMX_ERRORTYPE ret = OMX_ErrorNone;
395
396 FunctionIn();
397
398 *pDataBuffer = NULL;
399
400 if (pExynosPort->portWayType == WAY1_PORT) {
401 *pDataBuffer = &pExynosPort->way.port1WayDataBuffer.dataBuffer;
402 } else if (pExynosPort->portWayType == WAY2_PORT) {
403 pDataBuffer[0] = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);
404 pDataBuffer[1] = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer);
405 }
406
407 EXIT:
408 FunctionOut();
409
410 return ret;
411 }
412
413 OMX_ERRORTYPE Exynos_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex)
414 {
415 OMX_ERRORTYPE ret = OMX_ErrorNone;
416 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
417 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
418 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
419 OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
420 EXYNOS_OMX_DATABUFFER *pDataPortBuffer[2] = {NULL, NULL};
421 EXYNOS_OMX_MESSAGE *message = NULL;
422 OMX_U32 flushNum = 0;
423 OMX_S32 semValue = 0;
424 int i = 0, maxBufferNum = 0;
425 FunctionIn();
426
427 pExynosPort = &pExynosComponent->pExynosPort[portIndex];
428
429 while (Exynos_OSAL_GetElemNum(&pExynosPort->bufferQ) > 0) {
430 Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[portIndex].bufferSemID, &semValue);
431 if (semValue == 0)
432 Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[portIndex].bufferSemID);
433
434 Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[portIndex].bufferSemID);
435 message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
436 if ((message != NULL) && (message->messageType != EXYNOS_OMX_CommandFakeBuffer)) {
437 bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData;
438 bufferHeader->nFilledLen = 0;
439
440 if (portIndex == OUTPUT_PORT_INDEX) {
441 Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
442 } else if (portIndex == INPUT_PORT_INDEX) {
443 Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
444 }
445 }
446 Exynos_OSAL_Free(message);
447 message = NULL;
448 }
449
450 Exynos_OMX_GetFlushBuffer(pExynosPort, pDataPortBuffer);
451 if (portIndex == INPUT_PORT_INDEX) {
452 if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
453 Exynos_InputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
454 if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
455 Exynos_InputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
456 } else if (portIndex == OUTPUT_PORT_INDEX) {
457 if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
458 Exynos_OutputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
459 if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
460 Exynos_OutputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
461 }
462
463 if (pExynosComponent->bMultiThreadProcess == OMX_TRUE) {
464 if (pExynosPort->bufferProcessType & BUFFER_SHARE) {
465 if (pExynosPort->processData.bufferHeader != NULL) {
466 if (portIndex == INPUT_PORT_INDEX) {
467 Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader);
468 } else if (portIndex == OUTPUT_PORT_INDEX) {
469 #ifdef USE_ANB
470 if (pExynosPort->bIsANBEnabled == OMX_TRUE)
471 Exynos_OSAL_UnlockANB(pExynosPort->processData.bufferHeader->pBuffer);
472 #endif
473 Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader);
474 }
475 }
476 Exynos_ResetCodecData(&pExynosPort->processData);
477
478 if (pVideoDec->bReconfigDPB == OMX_TRUE)
479 maxBufferNum = pVideoDec->nSavedDPBCnt;
480 else
481 maxBufferNum = pExynosPort->portDefinition.nBufferCountActual;
482 for (i = 0; i < maxBufferNum; i++) {
483 if (pExynosPort->extendBufferHeader[i].bBufferInOMX == OMX_TRUE) {
484 if (portIndex == OUTPUT_PORT_INDEX) {
485 #ifdef USE_ANB
486 if (pExynosPort->bIsANBEnabled == OMX_TRUE)
487 Exynos_OSAL_UnlockANB(pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
488 #endif
489 Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader);
490 } else if (portIndex == INPUT_PORT_INDEX) {
491 Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader);
492 }
493 }
494 }
495 }
496 } else {
497 Exynos_ResetCodecData(&pExynosPort->processData);
498 }
499
500 while(1) {
501 OMX_S32 cnt = 0;
502 Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[portIndex].bufferSemID, &cnt);
503 if (cnt <= 0)
504 break;
505 Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[portIndex].bufferSemID);
506 }
507 Exynos_OSAL_ResetQueue(&pExynosPort->bufferQ);
508
509 EXIT:
510 FunctionOut();
511
512 return ret;
513 }
514
515 OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent)
516 {
517 OMX_ERRORTYPE ret = OMX_ErrorNone;
518 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
519 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
520 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
521 EXYNOS_OMX_DATABUFFER *flushPortBuffer[2] = {NULL, NULL};
522 OMX_U32 i = 0, cnt = 0;
523
524 FunctionIn();
525
526 if (pOMXComponent == NULL) {
527 ret = OMX_ErrorBadParameter;
528 goto EXIT;
529 }
530 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
531 if (ret != OMX_ErrorNone) {
532 goto EXIT;
533 }
534
535 if (pOMXComponent->pComponentPrivate == NULL) {
536 ret = OMX_ErrorBadParameter;
537 goto EXIT;
538 }
539 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
540 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
541
542 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush start, port:%d", nPortIndex);
543
544 pExynosComponent->pExynosPort[nPortIndex].bIsPortFlushed = OMX_TRUE;
545
546 if (pExynosComponent->bMultiThreadProcess == OMX_FALSE) {
547 Exynos_OSAL_SignalSet(pExynosComponent->pauseEvent);
548 } else {
549 Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[nPortIndex].pauseEvent);
550 }
551
552 pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
553 Exynos_OMX_GetFlushBuffer(pExynosPort, flushPortBuffer);
554
555 if (pExynosComponent->pExynosPort[nPortIndex].bufferProcessType & BUFFER_COPY)
556 Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID);
557 Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID);
558
559 pVideoDec->exynos_codec_bufferProcessRun(pOMXComponent, nPortIndex);
560 Exynos_OSAL_MutexLock(flushPortBuffer[0]->bufferMutex);
561 pVideoDec->exynos_codec_stop(pOMXComponent, nPortIndex);
562 Exynos_OSAL_MutexLock(flushPortBuffer[1]->bufferMutex);
563 ret = Exynos_OMX_FlushPort(pOMXComponent, nPortIndex);
564 if (pVideoDec->bReconfigDPB == OMX_TRUE)
565 pVideoDec->exynos_codec_reconfigAllBuffers(pOMXComponent, nPortIndex);
566 else if (pExynosComponent->pExynosPort[nPortIndex].bufferProcessType & BUFFER_COPY)
567 pVideoDec->exynos_codec_enqueueAllBuffer(pOMXComponent, nPortIndex);
568 Exynos_ResetCodecData(&pExynosPort->processData);
569
570 if (ret == OMX_ErrorNone) {
571 if (nPortIndex == INPUT_PORT_INDEX) {
572 pExynosComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
573 pExynosComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
574 Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
575 Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
576 pExynosComponent->getAllDelayBuffer = OMX_FALSE;
577 pExynosComponent->bSaveFlagEOS = OMX_FALSE;
578 pExynosComponent->reInputData = OMX_FALSE;
579 }
580
581 pExynosComponent->pExynosPort[nPortIndex].bIsPortFlushed = OMX_FALSE;
582 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush EventCmdComplete, port:%d", nPortIndex);
583 if (bEvent == OMX_TRUE)
584 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
585 pExynosComponent->callbackData,
586 OMX_EventCmdComplete,
587 OMX_CommandFlush, nPortIndex, NULL);
588 }
589 Exynos_OSAL_MutexUnlock(flushPortBuffer[1]->bufferMutex);
590 Exynos_OSAL_MutexUnlock(flushPortBuffer[0]->bufferMutex);
591
592 EXIT:
593 if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pExynosComponent != NULL)) {
594 Exynos_OSAL_Log(EXYNOS_LOG_ERROR,"%s : %d", __FUNCTION__, __LINE__);
595 pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
596 pExynosComponent->callbackData,
597 OMX_EventError,
598 ret, 0, NULL);
599 }
600
601 FunctionOut();
602
603 return ret;
604 }
605
606 OMX_ERRORTYPE Exynos_InputBufferReturn(
607 OMX_COMPONENTTYPE *pOMXComponent,
608 EXYNOS_OMX_DATABUFFER *pDataBuffer)
609 {
610 OMX_ERRORTYPE ret = OMX_ErrorNone;
611 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
612 EXYNOS_OMX_BASEPORT *pInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
613 OMX_BUFFERHEADERTYPE *pBufferHdr = NULL;
614
615 FunctionIn();
616
617 pBufferHdr = pDataBuffer->bufferHeader;
618
619 if (pBufferHdr != NULL) {
620 if (pInputPort->markType.hMarkTargetComponent != NULL) {
621 pBufferHdr->hMarkTargetComponent = pInputPort->markType.hMarkTargetComponent;
622 pBufferHdr->pMarkData = pInputPort->markType.pMarkData;
623 pInputPort->markType.hMarkTargetComponent = NULL;
624 pInputPort->markType.pMarkData = NULL;
625 }
626
627 if (pBufferHdr->hMarkTargetComponent != NULL) {
628 if (pBufferHdr->hMarkTargetComponent == pOMXComponent) {
629 pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
630 pExynosComponent->callbackData,
631 OMX_EventMark,
632 0, 0, pBufferHdr->pMarkData);
633 } else {
634 pExynosComponent->propagateMarkType.hMarkTargetComponent = pBufferHdr->hMarkTargetComponent;
635 pExynosComponent->propagateMarkType.pMarkData = pBufferHdr->pMarkData;
636 }
637 }
638
639 pBufferHdr->nFilledLen = 0;
640 pBufferHdr->nOffset = 0;
641 Exynos_OMX_InputBufferReturn(pOMXComponent, pBufferHdr);
642 }
643
644 /* reset dataBuffer */
645 Exynos_ResetDataBuffer(pDataBuffer);
646
647 EXIT:
648 FunctionOut();
649
650 return ret;
651 }
652
653 OMX_ERRORTYPE Exynos_InputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
654 {
655 OMX_ERRORTYPE ret = OMX_ErrorUndefined;
656 EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
657 EXYNOS_OMX_MESSAGE *message = NULL;
658 EXYNOS_OMX_DATABUFFER *inputUseBuffer = NULL;
659
660 FunctionIn();
661
662 inputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);
663
664 if (pExynosComponent->currentState != OMX_StateExecuting) {
665 ret = OMX_ErrorUndefined;
666 goto EXIT;
667 } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
668 (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) {
669 Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);
670 if (inputUseBuffer->dataValid != OMX_TRUE) {
671 message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
672 if (message == NULL) {
673 ret = OMX_ErrorUndefined;
674 goto EXIT;
675 }
676 if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
677 Exynos_OSAL_Free(message);
678 ret = OMX_ErrorCodecFlush;
679 goto EXIT;
680 }
681
682 inputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
683 inputUseBuffer->allocSize = inputUseBuffer->bufferHeader->nAllocLen;
684 inputUseBuffer->dataLen = inputUseBuffer->bufferHeader->nFilledLen;
685 inputUseBuffer->remainDataLen = inputUseBuffer->dataLen;
686 inputUseBuffer->usedDataLen = 0;
687 inputUseBuffer->dataValid = OMX_TRUE;
688 inputUseBuffer->nFlags = inputUseBuffer->bufferHeader->nFlags;
689 inputUseBuffer->timeStamp = inputUseBuffer->bufferHeader->nTimeStamp;
690
691 Exynos_OSAL_Free(message);
692
693 if (inputUseBuffer->allocSize <= inputUseBuffer->dataLen)
694 Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", inputUseBuffer->allocSize, inputUseBuffer->dataLen);
695 }
696 ret = OMX_ErrorNone;
697 }
698 EXIT:
699 FunctionOut();
700
701 return ret;
702 }
703
704 OMX_ERRORTYPE Exynos_OutputBufferReturn(
705 OMX_COMPONENTTYPE *pOMXComponent,
706 EXYNOS_OMX_DATABUFFER *pDataBuffer)
707 {
708 OMX_ERRORTYPE ret = OMX_ErrorNone;
709 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
710 OMX_BUFFERHEADERTYPE *pBufferHdr = pDataBuffer->bufferHeader;
711
712 FunctionIn();
713
714 if (pBufferHdr != NULL) {
715 pBufferHdr->nFilledLen = pDataBuffer->remainDataLen;
716 pBufferHdr->nOffset = 0;
717 pBufferHdr->nFlags = pDataBuffer->nFlags;
718 pBufferHdr->nTimeStamp = pDataBuffer->timeStamp;
719
720 if (pExynosComponent->propagateMarkType.hMarkTargetComponent != NULL) {
721 pBufferHdr->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent;
722 pBufferHdr->pMarkData = pExynosComponent->propagateMarkType.pMarkData;
723
724 pExynosComponent->propagateMarkType.hMarkTargetComponent = NULL;
725 pExynosComponent->propagateMarkType.pMarkData = NULL;
726 }
727
728 if ((pBufferHdr->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
729 pBufferHdr->nFilledLen = 0;
730 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"event OMX_BUFFERFLAG_EOS!!!");
731 pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
732 pExynosComponent->callbackData,
733 OMX_EventBufferFlag,
734 OUTPUT_PORT_INDEX,
735 pBufferHdr->nFlags, NULL);
736 }
737 Exynos_OMX_OutputBufferReturn(pOMXComponent, pBufferHdr);
738 }
739
740 /* reset dataBuffer */
741 Exynos_ResetDataBuffer(pDataBuffer);
742
743 EXIT:
744 FunctionOut();
745
746 return ret;
747 }
748
749 OMX_ERRORTYPE Exynos_OutputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
750 {
751 OMX_ERRORTYPE ret = OMX_ErrorUndefined;
752 EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
753 EXYNOS_OMX_MESSAGE *message = NULL;
754 EXYNOS_OMX_DATABUFFER *outputUseBuffer = NULL;
755
756 FunctionIn();
757
758 if (pExynosPort->bufferProcessType & BUFFER_COPY) {
759 outputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer);
760 } else if (pExynosPort->bufferProcessType & BUFFER_SHARE) {
761 outputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);
762 }
763
764 if (pExynosComponent->currentState != OMX_StateExecuting) {
765 ret = OMX_ErrorUndefined;
766 goto EXIT;
767 } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
768 (!CHECK_PORT_BEING_FLUSHED(pExynosPort))){
769 Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);
770 if (outputUseBuffer->dataValid != OMX_TRUE) {
771 message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
772 if (message == NULL) {
773 ret = OMX_ErrorUndefined;
774 goto EXIT;
775 }
776 if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
777 Exynos_OSAL_Free(message);
778 ret = OMX_ErrorCodecFlush;
779 goto EXIT;
780 }
781
782 outputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
783 outputUseBuffer->allocSize = outputUseBuffer->bufferHeader->nAllocLen;
784 outputUseBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen;
785 outputUseBuffer->remainDataLen = outputUseBuffer->dataLen;
786 outputUseBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset;
787 outputUseBuffer->dataValid = OMX_TRUE;
788 /* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */
789 /* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */
790 /*
791 if (pExynosPort->bufferProcessType & BUFFER_SHARE)
792 outputUseBuffer->pPrivate = outputUseBuffer->bufferHeader->pOutputPortPrivate;
793 else if (pExynosPort->bufferProcessType & BUFFER_COPY) {
794 pExynosPort->processData.dataBuffer = outputUseBuffer->bufferHeader->pBuffer;
795 pExynosPort->processData.allocSize = outputUseBuffer->bufferHeader->nAllocLen;
796 }
797 */
798
799 Exynos_OSAL_Free(message);
800 }
801 ret = OMX_ErrorNone;
802 }
803 EXIT:
804 FunctionOut();
805
806 return ret;
807
808 }
809
810 OMX_BUFFERHEADERTYPE *Exynos_OutputBufferGetQueue_Direct(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
811 {
812 OMX_BUFFERHEADERTYPE *retBuffer = NULL;
813 EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
814 EXYNOS_OMX_MESSAGE *message = NULL;
815
816 FunctionIn();
817
818 if (pExynosComponent->currentState != OMX_StateExecuting) {
819 retBuffer = NULL;
820 goto EXIT;
821 } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
822 (!CHECK_PORT_BEING_FLUSHED(pExynosPort))){
823 Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);
824
825 message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
826 if (message == NULL) {
827 retBuffer = NULL;
828 goto EXIT;
829 }
830 if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
831 Exynos_OSAL_Free(message);
832 retBuffer = NULL;
833 goto EXIT;
834 }
835
836 retBuffer = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
837 Exynos_OSAL_Free(message);
838 }
839
840 EXIT:
841 FunctionOut();
842
843 return retBuffer;
844 }
845
846 OMX_ERRORTYPE Exynos_CodecBufferEnQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex, OMX_PTR data)
847 {
848 OMX_ERRORTYPE ret = OMX_ErrorNone;
849 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
850
851 FunctionIn();
852
853 pExynosPort= &pExynosComponent->pExynosPort[PortIndex];
854
855 if (data == NULL) {
856 ret = OMX_ErrorInsufficientResources;
857 goto EXIT;
858 }
859
860 ret = Exynos_OSAL_Queue(&pExynosPort->codecBufferQ, (void *)data);
861 if (ret != 0) {
862 ret = OMX_ErrorUndefined;
863 goto EXIT;
864 }
865 Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID);
866
867 ret = OMX_ErrorNone;
868
869 EXIT:
870 FunctionOut();
871
872 return ret;
873 }
874
875 OMX_ERRORTYPE Exynos_CodecBufferDeQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex, OMX_PTR *data)
876 {
877 OMX_ERRORTYPE ret = OMX_ErrorNone;
878 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
879 OMX_U32 tempData;
880
881 FunctionIn();
882
883 pExynosPort = &pExynosComponent->pExynosPort[PortIndex];
884 Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID);
885 tempData = (OMX_U32)Exynos_OSAL_Dequeue(&pExynosPort->codecBufferQ);
886 if (tempData == NULL) {
887 *data = NULL;
888 ret = OMX_ErrorUndefined;
889 goto EXIT;
890 }
891 *data = (OMX_PTR)tempData;
892
893 ret = OMX_ErrorNone;
894
895 EXIT:
896 FunctionOut();
897
898 return ret;
899 }
900
901 OMX_ERRORTYPE Exynos_CodecBufferReset(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex)
902 {
903 OMX_ERRORTYPE ret = OMX_ErrorNone;
904 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
905
906 FunctionIn();
907
908 pExynosPort= &pExynosComponent->pExynosPort[PortIndex];
909
910 ret = Exynos_OSAL_ResetQueue(&pExynosPort->codecBufferQ);
911 if (ret != 0) {
912 ret = OMX_ErrorUndefined;
913 goto EXIT;
914 }
915 while (1) {
916 int cnt = 0;
917 Exynos_OSAL_Get_SemaphoreCount(pExynosPort->codecSemID, &cnt);
918 if (cnt > 0)
919 Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID);
920 else
921 break;
922 }
923 ret = OMX_ErrorNone;
924
925 EXIT:
926 FunctionOut();
927
928 return ret;
929 }
930
931 OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetParameter(
932 OMX_IN OMX_HANDLETYPE hComponent,
933 OMX_IN OMX_INDEXTYPE nParamIndex,
934 OMX_INOUT OMX_PTR ComponentParameterStructure)
935 {
936 OMX_ERRORTYPE ret = OMX_ErrorNone;
937 OMX_COMPONENTTYPE *pOMXComponent = NULL;
938 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
939 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
940
941 FunctionIn();
942
943 if (hComponent == NULL) {
944 ret = OMX_ErrorBadParameter;
945 goto EXIT;
946 }
947 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
948 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
949 if (ret != OMX_ErrorNone) {
950 goto EXIT;
951 }
952
953 if (pOMXComponent->pComponentPrivate == NULL) {
954 ret = OMX_ErrorBadParameter;
955 goto EXIT;
956 }
957 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
958
959 if (pExynosComponent->currentState == OMX_StateInvalid ) {
960 ret = OMX_ErrorInvalidState;
961 goto EXIT;
962 }
963
964 if (ComponentParameterStructure == NULL) {
965 ret = OMX_ErrorBadParameter;
966 goto EXIT;
967 }
968
969 switch (nParamIndex) {
970 case OMX_IndexParamVideoInit:
971 {
972 OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
973 ret = Exynos_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE));
974 if (ret != OMX_ErrorNone) {
975 goto EXIT;
976 }
977
978 portParam->nPorts = pExynosComponent->portParam.nPorts;
979 portParam->nStartPortNumber = pExynosComponent->portParam.nStartPortNumber;
980 ret = OMX_ErrorNone;
981 }
982 break;
983 case OMX_IndexParamVideoPortFormat:
984 {
985 OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
986 OMX_U32 portIndex = portFormat->nPortIndex;
987 OMX_U32 index = portFormat->nIndex;
988 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
989 OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
990 OMX_U32 supportFormatNum = 0; /* supportFormatNum = N-1 */
991
992 ret = Exynos_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
993 if (ret != OMX_ErrorNone) {
994 goto EXIT;
995 }
996
997 if ((portIndex >= pExynosComponent->portParam.nPorts)) {
998 ret = OMX_ErrorBadPortIndex;
999 goto EXIT;
1000 }
1001
1002
1003 if (portIndex == INPUT_PORT_INDEX) {
1004 supportFormatNum = INPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1;
1005 if (index > supportFormatNum) {
1006 ret = OMX_ErrorNoMore;
1007 goto EXIT;
1008 }
1009
1010 pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1011 portDefinition = &pExynosPort->portDefinition;
1012
1013 portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat;
1014 portFormat->eColorFormat = portDefinition->format.video.eColorFormat;
1015 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1016 } else if (portIndex == OUTPUT_PORT_INDEX) {
1017 pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1018 portDefinition = &pExynosPort->portDefinition;
1019
1020 switch (index) {
1021 case supportFormat_0:
1022 portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
1023 portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
1024 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1025 break;
1026 case supportFormat_1:
1027 portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
1028 portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
1029 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1030 break;
1031 case supportFormat_2:
1032 portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
1033 portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled;
1034 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1035 break;
1036 default:
1037 if (index > supportFormat_0) {
1038 ret = OMX_ErrorNoMore;
1039 goto EXIT;
1040 }
1041 break;
1042 }
1043 }
1044 ret = OMX_ErrorNone;
1045 }
1046 break;
1047 #ifdef USE_ANB
1048 case OMX_IndexParamGetAndroidNativeBuffer:
1049 {
1050 ret = Exynos_OSAL_GetANBParameter(hComponent, nParamIndex, ComponentParameterStructure);
1051 }
1052 break;
1053 case OMX_IndexParamPortDefinition:
1054 {
1055 OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
1056 OMX_U32 portIndex = portDefinition->nPortIndex;
1057 EXYNOS_OMX_BASEPORT *pExynosPort;
1058
1059 ret = Exynos_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
1060 if (ret != OMX_ErrorNone) {
1061 goto EXIT;
1062 }
1063
1064 /* at this point, GetParameter has done all the verification, we
1065 * just dereference things directly here
1066 */
1067 pExynosPort = &pExynosComponent->pExynosPort[portIndex];
1068 if (pExynosPort->bIsANBEnabled == OMX_TRUE) {
1069 portDefinition->format.video.eColorFormat =
1070 (OMX_COLOR_FORMATTYPE)Exynos_OSAL_OMX2HalPixelFormat(portDefinition->format.video.eColorFormat);
1071 }
1072 }
1073 break;
1074 #endif
1075 default:
1076 {
1077 ret = Exynos_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
1078 }
1079 break;
1080 }
1081
1082 EXIT:
1083 FunctionOut();
1084
1085 return ret;
1086 }
1087 OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter(
1088 OMX_IN OMX_HANDLETYPE hComponent,
1089 OMX_IN OMX_INDEXTYPE nIndex,
1090 OMX_IN OMX_PTR ComponentParameterStructure)
1091 {
1092 OMX_ERRORTYPE ret = OMX_ErrorNone;
1093 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1094 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1095 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
1096
1097 FunctionIn();
1098
1099 if (hComponent == NULL) {
1100 ret = OMX_ErrorBadParameter;
1101 goto EXIT;
1102 }
1103 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1104 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1105 if (ret != OMX_ErrorNone) {
1106 goto EXIT;
1107 }
1108
1109 if (pOMXComponent->pComponentPrivate == NULL) {
1110 ret = OMX_ErrorBadParameter;
1111 goto EXIT;
1112 }
1113 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1114
1115 if (pExynosComponent->currentState == OMX_StateInvalid ) {
1116 ret = OMX_ErrorInvalidState;
1117 goto EXIT;
1118 }
1119
1120 if (ComponentParameterStructure == NULL) {
1121 ret = OMX_ErrorBadParameter;
1122 goto EXIT;
1123 }
1124
1125 switch (nIndex) {
1126 case OMX_IndexParamVideoPortFormat:
1127 {
1128 OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
1129 OMX_U32 portIndex = portFormat->nPortIndex;
1130 OMX_U32 index = portFormat->nIndex;
1131 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
1132 OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
1133 OMX_U32 supportFormatNum = 0;
1134
1135 ret = Exynos_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
1136 if (ret != OMX_ErrorNone) {
1137 goto EXIT;
1138 }
1139
1140 if ((portIndex >= pExynosComponent->portParam.nPorts)) {
1141 ret = OMX_ErrorBadPortIndex;
1142 goto EXIT;
1143 } else {
1144 pExynosPort = &pExynosComponent->pExynosPort[portIndex];
1145 portDefinition = &pExynosPort->portDefinition;
1146
1147 portDefinition->format.video.eColorFormat = portFormat->eColorFormat;
1148 portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat;
1149 portDefinition->format.video.xFramerate = portFormat->xFramerate;
1150 }
1151 }
1152 break;
1153 case OMX_IndexParamPortDefinition:
1154 {
1155 OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
1156 OMX_U32 portIndex = pPortDefinition->nPortIndex;
1157 EXYNOS_OMX_BASEPORT *pExynosPort;
1158 OMX_U32 width, height, size;
1159 OMX_U32 realWidth, realHeight;
1160
1161 if (portIndex >= pExynosComponent->portParam.nPorts) {
1162 ret = OMX_ErrorBadPortIndex;
1163 goto EXIT;
1164 }
1165 ret = Exynos_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
1166 if (ret != OMX_ErrorNone) {
1167 goto EXIT;
1168 }
1169
1170 pExynosPort = &pExynosComponent->pExynosPort[portIndex];
1171
1172 if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) {
1173 if (pExynosPort->portDefinition.bEnabled == OMX_TRUE) {
1174 ret = OMX_ErrorIncorrectStateOperation;
1175 goto EXIT;
1176 }
1177 }
1178 if (pPortDefinition->nBufferCountActual < pExynosPort->portDefinition.nBufferCountMin) {
1179 ret = OMX_ErrorBadParameter;
1180 goto EXIT;
1181 }
1182
1183 Exynos_OSAL_Memcpy(&pExynosPort->portDefinition, pPortDefinition, pPortDefinition->nSize);
1184
1185 #ifdef USE_ANB // Modified by Google engineer
1186 /* should not affect the format since in ANB case, the caller
1187 * is providing us a HAL format */
1188 if (pExynosPort->bIsANBEnabled == OMX_TRUE) {
1189 pExynosPort->portDefinition.format.video.eColorFormat =
1190 Exynos_OSAL_Hal2OMXPixelFormat(pExynosPort->portDefinition.format.video.eColorFormat);
1191 }
1192 #endif
1193
1194 realWidth = pExynosPort->portDefinition.format.video.nFrameWidth;
1195 realHeight = pExynosPort->portDefinition.format.video.nFrameHeight;
1196 width = ((realWidth + 15) & (~15));
1197 height = ((realHeight + 15) & (~15));
1198 size = (width * height * 3) / 2;
1199 pExynosPort->portDefinition.format.video.nStride = width;
1200 pExynosPort->portDefinition.format.video.nSliceHeight = height;
1201 pExynosPort->portDefinition.nBufferSize = (size > pExynosPort->portDefinition.nBufferSize) ? size : pExynosPort->portDefinition.nBufferSize;
1202
1203 if (portIndex == INPUT_PORT_INDEX) {
1204 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1205 pExynosOutputPort->portDefinition.format.video.nFrameWidth = pExynosPort->portDefinition.format.video.nFrameWidth;
1206 pExynosOutputPort->portDefinition.format.video.nFrameHeight = pExynosPort->portDefinition.format.video.nFrameHeight;
1207 pExynosOutputPort->portDefinition.format.video.nStride = width;
1208 pExynosOutputPort->portDefinition.format.video.nSliceHeight = height;
1209
1210 switch (pExynosOutputPort->portDefinition.format.video.eColorFormat) {
1211 case OMX_COLOR_FormatYUV420Planar:
1212 case OMX_COLOR_FormatYUV420SemiPlanar:
1213 pExynosOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
1214 break;
1215 case OMX_SEC_COLOR_FormatNV12Tiled:
1216 pExynosOutputPort->portDefinition.nBufferSize =
1217 calc_plane(pExynosPort->portDefinition.format.video.nFrameWidth, pExynosOutputPort->portDefinition.format.video.nFrameHeight) +
1218 calc_plane(pExynosPort->portDefinition.format.video.nFrameWidth, pExynosOutputPort->portDefinition.format.video.nFrameHeight >> 1);
1219 break;
1220 default:
1221 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Color format is not support!! use default YUV size!!");
1222 ret = OMX_ErrorUnsupportedSetting;
1223 break;
1224 }
1225
1226 if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
1227 pExynosOutputPort->portDefinition.nBufferSize =
1228 calc_plane(pExynosPort->portDefinition.format.video.nFrameWidth, pExynosOutputPort->portDefinition.format.video.nFrameHeight) +
1229 calc_plane(pExynosPort->portDefinition.format.video.nFrameWidth, pExynosOutputPort->portDefinition.format.video.nFrameHeight >> 1);
1230 }
1231 }
1232 }
1233 break;
1234 #ifdef USE_ANB
1235 case OMX_IndexParamEnableAndroidBuffers:
1236 case OMX_IndexParamUseAndroidNativeBuffer:
1237 {
1238 ret = Exynos_OSAL_SetANBParameter(hComponent, nIndex, ComponentParameterStructure);
1239 }
1240 break;
1241 #endif
1242 default:
1243 {
1244 ret = Exynos_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
1245 }
1246 break;
1247 }
1248
1249 EXIT:
1250 FunctionOut();
1251
1252 return ret;
1253 }
1254
1255 OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetConfig(
1256 OMX_HANDLETYPE hComponent,
1257 OMX_INDEXTYPE nIndex,
1258 OMX_PTR pComponentConfigStructure)
1259 {
1260 OMX_ERRORTYPE ret = OMX_ErrorNone;
1261 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1262 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1263
1264 FunctionIn();
1265
1266 if (hComponent == NULL) {
1267 ret = OMX_ErrorBadParameter;
1268 goto EXIT;
1269 }
1270 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1271 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1272 if (ret != OMX_ErrorNone) {
1273 goto EXIT;
1274 }
1275 if (pOMXComponent->pComponentPrivate == NULL) {
1276 ret = OMX_ErrorBadParameter;
1277 goto EXIT;
1278 }
1279 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1280 if (pComponentConfigStructure == NULL) {
1281 ret = OMX_ErrorBadParameter;
1282 goto EXIT;
1283 }
1284 if (pExynosComponent->currentState == OMX_StateInvalid) {
1285 ret = OMX_ErrorInvalidState;
1286 goto EXIT;
1287 }
1288
1289 switch (nIndex) {
1290 default:
1291 ret = Exynos_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
1292 break;
1293 }
1294
1295 EXIT:
1296 FunctionOut();
1297
1298 return ret;
1299 }
1300
1301 OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetConfig(
1302 OMX_HANDLETYPE hComponent,
1303 OMX_INDEXTYPE nIndex,
1304 OMX_PTR pComponentConfigStructure)
1305 {
1306 OMX_ERRORTYPE ret = OMX_ErrorNone;
1307 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1308 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1309
1310 FunctionIn();
1311
1312 if (hComponent == NULL) {
1313 ret = OMX_ErrorBadParameter;
1314 goto EXIT;
1315 }
1316 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1317 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1318 if (ret != OMX_ErrorNone) {
1319 goto EXIT;
1320 }
1321 if (pOMXComponent->pComponentPrivate == NULL) {
1322 ret = OMX_ErrorBadParameter;
1323 goto EXIT;
1324 }
1325 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1326 if (pComponentConfigStructure == NULL) {
1327 ret = OMX_ErrorBadParameter;
1328 goto EXIT;
1329 }
1330 if (pExynosComponent->currentState == OMX_StateInvalid) {
1331 ret = OMX_ErrorInvalidState;
1332 goto EXIT;
1333 }
1334
1335 switch (nIndex) {
1336 case OMX_IndexVendorThumbnailMode:
1337 {
1338 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1339 pVideoDec->bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure);
1340
1341 ret = OMX_ErrorNone;
1342 }
1343 break;
1344 default:
1345 ret = Exynos_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
1346 break;
1347 }
1348
1349 EXIT:
1350 FunctionOut();
1351
1352 return ret;
1353 }
1354
1355 OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetExtensionIndex(
1356 OMX_IN OMX_HANDLETYPE hComponent,
1357 OMX_IN OMX_STRING cParameterName,
1358 OMX_OUT OMX_INDEXTYPE *pIndexType)
1359 {
1360 OMX_ERRORTYPE ret = OMX_ErrorNone;
1361 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1362 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1363
1364 FunctionIn();
1365
1366 if (hComponent == NULL) {
1367 ret = OMX_ErrorBadParameter;
1368 goto EXIT;
1369 }
1370 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1371 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1372 if (ret != OMX_ErrorNone) {
1373 goto EXIT;
1374 }
1375
1376 if (pOMXComponent->pComponentPrivate == NULL) {
1377 ret = OMX_ErrorBadParameter;
1378 goto EXIT;
1379 }
1380 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1381
1382 if ((cParameterName == NULL) || (pIndexType == NULL)) {
1383 ret = OMX_ErrorBadParameter;
1384 goto EXIT;
1385 }
1386 if (pExynosComponent->currentState == OMX_StateInvalid) {
1387 ret = OMX_ErrorInvalidState;
1388 goto EXIT;
1389 }
1390
1391 #ifdef USE_ANB
1392 if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_ANB) == 0)
1393 *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamEnableAndroidBuffers;
1394 else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_ANB) == 0)
1395 *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamGetAndroidNativeBuffer;
1396 else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_USE_ANB) == 0)
1397 *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamUseAndroidNativeBuffer;
1398 else
1399 ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
1400 #else
1401 ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
1402 #endif
1403
1404 EXIT:
1405 FunctionOut();
1406
1407 return ret;
1408 }
1409
1410 #ifdef USE_ANB
1411 OMX_ERRORTYPE Exynos_Shared_ANBBufferToData(EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_DATA *pData, EXYNOS_OMX_BASEPORT *pExynosPort, EXYNOS_OMX_PLANE nPlane)
1412 {
1413 OMX_ERRORTYPE ret = OMX_ErrorNone;
1414 OMX_U32 width, height;
1415 // void *pPhys[MAX_BUFFER_PLANE];
1416 ExynosVideoPlane planes[MAX_BUFFER_PLANE];
1417
1418 memset(planes, 0, sizeof(planes));
1419
1420 if (pExynosPort->bIsANBEnabled == OMX_TRUE) {
1421 OMX_U32 stride;
1422
1423 width = pExynosPort->portDefinition.format.video.nFrameWidth;
1424 height = pExynosPort->portDefinition.format.video.nFrameHeight;
1425 if ((pUseBuffer->bufferHeader != NULL) && (pUseBuffer->bufferHeader->pBuffer != NULL)) {
1426 Exynos_OSAL_LockANB(pUseBuffer->bufferHeader->pBuffer, width, height, pExynosPort->portDefinition.format.video.eColorFormat, &stride, planes);
1427 pUseBuffer->dataLen = sizeof(void *);
1428 } else {
1429 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
1430 ret = OMX_ErrorBadParameter;
1431 goto EXIT;
1432 }
1433 } else {
1434 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
1435 ret = OMX_ErrorBadParameter;
1436 goto EXIT;
1437 }
1438
1439 if (nPlane == TWO_PLANE) {
1440 /* Case of Shared Buffer, Only support two PlaneBuffer */
1441 pData->buffer.multiPlaneBuffer.dataBuffer[0] = planes[0].addr;
1442 pData->buffer.multiPlaneBuffer.dataBuffer[1] = planes[1].addr;
1443 #ifdef USE_DMA_BUF
1444 pData->buffer.multiPlaneBuffer.fd[0] = planes[0].fd;
1445 pData->buffer.multiPlaneBuffer.fd[1] = planes[1].fd;
1446 #endif
1447 } else {
1448 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not support plane");
1449 ret = OMX_ErrorNotImplemented;
1450 goto EXIT;
1451 }
1452
1453 pData->allocSize = pUseBuffer->allocSize;
1454 pData->dataLen = pUseBuffer->dataLen;
1455 pData->usedDataLen = pUseBuffer->usedDataLen;
1456 pData->remainDataLen = pUseBuffer->remainDataLen;
1457 pData->timeStamp = pUseBuffer->timeStamp;
1458 pData->nFlags = pUseBuffer->nFlags;
1459 pData->pPrivate = pUseBuffer->pPrivate;
1460 pData->bufferHeader = pUseBuffer->bufferHeader;
1461
1462 EXIT:
1463 return ret;
1464 }
1465
1466 OMX_ERRORTYPE Exynos_Shared_DataToANBBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_BASEPORT *pExynosPort)
1467 {
1468 OMX_ERRORTYPE ret = OMX_ErrorNone;
1469
1470 pUseBuffer->bufferHeader = pData->bufferHeader;
1471 pUseBuffer->allocSize = pData->allocSize;
1472 pUseBuffer->dataLen = pData->dataLen;
1473 pUseBuffer->usedDataLen = pData->usedDataLen;
1474 pUseBuffer->remainDataLen = pData->remainDataLen;
1475 pUseBuffer->timeStamp = pData->timeStamp;
1476 pUseBuffer->nFlags = pData->nFlags;
1477 pUseBuffer->pPrivate = pData->pPrivate;
1478
1479 if ((pUseBuffer->bufferHeader == NULL) ||
1480 (pUseBuffer->bufferHeader->pBuffer == NULL)) {
1481 ret = OMX_ErrorUndefined;
1482 goto EXIT;
1483 }
1484
1485 if (pExynosPort->bIsANBEnabled == OMX_TRUE) {
1486 Exynos_OSAL_UnlockANB(pUseBuffer->bufferHeader->pBuffer);
1487 } else {
1488 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
1489 ret = OMX_ErrorBadParameter;
1490 goto EXIT;
1491 }
1492
1493 EXIT:
1494 return ret;
1495 }
1496 #endif
1497
1498 OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer)
1499 {
1500 OMX_ERRORTYPE ret = OMX_ErrorNone;
1501
1502 pUseBuffer->bufferHeader = pData->bufferHeader;
1503 pUseBuffer->allocSize = pData->allocSize;
1504 pUseBuffer->dataLen = pData->dataLen;
1505 pUseBuffer->usedDataLen = pData->usedDataLen;
1506 pUseBuffer->remainDataLen = pData->remainDataLen;
1507 pUseBuffer->timeStamp = pData->timeStamp;
1508 pUseBuffer->nFlags = pData->nFlags;
1509 pUseBuffer->pPrivate = pData->pPrivate;
1510
1511 return ret;
1512 }