3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file Exynos_OMX_VdecControl.c
21 * @author SeungBeom Kim (sbcrux.kim@samsung.com)
31 #include "Exynos_OMX_Macros.h"
32 #include "Exynos_OSAL_Event.h"
33 #include "Exynos_OMX_Vdec.h"
34 #include "Exynos_OMX_VdecControl.h"
35 #include "Exynos_OMX_Basecomponent.h"
36 #include "Exynos_OSAL_Thread.h"
37 #include "Exynos_OSAL_Semaphore.h"
38 #include "Exynos_OSAL_Mutex.h"
39 #include "Exynos_OSAL_ETC.h"
40 #include "Exynos_OSAL_SharedMemory.h"
41 #include "Exynos_OMX_Baseport.h"
44 #include "Exynos_OSAL_Platform_Specific.h"
47 #include "ExynosVideoApi.h"
50 #define EXYNOS_LOG_TAG "EXYNOS_VIDEO_DECCONTROL"
51 #define EXYNOS_LOG_OFF
52 //#define EXYNOS_TRACE_ON
53 #include "Exynos_OSAL_Log.h"
56 OMX_ERRORTYPE Exynos_OMX_UseBuffer(
57 OMX_IN OMX_HANDLETYPE hComponent,
58 OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
59 OMX_IN OMX_U32 nPortIndex,
60 OMX_IN OMX_PTR pAppPrivate,
61 OMX_IN OMX_U32 nSizeBytes,
62 OMX_IN OMX_U8 *pBuffer)
64 OMX_ERRORTYPE ret = OMX_ErrorNone;
65 OMX_COMPONENTTYPE *pOMXComponent = NULL;
66 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
67 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
68 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
69 OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
74 if (hComponent == NULL) {
75 ret = OMX_ErrorBadParameter;
78 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
79 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
80 if (ret != OMX_ErrorNone) {
84 if (pOMXComponent->pComponentPrivate == NULL) {
85 ret = OMX_ErrorBadParameter;
88 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
89 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
91 pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
92 if (nPortIndex >= pExynosComponent->portParam.nPorts) {
93 ret = OMX_ErrorBadPortIndex;
96 if (pExynosPort->portState != OMX_StateIdle) {
97 ret = OMX_ErrorIncorrectStateOperation;
101 if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) {
102 ret = OMX_ErrorBadPortIndex;
106 temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
107 if (temp_bufferHeader == NULL) {
108 ret = OMX_ErrorInsufficientResources;
111 Exynos_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
113 for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) {
114 if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
115 pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
116 pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
117 INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
118 temp_bufferHeader->pBuffer = pBuffer;
119 temp_bufferHeader->nAllocLen = nSizeBytes;
120 temp_bufferHeader->pAppPrivate = pAppPrivate;
121 if (nPortIndex == INPUT_PORT_INDEX)
122 temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
124 temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
125 #ifdef TIZEN_FEATURE_E3250
126 if (nPortIndex == OUTPUT_PORT_INDEX) {
127 MMVideoBuffer * pSlpOutBuf = (MMVideoBuffer *)pBuffer;
129 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "fd[0] =%d, fd[1] =%d, vaddr[0] =%p, vaddr[1] = %p, y_size=%d, uv_size=%d\n",
130 pSlpOutBuf->handle.dmabuf_fd[0], pSlpOutBuf->handle.dmabuf_fd[1], pSlpOutBuf->data[0], pSlpOutBuf->data[1],
131 pSlpOutBuf->size[0],pSlpOutBuf->size[1]);
133 pExynosPort->extendBufferHeader[i].buf_fd[0] = pSlpOutBuf->handle.dmabuf_fd[0];
134 pExynosPort->extendBufferHeader[i].buf_fd[1] = pSlpOutBuf->handle.dmabuf_fd[1];
135 pExynosPort->extendBufferHeader[i].buf_fd[2] = 0;
137 pExynosPort->extendBufferHeader[i].pYUVBuf[0] = pSlpOutBuf->data[0];
138 pExynosPort->extendBufferHeader[i].pYUVBuf[1] = pSlpOutBuf->data[1];
139 pExynosPort->extendBufferHeader[i].pYUVBuf[2] = NULL;
141 pExynosPort->extendBufferHeader[i].tbm_bo[0] = pSlpOutBuf->handle.bo[0];
142 pExynosPort->extendBufferHeader[i].tbm_bo[1] = pSlpOutBuf->handle.bo[1];
143 pExynosPort->extendBufferHeader[i].tbm_bo[2] = NULL;
145 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "\nPlatformBuffer: buf %d pYUVBuf[0]:0x%x , pYUVBuf[1]:0x%x ",
146 i, pExynosPort->extendBufferHeader[i].pYUVBuf[0], pExynosPort->extendBufferHeader[i].pYUVBuf[1]);
147 } else if ((pVideoDec->bDRMPlayerMode == OMX_TRUE) && (nPortIndex == INPUT_PORT_INDEX)) {
148 pExynosPort->extendBufferHeader[i].buf_fd[0] = (int)pBuffer;
149 } else if(nPortIndex == INPUT_PORT_INDEX){
150 MMVideoBuffer * pSlpOutBuf = (MMVideoBuffer *)pBuffer;
151 temp_bufferHeader->pBuffer = pSlpOutBuf->data[0];
153 pExynosPort->extendBufferHeader[i].buf_fd[0] = pBuffer;
154 SCMN_IMGB * pSlpOutBuf = (SCMN_IMGB *)pBuffer;
155 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "fd[0] =%d, vaddr[0] =%p, , length=%d",
156 pSlpOutBuf->fd[0], pSlpOutBuf->a[0], nSizeBytes);
158 pExynosPort->extendBufferHeader[i].buf_fd[0] = pSlpOutBuf->fd[0];
159 pExynosPort->extendBufferHeader[i].buf_fd[1] = 0;
160 pExynosPort->extendBufferHeader[i].buf_fd[2] = 0;
162 pExynosPort->extendBufferHeader[i].pYUVBuf[0] = pSlpOutBuf->a[0];
163 pExynosPort->extendBufferHeader[i].pYUVBuf[1] = NULL;
164 pExynosPort->extendBufferHeader[i].pYUVBuf[2] = NULL;
166 temp_bufferHeader->pBuffer = pSlpOutBuf->a[0];
170 *ppBufferHdr = temp_bufferHeader;
171 pExynosPort->assignedBufferNum++;
172 if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) {
173 pExynosPort->portDefinition.bPopulated = OMX_TRUE;
174 /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
175 Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource);
176 /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
183 Exynos_OSAL_Free(temp_bufferHeader);
184 ret = OMX_ErrorInsufficientResources;
192 OMX_ERRORTYPE Exynos_OMX_AllocateBuffer(
193 OMX_IN OMX_HANDLETYPE hComponent,
194 OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
195 OMX_IN OMX_U32 nPortIndex,
196 OMX_IN OMX_PTR pAppPrivate,
197 OMX_IN OMX_U32 nSizeBytes)
199 OMX_ERRORTYPE ret = OMX_ErrorNone;
200 OMX_COMPONENTTYPE *pOMXComponent = NULL;
201 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
202 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
203 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
204 OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
205 OMX_U8 *temp_buffer = NULL;
206 int temp_buffer_fd = -1;
208 MEMORY_TYPE mem_type;
212 if (hComponent == NULL) {
213 ret = OMX_ErrorBadParameter;
216 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
217 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
218 if (ret != OMX_ErrorNone) {
222 if (pOMXComponent->pComponentPrivate == NULL) {
223 ret = OMX_ErrorBadParameter;
226 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
227 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
229 pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
230 if (nPortIndex >= pExynosComponent->portParam.nPorts) {
231 ret = OMX_ErrorBadPortIndex;
235 if (pExynosPort->portState != OMX_StateIdle ) {
236 ret = OMX_ErrorIncorrectStateOperation;
240 if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) {
241 ret = OMX_ErrorBadPortIndex;
245 if ((pVideoDec->bDRMPlayerMode == OMX_TRUE) && (nPortIndex == INPUT_PORT_INDEX)) {
246 mem_type = SECURE_MEMORY;
247 } else if (pExynosPort->bufferProcessType & BUFFER_SHARE) {
248 mem_type = NORMAL_MEMORY;
250 mem_type = SYSTEM_MEMORY;
252 temp_buffer = Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nSizeBytes, mem_type);
253 if (temp_buffer == NULL) {
254 ret = OMX_ErrorInsufficientResources;
257 temp_buffer_fd = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, temp_buffer);
259 temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
260 if (temp_bufferHeader == NULL) {
261 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, temp_buffer);
262 ret = OMX_ErrorInsufficientResources;
265 Exynos_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
267 for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) {
268 if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
269 pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader;
270 pExynosPort->extendBufferHeader[i].buf_fd[0] = temp_buffer_fd;
271 pExynosPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED);
272 INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
273 if (mem_type == SECURE_MEMORY)
274 temp_bufferHeader->pBuffer = (OMX_U8 *)temp_buffer_fd;
276 temp_bufferHeader->pBuffer = temp_buffer;
277 temp_bufferHeader->nAllocLen = nSizeBytes;
278 temp_bufferHeader->pAppPrivate = pAppPrivate;
279 if (nPortIndex == INPUT_PORT_INDEX)
280 temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
282 temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
283 pExynosPort->assignedBufferNum++;
284 if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) {
285 pExynosPort->portDefinition.bPopulated = OMX_TRUE;
286 /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
287 Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource);
288 /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
290 *ppBuffer = temp_bufferHeader;
296 Exynos_OSAL_Free(temp_bufferHeader);
297 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, temp_buffer);
299 ret = OMX_ErrorInsufficientResources;
307 OMX_ERRORTYPE Exynos_OMX_FreeBuffer(
308 OMX_IN OMX_HANDLETYPE hComponent,
309 OMX_IN OMX_U32 nPortIndex,
310 OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr)
312 OMX_ERRORTYPE ret = OMX_ErrorNone;
313 OMX_COMPONENTTYPE *pOMXComponent = NULL;
314 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
315 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
316 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
321 if (hComponent == NULL) {
322 ret = OMX_ErrorBadParameter;
325 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
326 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
327 if (ret != OMX_ErrorNone) {
331 if (pOMXComponent->pComponentPrivate == NULL) {
332 ret = OMX_ErrorBadParameter;
335 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
336 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
337 pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
339 if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) {
340 ret = OMX_ErrorBadPortIndex;
344 if ((pExynosPort->portState != OMX_StateLoaded) && (pExynosPort->portState != OMX_StateInvalid)) {
345 (*(pExynosComponent->pCallbacks->EventHandler)) (pOMXComponent,
346 pExynosComponent->callbackData,
347 (OMX_U32)OMX_EventError,
348 (OMX_U32)OMX_ErrorPortUnpopulated,
352 for (i = 0; i < /*pExynosPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) {
353 if (((pExynosPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pExynosPort->extendBufferHeader[i].OMXBufferHeader != NULL)) {
354 if (pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer == pBufferHdr->pBuffer) {
355 if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) {
356 if ((pVideoDec->bDRMPlayerMode == OMX_TRUE) && (nPortIndex == INPUT_PORT_INDEX)) {
357 OMX_PTR mapBuffer = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory, (int)pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
358 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, mapBuffer);
360 Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer);
362 pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer = NULL;
363 pBufferHdr->pBuffer = NULL;
364 } else if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) {
367 pExynosPort->assignedBufferNum--;
368 if (pExynosPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) {
369 Exynos_OSAL_Free(pExynosPort->extendBufferHeader[i].OMXBufferHeader);
370 pExynosPort->extendBufferHeader[i].OMXBufferHeader = NULL;
373 pExynosPort->bufferStateAllocate[i] = BUFFER_STATE_FREE;
381 if (ret == OMX_ErrorNone) {
382 if (pExynosPort->assignedBufferNum == 0) {
383 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosPort->unloadedResource signal set");
384 /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */
385 Exynos_OSAL_SemaphorePost(pExynosPort->unloadedResource);
386 /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */
387 pExynosPort->portDefinition.bPopulated = OMX_FALSE;
396 OMX_ERRORTYPE Exynos_OMX_AllocateTunnelBuffer(EXYNOS_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
399 return OMX_ErrorTunnelingUnsupported;
402 OMX_ERRORTYPE Exynos_OMX_FreeTunnelBuffer(EXYNOS_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
404 return OMX_ErrorTunnelingUnsupported;
407 OMX_ERRORTYPE Exynos_OMX_ComponentTunnelRequest(
408 OMX_IN OMX_HANDLETYPE hComp,
409 OMX_IN OMX_U32 nPort,
410 OMX_IN OMX_HANDLETYPE hTunneledComp,
411 OMX_IN OMX_U32 nTunneledPort,
412 OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup)
414 return OMX_ErrorTunnelingUnsupported;
417 OMX_ERRORTYPE Exynos_OMX_GetFlushBuffer(EXYNOS_OMX_BASEPORT *pExynosPort, EXYNOS_OMX_DATABUFFER *pDataBuffer[])
419 OMX_ERRORTYPE ret = OMX_ErrorNone;
425 if (pExynosPort->portWayType == WAY1_PORT) {
426 *pDataBuffer = &pExynosPort->way.port1WayDataBuffer.dataBuffer;
427 } else if (pExynosPort->portWayType == WAY2_PORT) {
428 pDataBuffer[0] = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);
429 pDataBuffer[1] = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer);
437 OMX_ERRORTYPE Exynos_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex)
439 OMX_ERRORTYPE ret = OMX_ErrorNone;
440 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
441 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
442 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
443 OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
444 EXYNOS_OMX_DATABUFFER *pDataPortBuffer[2] = {NULL, NULL};
445 EXYNOS_OMX_MESSAGE *message = NULL;
446 OMX_S32 semValue = 0;
447 int i = 0, maxBufferNum = 0;
449 #ifdef TIZEN_FEATURE_E3250
450 Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "flushPort idx:%d", portIndex);
453 pExynosPort = &pExynosComponent->pExynosPort[portIndex];
455 while (Exynos_OSAL_GetElemNum(&pExynosPort->bufferQ) > 0) {
456 Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[portIndex].bufferSemID, &semValue);
458 Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[portIndex].bufferSemID);
460 Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[portIndex].bufferSemID);
461 message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
462 if ((message != NULL) && (message->messageType != EXYNOS_OMX_CommandFakeBuffer)) {
463 bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData;
464 bufferHeader->nFilledLen = 0;
466 if (portIndex == OUTPUT_PORT_INDEX) {
467 Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
468 } else if (portIndex == INPUT_PORT_INDEX) {
469 Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
472 Exynos_OSAL_Free(message);
476 Exynos_OMX_GetFlushBuffer(pExynosPort, pDataPortBuffer);
477 if (portIndex == INPUT_PORT_INDEX) {
478 if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
479 Exynos_FlushInputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
480 if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
481 Exynos_FlushInputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
482 } else if (portIndex == OUTPUT_PORT_INDEX) {
483 if (pDataPortBuffer[0]->dataValid == OMX_TRUE)
484 Exynos_FlushOutputBufferReturn(pOMXComponent, pDataPortBuffer[0]);
485 if (pDataPortBuffer[1]->dataValid == OMX_TRUE)
486 Exynos_FlushOutputBufferReturn(pOMXComponent, pDataPortBuffer[1]);
489 if (pExynosComponent->bMultiThreadProcess == OMX_TRUE) {
490 if (pExynosPort->bufferProcessType & BUFFER_SHARE) {
491 if (pExynosPort->processData.bufferHeader != NULL) {
492 if (portIndex == INPUT_PORT_INDEX) {
493 Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader);
494 } else if (portIndex == OUTPUT_PORT_INDEX) {
495 Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader);
498 Exynos_ResetCodecData(&pExynosPort->processData);
500 if (pVideoDec->bDRCProcessing == OMX_TRUE)
501 maxBufferNum = pVideoDec->nDRCSavedBufferCount;
503 maxBufferNum = pExynosPort->portDefinition.nBufferCountActual;
505 for (i = 0; i < maxBufferNum; i++) {
506 if (pExynosPort->extendBufferHeader[i].bBufferInOMX == OMX_TRUE) {
507 if (portIndex == OUTPUT_PORT_INDEX) {
508 Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader);
509 } else if (portIndex == INPUT_PORT_INDEX) {
510 Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader);
516 Exynos_ResetCodecData(&pExynosPort->processData);
521 Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[portIndex].bufferSemID, &cnt);
524 Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[portIndex].bufferSemID);
526 Exynos_OSAL_ResetQueue(&pExynosPort->bufferQ);
533 OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent)
535 OMX_ERRORTYPE ret = OMX_ErrorNone;
536 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
537 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
538 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
539 EXYNOS_OMX_DATABUFFER *flushPortBuffer[2] = {NULL, NULL};
543 #ifdef TIZEN_FEATURE_E3250
544 Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "bufferFlush idx:%d", nPortIndex);
547 if (pOMXComponent == NULL) {
548 ret = OMX_ErrorBadParameter;
551 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
552 if (ret != OMX_ErrorNone) {
556 if (pOMXComponent->pComponentPrivate == NULL) {
557 ret = OMX_ErrorBadParameter;
560 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
561 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
563 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush start, port:%d", nPortIndex);
565 pExynosComponent->pExynosPort[nPortIndex].bIsPortFlushed = OMX_TRUE;
567 if (pExynosComponent->bMultiThreadProcess == OMX_FALSE) {
568 Exynos_OSAL_SignalSet(pExynosComponent->pauseEvent);
570 Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[nPortIndex].pauseEvent);
573 pExynosPort = &pExynosComponent->pExynosPort[nPortIndex];
574 Exynos_OMX_GetFlushBuffer(pExynosPort, flushPortBuffer);
576 if (pExynosComponent->pExynosPort[nPortIndex].bufferProcessType & BUFFER_COPY)
577 Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID);
578 Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID);
580 pVideoDec->exynos_codec_bufferProcessRun(pOMXComponent, nPortIndex);
581 Exynos_OSAL_MutexLock(flushPortBuffer[0]->bufferMutex);
582 pVideoDec->exynos_codec_stop(pOMXComponent, nPortIndex);
583 Exynos_OSAL_MutexLock(flushPortBuffer[1]->bufferMutex);
584 ret = Exynos_OMX_FlushPort(pOMXComponent, nPortIndex);
586 if (pVideoDec->bDRCProcessing == OMX_TRUE) {
587 /* pVideoDec->bDRCProcess == OMX_TRUE
588 the case of dynamic resolution change */
589 pVideoDec->exynos_codec_resetupAllElement(pOMXComponent, nPortIndex);
590 } else if (pExynosComponent->pExynosPort[nPortIndex].bufferProcessType & BUFFER_COPY) {
591 pVideoDec->exynos_codec_enqueueAllBuffer(pOMXComponent, nPortIndex);
594 Exynos_ResetCodecData(&pExynosPort->processData);
596 if (ret == OMX_ErrorNone) {
597 if (nPortIndex == INPUT_PORT_INDEX) {
598 pExynosComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
599 pExynosComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
600 pExynosComponent->checkTimeStamp.bImmediateDisplay = OMX_FALSE;
601 Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
602 Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
603 pExynosComponent->getAllDelayBuffer = OMX_FALSE;
604 pExynosComponent->bSaveFlagEOS = OMX_FALSE;
605 pExynosComponent->reInputData = OMX_FALSE;
608 pExynosComponent->pExynosPort[nPortIndex].bIsPortFlushed = OMX_FALSE;
609 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush EventCmdComplete, port:%d", nPortIndex);
610 if (bEvent == OMX_TRUE)
611 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
612 pExynosComponent->callbackData,
613 OMX_EventCmdComplete,
614 OMX_CommandFlush, nPortIndex, NULL);
616 Exynos_OSAL_MutexUnlock(flushPortBuffer[1]->bufferMutex);
617 Exynos_OSAL_MutexUnlock(flushPortBuffer[0]->bufferMutex);
620 if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pExynosComponent != NULL)) {
621 Exynos_OSAL_Log(EXYNOS_LOG_ERROR,"%s : %d", __FUNCTION__, __LINE__);
622 pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
623 pExynosComponent->callbackData,
633 OMX_ERRORTYPE Exynos_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent)
635 OMX_ERRORTYPE ret = OMX_ErrorNone;
636 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
637 EXYNOS_OMX_BASEPORT *exynosOMXInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
638 EXYNOS_OMX_DATABUFFER *dataBuffer = NULL;
639 OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
643 if (exynosOMXInputPort->bufferProcessType & BUFFER_COPY) {
644 dataBuffer = &(exynosOMXInputPort->way.port2WayDataBuffer.inputDataBuffer);
645 } else if (exynosOMXInputPort->bufferProcessType & BUFFER_SHARE) {
646 dataBuffer = &(exynosOMXInputPort->way.port2WayDataBuffer.outputDataBuffer);
649 bufferHeader = dataBuffer->bufferHeader;
651 if (bufferHeader != NULL) {
652 if (exynosOMXInputPort->markType.hMarkTargetComponent != NULL ) {
653 bufferHeader->hMarkTargetComponent = exynosOMXInputPort->markType.hMarkTargetComponent;
654 bufferHeader->pMarkData = exynosOMXInputPort->markType.pMarkData;
655 exynosOMXInputPort->markType.hMarkTargetComponent = NULL;
656 exynosOMXInputPort->markType.pMarkData = NULL;
659 if (bufferHeader->hMarkTargetComponent != NULL) {
660 if (bufferHeader->hMarkTargetComponent == pOMXComponent) {
661 pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
662 pExynosComponent->callbackData,
664 0, 0, bufferHeader->pMarkData);
666 pExynosComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent;
667 pExynosComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData;
671 bufferHeader->nFilledLen = 0;
672 bufferHeader->nOffset = 0;
673 Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
676 /* reset dataBuffer */
677 Exynos_ResetDataBuffer(dataBuffer);
684 OMX_ERRORTYPE Exynos_FlushInputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer)
686 OMX_ERRORTYPE ret = OMX_ErrorNone;
687 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
688 EXYNOS_OMX_BASEPORT *exynosOMXInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
689 OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
693 bufferHeader = dataBuffer->bufferHeader;
695 if (bufferHeader != NULL) {
696 if (exynosOMXInputPort->markType.hMarkTargetComponent != NULL ) {
697 bufferHeader->hMarkTargetComponent = exynosOMXInputPort->markType.hMarkTargetComponent;
698 bufferHeader->pMarkData = exynosOMXInputPort->markType.pMarkData;
699 exynosOMXInputPort->markType.hMarkTargetComponent = NULL;
700 exynosOMXInputPort->markType.pMarkData = NULL;
703 if (bufferHeader->hMarkTargetComponent != NULL) {
704 if (bufferHeader->hMarkTargetComponent == pOMXComponent) {
705 pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
706 pExynosComponent->callbackData,
708 0, 0, bufferHeader->pMarkData);
710 pExynosComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent;
711 pExynosComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData;
715 bufferHeader->nFilledLen = 0;
716 bufferHeader->nOffset = 0;
717 Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader);
720 /* reset dataBuffer */
721 Exynos_ResetDataBuffer(dataBuffer);
728 OMX_ERRORTYPE Exynos_InputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
730 OMX_ERRORTYPE ret = OMX_ErrorUndefined;
731 EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
732 EXYNOS_OMX_MESSAGE *message = NULL;
733 EXYNOS_OMX_DATABUFFER *inputUseBuffer = NULL;
737 inputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);
739 if (pExynosComponent->currentState != OMX_StateExecuting) {
740 ret = OMX_ErrorUndefined;
742 } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
743 (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) {
744 Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);
745 if (inputUseBuffer->dataValid != OMX_TRUE) {
746 message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
747 if (message == NULL) {
748 ret = OMX_ErrorUndefined;
751 if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
752 Exynos_OSAL_Free(message);
753 ret = OMX_ErrorCodecFlush;
757 inputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
758 inputUseBuffer->allocSize = inputUseBuffer->bufferHeader->nAllocLen;
759 inputUseBuffer->dataLen = inputUseBuffer->bufferHeader->nFilledLen;
760 inputUseBuffer->remainDataLen = inputUseBuffer->dataLen;
761 inputUseBuffer->usedDataLen = 0;
762 inputUseBuffer->dataValid = OMX_TRUE;
763 inputUseBuffer->nFlags = inputUseBuffer->bufferHeader->nFlags;
764 inputUseBuffer->timeStamp = inputUseBuffer->bufferHeader->nTimeStamp;
766 Exynos_OSAL_Free(message);
768 #ifndef TIZEN_FEATURE_E3250
769 if (inputUseBuffer->allocSize <= inputUseBuffer->dataLen)
770 Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", inputUseBuffer->allocSize, inputUseBuffer->dataLen);
781 OMX_ERRORTYPE Exynos_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent)
783 OMX_ERRORTYPE ret = OMX_ErrorNone;
784 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
785 EXYNOS_OMX_BASEPORT *exynosOMXOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
786 EXYNOS_OMX_DATABUFFER *dataBuffer = NULL;
787 OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
791 dataBuffer = &(exynosOMXOutputPort->way.port2WayDataBuffer.outputDataBuffer);
792 bufferHeader = dataBuffer->bufferHeader;
794 if (bufferHeader != NULL) {
795 #ifdef TIZEN_FEATURE_E3250
796 bufferHeader->nFilledLen = sizeof(MMVideoBuffer);
798 bufferHeader->nFilledLen = dataBuffer->remainDataLen;
800 bufferHeader->nOffset = 0;
801 bufferHeader->nFlags = dataBuffer->nFlags;
802 bufferHeader->nTimeStamp = dataBuffer->timeStamp;
804 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"Exynos_OutputBufferReturn: nFilledLen: %d", bufferHeader->nFilledLen);
805 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"Exynos_OutputBufferReturn: nFlags: %d", bufferHeader->nFlags);
806 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"Exynos_OutputBufferReturn: nTimeStamp: %lld", bufferHeader->nTimeStamp);
808 if (pExynosComponent->propagateMarkType.hMarkTargetComponent != NULL) {
809 bufferHeader->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent;
810 bufferHeader->pMarkData = pExynosComponent->propagateMarkType.pMarkData;
811 pExynosComponent->propagateMarkType.hMarkTargetComponent = NULL;
812 pExynosComponent->propagateMarkType.pMarkData = NULL;
815 if ((bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
816 bufferHeader->nFilledLen = 0;
817 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"event OMX_BUFFERFLAG_EOS!!!");
818 pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
819 pExynosComponent->callbackData,
822 bufferHeader->nFlags, NULL);
825 Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
827 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d bufferHeader is NULL! ", __FUNCTION__, __LINE__);
830 /* reset dataBuffer */
831 Exynos_ResetDataBuffer(dataBuffer);
838 OMX_ERRORTYPE Exynos_FlushOutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer)
840 OMX_ERRORTYPE ret = OMX_ErrorNone;
841 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
842 OMX_BUFFERHEADERTYPE *bufferHeader = NULL;
846 bufferHeader = dataBuffer->bufferHeader;
848 if (bufferHeader != NULL) {
849 bufferHeader->nFilledLen = dataBuffer->remainDataLen;
850 bufferHeader->nOffset = 0;
851 bufferHeader->nFlags = dataBuffer->nFlags;
852 bufferHeader->nTimeStamp = dataBuffer->timeStamp;
854 if (pExynosComponent->propagateMarkType.hMarkTargetComponent != NULL) {
855 bufferHeader->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent;
856 bufferHeader->pMarkData = pExynosComponent->propagateMarkType.pMarkData;
857 pExynosComponent->propagateMarkType.hMarkTargetComponent = NULL;
858 pExynosComponent->propagateMarkType.pMarkData = NULL;
861 if ((bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
862 bufferHeader->nFilledLen = 0;
863 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"event OMX_BUFFERFLAG_EOS!!!");
864 pExynosComponent->pCallbacks->EventHandler(pOMXComponent,
865 pExynosComponent->callbackData,
868 bufferHeader->nFlags, NULL);
870 Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader);
873 /* reset dataBuffer */
874 Exynos_ResetDataBuffer(dataBuffer);
881 OMX_ERRORTYPE Exynos_OutputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
883 OMX_ERRORTYPE ret = OMX_ErrorUndefined;
884 EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
885 EXYNOS_OMX_MESSAGE *message = NULL;
886 EXYNOS_OMX_DATABUFFER *outputUseBuffer = NULL;
890 if (pExynosPort->bufferProcessType & BUFFER_COPY) {
891 outputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer);
892 } else if (pExynosPort->bufferProcessType & BUFFER_SHARE) {
893 outputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer);
896 if (pExynosComponent->currentState != OMX_StateExecuting) {
897 ret = OMX_ErrorUndefined;
899 } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
900 (!CHECK_PORT_BEING_FLUSHED(pExynosPort))){
901 Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);
902 if (outputUseBuffer->dataValid != OMX_TRUE) {
903 message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
904 if (message == NULL) {
905 ret = OMX_ErrorUndefined;
908 if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
909 Exynos_OSAL_Free(message);
910 ret = OMX_ErrorCodecFlush;
914 outputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
915 outputUseBuffer->allocSize = outputUseBuffer->bufferHeader->nAllocLen;
916 outputUseBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen;
917 outputUseBuffer->remainDataLen = outputUseBuffer->dataLen;
918 outputUseBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset;
919 outputUseBuffer->dataValid = OMX_TRUE;
920 /* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */
921 /* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */
923 if (pExynosPort->bufferProcessType & BUFFER_SHARE)
924 outputUseBuffer->pPrivate = outputUseBuffer->bufferHeader->pOutputPortPrivate;
925 else if (pExynosPort->bufferProcessType & BUFFER_COPY) {
926 pExynosPort->processData.dataBuffer = outputUseBuffer->bufferHeader->pBuffer;
927 pExynosPort->processData.allocSize = outputUseBuffer->bufferHeader->nAllocLen;
931 Exynos_OSAL_Free(message);
942 OMX_BUFFERHEADERTYPE *Exynos_OutputBufferGetQueue_Direct(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
944 OMX_BUFFERHEADERTYPE *retBuffer = NULL;
945 EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
946 EXYNOS_OMX_MESSAGE *message = NULL;
950 if (pExynosComponent->currentState != OMX_StateExecuting) {
953 } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
954 (!CHECK_PORT_BEING_FLUSHED(pExynosPort))){
955 Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID);
957 message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ);
958 if (message == NULL) {
962 if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) {
963 Exynos_OSAL_Free(message);
968 retBuffer = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
969 Exynos_OSAL_Free(message);
978 OMX_ERRORTYPE Exynos_CodecBufferEnQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex, OMX_PTR data)
980 OMX_ERRORTYPE ret = OMX_ErrorNone;
981 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
985 pExynosPort= &pExynosComponent->pExynosPort[PortIndex];
988 ret = OMX_ErrorInsufficientResources;
992 #ifdef TIZEN_FEATURE_E3250
993 if (pExynosPort == NULL) {
994 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d: pExynosPort is NULL", __FUNCTION__, __LINE__);
998 ret = Exynos_OSAL_Queue(&pExynosPort->codecBufferQ, (void *)data);
1000 ret = OMX_ErrorUndefined;
1003 Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID);
1005 ret = OMX_ErrorNone;
1013 OMX_ERRORTYPE Exynos_CodecBufferDeQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex, OMX_PTR *data)
1015 OMX_ERRORTYPE ret = OMX_ErrorNone;
1016 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
1021 pExynosPort = &pExynosComponent->pExynosPort[PortIndex];
1022 Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID);
1023 tempData = Exynos_OSAL_Dequeue(&pExynosPort->codecBufferQ);
1024 if (tempData == NULL) {
1026 ret = OMX_ErrorUndefined;
1029 *data = (OMX_PTR)tempData;
1031 ret = OMX_ErrorNone;
1039 OMX_ERRORTYPE Exynos_CodecBufferReset(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex)
1041 OMX_ERRORTYPE ret = OMX_ErrorNone;
1042 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
1046 pExynosPort= &pExynosComponent->pExynosPort[PortIndex];
1048 ret = Exynos_OSAL_ResetQueue(&pExynosPort->codecBufferQ);
1050 ret = OMX_ErrorUndefined;
1055 Exynos_OSAL_Get_SemaphoreCount(pExynosPort->codecSemID, &cnt);
1057 Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID);
1061 ret = OMX_ErrorNone;
1069 OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetParameter(
1070 OMX_IN OMX_HANDLETYPE hComponent,
1071 OMX_IN OMX_INDEXTYPE nParamIndex,
1072 OMX_INOUT OMX_PTR ComponentParameterStructure)
1074 OMX_ERRORTYPE ret = OMX_ErrorNone;
1075 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1076 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1080 if (hComponent == NULL) {
1081 ret = OMX_ErrorBadParameter;
1084 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1085 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1086 if (ret != OMX_ErrorNone) {
1090 if (pOMXComponent->pComponentPrivate == NULL) {
1091 ret = OMX_ErrorBadParameter;
1094 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1096 if (pExynosComponent->currentState == OMX_StateInvalid ) {
1097 ret = OMX_ErrorInvalidState;
1101 if (ComponentParameterStructure == NULL) {
1102 ret = OMX_ErrorBadParameter;
1106 switch (nParamIndex) {
1107 case OMX_IndexParamVideoInit:
1109 OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
1110 ret = Exynos_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE));
1111 if (ret != OMX_ErrorNone) {
1115 portParam->nPorts = pExynosComponent->portParam.nPorts;
1116 portParam->nStartPortNumber = pExynosComponent->portParam.nStartPortNumber;
1117 ret = OMX_ErrorNone;
1120 case OMX_IndexParamVideoPortFormat:
1122 OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
1123 OMX_U32 portIndex = portFormat->nPortIndex;
1124 OMX_U32 index = portFormat->nIndex;
1125 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
1126 OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
1127 OMX_U32 supportFormatNum = 0; /* supportFormatNum = N-1 */
1129 ret = Exynos_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
1130 if (ret != OMX_ErrorNone) {
1134 if ((portIndex >= pExynosComponent->portParam.nPorts)) {
1135 ret = OMX_ErrorBadPortIndex;
1140 if (portIndex == INPUT_PORT_INDEX) {
1141 supportFormatNum = INPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1;
1142 if (index > supportFormatNum) {
1143 ret = OMX_ErrorNoMore;
1147 pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1148 portDefinition = &pExynosPort->portDefinition;
1150 portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat;
1151 portFormat->eColorFormat = portDefinition->format.video.eColorFormat;
1152 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1153 } else if (portIndex == OUTPUT_PORT_INDEX) {
1154 pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1155 portDefinition = &pExynosPort->portDefinition;
1158 case supportFormat_0:
1159 portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
1160 portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
1161 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1163 case supportFormat_1:
1164 portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
1165 portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
1166 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1168 case supportFormat_2:
1169 portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
1170 portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12L_DmaBuf_Fd;
1171 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1173 #ifdef TIZEN_FEATURE_E3250
1174 case supportFormat_3:
1175 portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
1176 portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12T_DmaBuf_Fd;
1177 portFormat->xFramerate = portDefinition->format.video.xFramerate;
1181 if (index > supportFormat_0) {
1182 ret = OMX_ErrorNoMore;
1188 ret = OMX_ErrorNone;
1192 case OMX_IndexParamGetAndroidNativeBuffer:
1194 ret = Exynos_OSAL_GetPBParameter(hComponent, nParamIndex, ComponentParameterStructure);
1200 ret = Exynos_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
1210 OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter(
1211 OMX_IN OMX_HANDLETYPE hComponent,
1212 OMX_IN OMX_INDEXTYPE nIndex,
1213 OMX_IN OMX_PTR ComponentParameterStructure)
1215 OMX_ERRORTYPE ret = OMX_ErrorNone;
1216 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1217 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1221 if (hComponent == NULL) {
1222 ret = OMX_ErrorBadParameter;
1225 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1226 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1227 if (ret != OMX_ErrorNone) {
1231 if (pOMXComponent->pComponentPrivate == NULL) {
1232 ret = OMX_ErrorBadParameter;
1235 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1237 if (pExynosComponent->currentState == OMX_StateInvalid ) {
1238 ret = OMX_ErrorInvalidState;
1242 if (ComponentParameterStructure == NULL) {
1243 ret = OMX_ErrorBadParameter;
1248 case OMX_IndexParamVideoPortFormat:
1250 OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
1251 OMX_U32 portIndex = portFormat->nPortIndex;
1252 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
1253 OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
1255 ret = Exynos_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
1256 if (ret != OMX_ErrorNone) {
1260 if ((portIndex >= pExynosComponent->portParam.nPorts)) {
1261 ret = OMX_ErrorBadPortIndex;
1264 pExynosPort = &pExynosComponent->pExynosPort[portIndex];
1265 portDefinition = &pExynosPort->portDefinition;
1267 portDefinition->format.video.eColorFormat = portFormat->eColorFormat;
1268 portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat;
1269 portDefinition->format.video.xFramerate = portFormat->xFramerate;
1274 #ifdef TIZEN_FEATURE_E3250
1275 case OMX_IndexParamEnablePlatformSpecificBuffers:
1277 case OMX_IndexParamEnableAndroidBuffers:
1279 case OMX_IndexParamUseAndroidNativeBuffer:
1281 ret = Exynos_OSAL_SetPBParameter(hComponent, nIndex, ComponentParameterStructure);
1286 #ifdef TIZEN_FEATURE_E3250
1287 case OMX_IndexParamEnableTimestampReorder:
1289 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1290 pVideoDec->bNeedTimestampReorder = OMX_TRUE;
1296 ret = Exynos_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
1307 OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetConfig(
1308 OMX_HANDLETYPE hComponent,
1309 OMX_INDEXTYPE nIndex,
1310 OMX_PTR pComponentConfigStructure)
1312 OMX_ERRORTYPE ret = OMX_ErrorNone;
1313 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1314 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1318 if (hComponent == NULL) {
1319 ret = OMX_ErrorBadParameter;
1322 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1323 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1324 if (ret != OMX_ErrorNone) {
1327 if (pOMXComponent->pComponentPrivate == NULL) {
1328 ret = OMX_ErrorBadParameter;
1331 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1332 if (pComponentConfigStructure == NULL) {
1333 ret = OMX_ErrorBadParameter;
1336 if (pExynosComponent->currentState == OMX_StateInvalid) {
1337 ret = OMX_ErrorInvalidState;
1343 ret = Exynos_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
1353 OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetConfig(
1354 OMX_HANDLETYPE hComponent,
1355 OMX_INDEXTYPE nIndex,
1356 OMX_PTR pComponentConfigStructure)
1358 OMX_ERRORTYPE ret = OMX_ErrorNone;
1359 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1360 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1364 if (hComponent == NULL) {
1365 ret = OMX_ErrorBadParameter;
1368 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1369 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1370 if (ret != OMX_ErrorNone) {
1373 if (pOMXComponent->pComponentPrivate == NULL) {
1374 ret = OMX_ErrorBadParameter;
1377 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1378 if (pComponentConfigStructure == NULL) {
1379 ret = OMX_ErrorBadParameter;
1382 if (pExynosComponent->currentState == OMX_StateInvalid) {
1383 ret = OMX_ErrorInvalidState;
1388 case OMX_IndexVendorThumbnailMode:
1390 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1391 pVideoDec->bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure);
1393 ret = OMX_ErrorNone;
1397 ret = Exynos_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
1407 OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetExtensionIndex(
1408 OMX_IN OMX_HANDLETYPE hComponent,
1409 OMX_IN OMX_STRING cParameterName,
1410 OMX_OUT OMX_INDEXTYPE *pIndexType)
1412 OMX_ERRORTYPE ret = OMX_ErrorNone;
1413 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1414 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1418 if (hComponent == NULL) {
1419 ret = OMX_ErrorBadParameter;
1422 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1423 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1424 if (ret != OMX_ErrorNone) {
1428 if (pOMXComponent->pComponentPrivate == NULL) {
1429 ret = OMX_ErrorBadParameter;
1432 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1434 if ((cParameterName == NULL) || (pIndexType == NULL)) {
1435 ret = OMX_ErrorBadParameter;
1438 if (pExynosComponent->currentState == OMX_StateInvalid) {
1439 ret = OMX_ErrorInvalidState;
1444 #ifdef TIZEN_FEATURE_E3250
1445 if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_PB) == 0)
1446 *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamEnablePlatformSpecificBuffers;
1447 else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_TS_REORDER) == 0)
1448 *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamEnableTimestampReorder;
1450 if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_ANB) == 0)
1451 *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamEnableAndroidBuffers;
1453 else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_ANB) == 0)
1454 *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamGetAndroidNativeBuffer;
1455 else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_USE_ANB) == 0)
1456 *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamUseAndroidNativeBuffer;
1458 ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
1460 ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
1469 #ifdef USE_PB /* this is from FillThisBuffer */
1470 OMX_ERRORTYPE Exynos_Shared_PlatformBufferToData(EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_DATA *pData, EXYNOS_OMX_BASEPORT *pExynosPort, EXYNOS_OMX_PLANE nPlane)
1472 OMX_ERRORTYPE ret = OMX_ErrorNone;
1473 OMX_U32 width, height;
1474 // void *pPhys[MAX_BUFFER_PLANE];
1475 ExynosVideoPlane planes[MAX_BUFFER_PLANE];
1479 memset(planes, 0, sizeof(planes));
1481 if (pExynosPort->bIsPBEnabled == OMX_TRUE) {
1484 width = pExynosPort->portDefinition.format.video.nFrameWidth;
1485 height = pExynosPort->portDefinition.format.video.nFrameHeight;
1486 if ((pUseBuffer->bufferHeader != NULL) && (pUseBuffer->bufferHeader->pBuffer != NULL)) {
1487 Exynos_OSAL_LockPB(pUseBuffer->bufferHeader->pBuffer, width, height, pExynosPort->portDefinition.format.video.eColorFormat, &stride, planes);
1488 pUseBuffer->dataLen = sizeof(void *);
1490 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
1491 ret = OMX_ErrorBadParameter;
1495 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
1496 ret = OMX_ErrorBadParameter;
1500 if (nPlane == TWO_PLANE) {
1501 /* Case of Shared Buffer, Only support two PlaneBuffer */
1502 pData->buffer.multiPlaneBuffer.dataBuffer[0] = planes[0].addr;
1503 pData->buffer.multiPlaneBuffer.dataBuffer[1] = planes[1].addr;
1505 pData->buffer.multiPlaneBuffer.fd[0] = planes[0].fd;
1506 pData->buffer.multiPlaneBuffer.fd[1] = planes[1].fd;
1509 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not support plane");
1510 ret = OMX_ErrorNotImplemented;
1514 pData->allocSize = pUseBuffer->allocSize;
1515 pData->dataLen = pUseBuffer->dataLen;
1516 pData->usedDataLen = pUseBuffer->usedDataLen;
1517 pData->remainDataLen = pUseBuffer->remainDataLen;
1518 pData->timeStamp = pUseBuffer->timeStamp;
1519 pData->nFlags = pUseBuffer->nFlags;
1520 pData->pPrivate = pUseBuffer->pPrivate;
1521 pData->bufferHeader = pUseBuffer->bufferHeader;
1528 /* this is for Fill This Buffer Done */
1529 #ifdef TIZEN_FEATURE_E3250
1530 OMX_ERRORTYPE Exynos_Shared_DataToPlatformBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_BASEPORT *pExynosPort, EXYNOS_OMX_BASEPORT *pExynosInPort)
1532 OMX_ERRORTYPE Exynos_Shared_DataToPlatformBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_BASEPORT *pExynosPort)
1535 OMX_ERRORTYPE ret = OMX_ErrorNone;
1539 pUseBuffer->bufferHeader = pData->bufferHeader;
1540 pUseBuffer->allocSize = pData->allocSize;
1541 #ifdef TIZEN_FEATURE_E3250
1542 pUseBuffer->dataLen = sizeof(MMVideoBuffer);
1544 pUseBuffer->dataLen = pData->dataLen;
1546 pUseBuffer->usedDataLen = pData->usedDataLen;
1547 pUseBuffer->remainDataLen = pData->remainDataLen;
1548 pUseBuffer->timeStamp = pData->timeStamp;
1549 pUseBuffer->nFlags = pData->nFlags;
1550 pUseBuffer->pPrivate = pData->pPrivate;
1552 if ((pUseBuffer->bufferHeader == NULL) ||
1553 (pUseBuffer->bufferHeader->pBuffer == NULL)) {
1554 Exynos_OSAL_Log(EXYNOS_LOG_VERVOSE, "pUseBuffer->bufferHeader or pUseBuffer->bufferHeader->pBuffer is NULL");
1555 ret = OMX_ErrorUndefined;
1559 if (pExynosPort->bIsPBEnabled == OMX_TRUE) {
1560 #ifdef TIZEN_FEATURE_E3250
1561 Exynos_OSAL_UnlockPB(pUseBuffer->bufferHeader->pBuffer, pData, pExynosPort,pExynosInPort);
1563 Exynos_OSAL_UnlockPB(pUseBuffer->bufferHeader->pBuffer, pData);
1566 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
1567 ret = OMX_ErrorBadParameter;