Changed sources for compiling
[platform/adaptation/ap_samsung/libomxil-e3250-v4l2.git] / openmax / component / video / dec / Exynos_OMX_Vdec.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_Vdec.c
20  * @brief
21  * @author      SeungBeom Kim (sbcrux.kim@samsung.com)
22  *              HyeYeon Chung (hyeon.chung@samsung.com)
23  *              Yunji Kim (yunji.kim@samsung.com)
24  * @version     2.0.0
25  * @history
26  *   2012.02.20 : Create
27  */
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <mm_types.h>
33 #include "Exynos_OMX_Macros.h"
34 #include "Exynos_OSAL_Event.h"
35 #include "Exynos_OMX_Vdec.h"
36 #include "Exynos_OMX_VdecControl.h"
37 #include "Exynos_OMX_Basecomponent.h"
38 #include "Exynos_OSAL_Thread.h"
39 #include "Exynos_OSAL_Semaphore.h"
40 #include "Exynos_OSAL_Mutex.h"
41 #include "Exynos_OSAL_ETC.h"
42
43 #ifdef USE_PB
44 #include "Exynos_OSAL_Platform_Specific.h"
45 #endif
46
47 #include "ExynosVideoApi.h"
48 #include "csc.h"
49
50 #undef  EXYNOS_LOG_TAG
51 #define EXYNOS_LOG_TAG    "EXYNOS_VIDEO_DEC"
52 #define EXYNOS_LOG_OFF
53 //#define EXYNOS_TRACE_ON
54 #include "Exynos_OSAL_Log.h"
55
56 int calc_plane(int width, int height)
57 {
58     int mbX, mbY;
59
60     mbX = ALIGN(width, S5P_FIMV_NV12MT_HALIGN);
61     mbY = ALIGN(height, S5P_FIMV_NV12MT_VALIGN);
62
63     return ALIGN(mbX * mbY, S5P_FIMV_DEC_BUF_ALIGN);
64 }
65
66 int calc_yplane(int width, int height)
67 {
68     int mbX, mbY;
69
70     mbX = ALIGN(width + 24, S5P_FIMV_NV12MT_HALIGN);
71     mbY = ALIGN(height + 16, S5P_FIMV_NV12MT_VALIGN);
72
73     return ALIGN(mbX * mbY, S5P_FIMV_DEC_BUF_ALIGN);
74 }
75
76 int calc_uvplane(int width, int height)
77 {
78     int mbX, mbY;
79
80     mbX = ALIGN(width + 16, S5P_FIMV_NV12MT_HALIGN);
81     mbY = ALIGN(height + 4, S5P_FIMV_NV12MT_VALIGN);
82
83     return ALIGN(mbX * mbY, S5P_FIMV_DEC_BUF_ALIGN);
84 }
85
86 inline void Exynos_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
87 {
88     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
89     EXYNOS_OMX_BASEPORT      *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
90     EXYNOS_OMX_BASEPORT      *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
91
92     if ((exynosOutputPort->portDefinition.format.video.nFrameWidth !=
93             exynosInputPort->portDefinition.format.video.nFrameWidth) ||
94         (exynosOutputPort->portDefinition.format.video.nFrameHeight !=
95             exynosInputPort->portDefinition.format.video.nFrameHeight)) {
96         OMX_U32 width = 0, height = 0;
97
98         exynosOutputPort->portDefinition.format.video.nFrameWidth =
99             exynosInputPort->portDefinition.format.video.nFrameWidth;
100         exynosOutputPort->portDefinition.format.video.nFrameHeight =
101             exynosInputPort->portDefinition.format.video.nFrameHeight;
102         width = exynosOutputPort->portDefinition.format.video.nStride =
103             exynosInputPort->portDefinition.format.video.nStride;
104         height = exynosOutputPort->portDefinition.format.video.nSliceHeight =
105             exynosInputPort->portDefinition.format.video.nSliceHeight;
106
107         switch(exynosOutputPort->portDefinition.format.video.eColorFormat) {
108         case OMX_COLOR_FormatYUV420Planar:
109         case OMX_COLOR_FormatYUV420SemiPlanar:
110             if (width && height)
111                 exynosOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
112             break;
113 #ifdef SLP_PLATFORM /* nv12t fd */
114         case OMX_SEC_COLOR_FormatNV12T_DmaBuf_Fd:
115             if (width && height)
116                 exynosOutputPort->portDefinition.nBufferSize = sizeof(MMVideoBuffer);
117             break;
118 #endif
119         case OMX_SEC_COLOR_FormatNV12Tiled:
120             width = exynosOutputPort->portDefinition.format.video.nFrameWidth;
121             height = exynosOutputPort->portDefinition.format.video.nFrameHeight;
122             if (width && height) {
123                 int YBufferSize = calc_plane(width, height);
124                 int CBufferSize = calc_plane(width, height >> 1);
125                 exynosOutputPort->portDefinition.nBufferSize = YBufferSize + CBufferSize;
126             }
127             break;
128         default:
129             if (width && height)
130                 exynosOutputPort->portDefinition.nBufferSize = width * height * 2;
131             break;
132         }
133     }
134
135     return;
136 }
137
138 OMX_BOOL Exynos_Check_BufferProcess_State(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 nPortIndex)
139 {
140     OMX_BOOL ret = OMX_FALSE;
141 #ifdef SLP_PLATFORM /* check state */
142     if (pExynosComponent->currentState != OMX_StateExecuting)
143         Exynos_OSAL_Log(EXYNOS_LOG_VERVOSE, "not OMX_StateExecuting");
144
145     if (pExynosComponent->pExynosPort[nPortIndex].portState != OMX_StateIdle)
146         Exynos_OSAL_Log(EXYNOS_LOG_VERVOSE, "not OMX_StateIdle");
147
148     if (pExynosComponent->transientState == EXYNOS_OMX_TransStateExecutingToIdle)
149         Exynos_OSAL_Log(EXYNOS_LOG_VERVOSE, "EXYNOS_OMX_TransStateExecutingToIdle");
150
151     if (pExynosComponent->transientState == EXYNOS_OMX_TransStateIdleToExecuting)
152         Exynos_OSAL_Log(EXYNOS_LOG_VERVOSE, "EXYNOS_OMX_TransStateIdleToExecuting");
153
154     if ((pExynosComponent->currentState == OMX_StateExecuting) &&
155         (pExynosComponent->pExynosPort[nPortIndex].portState == OMX_StateIdle) &&
156         (pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
157         (pExynosComponent->transientState != EXYNOS_OMX_TransStateIdleToExecuting)) {
158         ret = OMX_TRUE;
159 #else
160     if ((pExynosComponent->currentState == OMX_StateExecuting) &&
161         (pExynosComponent->pExynosPort[nPortIndex].portState == OMX_StateIdle) &&
162         (pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) &&
163         (pExynosComponent->transientState != EXYNOS_OMX_TransStateIdleToExecuting)) {
164         ret = OMX_TRUE;
165 #endif
166     } else {
167         ret = OMX_FALSE;
168     }
169
170     return ret;
171 }
172
173 OMX_ERRORTYPE Exynos_Input_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData)
174 {
175     OMX_ERRORTYPE                  ret = OMX_ErrorNone;
176     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
177     CODEC_DEC_BUFFER *pInputCodecBuffer = (CODEC_DEC_BUFFER *)codecBuffer;
178
179     pData->buffer.singlePlaneBuffer.dataBuffer = pInputCodecBuffer->pVirAddr[0];
180     pData->buffer.singlePlaneBuffer.fd = pInputCodecBuffer->fd[0];
181     pData->allocSize     = pInputCodecBuffer->bufferSize[0];
182     pData->dataLen       = pInputCodecBuffer->dataSize;
183     pData->usedDataLen   = 0;
184     pData->remainDataLen = pInputCodecBuffer->dataSize;
185
186     pData->nFlags        = 0;
187     pData->timeStamp     = 0;
188     pData->pPrivate      = codecBuffer;
189     pData->bufferHeader  = NULL;
190
191     return ret;
192 }
193
194 OMX_ERRORTYPE Exynos_Output_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData)
195 {
196     OMX_ERRORTYPE                  ret = OMX_ErrorNone;
197     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
198     OMX_PTR pSrcBuf[MAX_BUFFER_PLANE];
199     OMX_U32 allocSize[MAX_BUFFER_PLANE];
200
201     pVideoDec->exynos_codec_getCodecOutputPrivateData(codecBuffer, pSrcBuf, allocSize);
202     pData->buffer.multiPlaneBuffer.dataBuffer[0] = pSrcBuf[0];
203     pData->buffer.multiPlaneBuffer.dataBuffer[1] = pSrcBuf[1];
204     pData->buffer.multiPlaneBuffer.dataBuffer[2] = pSrcBuf[2];
205     pData->allocSize     = allocSize[0] + allocSize[1] + allocSize[2];
206     pData->dataLen       = 0;
207     pData->usedDataLen   = 0;
208     pData->remainDataLen = 0;
209
210     pData->nFlags        = 0;
211     pData->timeStamp     = 0;
212     pData->pPrivate      = codecBuffer;
213     pData->bufferHeader  = NULL;
214
215     return ret;
216 }
217
218 void Exynos_Wait_ProcessPause(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 nPortIndex)
219 {
220     EXYNOS_OMX_BASEPORT *exynosOMXInputPort  = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
221     EXYNOS_OMX_BASEPORT *exynosOMXOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
222     EXYNOS_OMX_BASEPORT *exynosOMXPort = NULL;
223
224     FunctionIn();
225
226     exynosOMXPort = &pExynosComponent->pExynosPort[nPortIndex];
227
228     if (((pExynosComponent->currentState == OMX_StatePause) ||
229         (pExynosComponent->currentState == OMX_StateIdle) ||
230         (pExynosComponent->transientState == EXYNOS_OMX_TransStateLoadedToIdle) ||
231         (pExynosComponent->transientState == EXYNOS_OMX_TransStateExecutingToIdle)) &&
232         (pExynosComponent->transientState != EXYNOS_OMX_TransStateIdleToLoaded) &&
233         (!CHECK_PORT_BEING_FLUSHED(exynosOMXPort))) {
234         Exynos_OSAL_SignalWait(pExynosComponent->pExynosPort[nPortIndex].pauseEvent, DEF_MAX_WAIT_TIME);
235         Exynos_OSAL_SignalReset(pExynosComponent->pExynosPort[nPortIndex].pauseEvent);
236     }
237
238     FunctionOut();
239
240     return;
241 }
242
243 OMX_BOOL Exynos_CSC_OutputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *dstOutputData)
244 {
245     OMX_BOOL                       ret              = OMX_FALSE;
246     EXYNOS_OMX_BASECOMPONENT      *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
247     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec        = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
248     EXYNOS_OMX_BASEPORT           *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
249     EXYNOS_OMX_BASEPORT           *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
250
251     EXYNOS_OMX_DATABUFFER         *outputUseBuffer  = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer;
252     OMX_U32                        copySize         = 0;
253     DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo      = NULL;
254 #ifdef SLP_PLATFORM
255     MMVideoBuffer *pSlpOutBuf = NULL;
256 #endif
257
258     FunctionIn();
259
260     OMX_U32 width = 0, height = 0;
261     int imageSize = 0;
262     OMX_COLOR_FORMATTYPE colorFormat;
263
264     void *pOutputBuf = (void *)outputUseBuffer->bufferHeader->pBuffer;
265     void *pSrcBuf[MAX_BUFFER_PLANE] = {NULL, };
266     void *pYUVBuf[MAX_BUFFER_PLANE] = {NULL, };
267
268     CSC_ERRORCODE cscRet = CSC_ErrorNone;
269     CSC_METHOD csc_method = CSC_METHOD_SW;
270     unsigned int cacheable = 1;
271
272     pBufferInfo = (DECODE_CODEC_EXTRA_BUFFERINFO *)dstOutputData->extInfo;
273
274     width = pBufferInfo->imageWidth;
275     height = pBufferInfo->imageHeight;
276     imageSize = width * height;
277     colorFormat = pBufferInfo->ColorFormat;
278
279 #ifdef SLP_PLATFORM
280     pSlpOutBuf = (MMVideoBuffer *)pOutputBuf;
281     pSlpOutBuf->width[0] = width;
282     pSlpOutBuf->width[1] = width;
283     pSlpOutBuf->height[0] = height;
284     pSlpOutBuf->height[1] = height/2;
285     pSlpOutBuf->stride_width[0] = width; /* need to check. stride */
286     pSlpOutBuf->stride_width[1] = width;
287     pSlpOutBuf->stride_height[0] = height; /* need to check. elevation */
288     pSlpOutBuf->stride_height[1] = height/2;
289
290     if (pVideoDec->bDRMPlayerMode == OMX_TRUE) {
291         pSlpOutBuf->data[0] = 0;
292         pSlpOutBuf->data[1] = 0;
293     } else {
294         pSlpOutBuf->data[0] = dstOutputData->buffer.multiPlaneBuffer.dataBuffer[0];
295         pSlpOutBuf->data[1] = dstOutputData->buffer.multiPlaneBuffer.dataBuffer[1];
296     }
297     pSlpOutBuf->data[2] = 0; /* omx do not use this plane */
298
299
300     pSlpOutBuf->handle.dmabuf_fd[0] = dstOutputData->buffer.multiPlaneBuffer.fd[0];
301     pSlpOutBuf->handle.dmabuf_fd[1] = dstOutputData->buffer.multiPlaneBuffer.fd[1];
302     pSlpOutBuf->handle.dmabuf_fd[2] = 0; /* omx do not use this plane */
303
304     //pSlpOutBuf->buf_share_method = MEMORY_DMABUF;
305     dstOutputData->dataLen = sizeof(MMVideoBuffer);
306
307     Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s: using fd instead of csc", __FUNCTION__);
308     Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "fd (%d, %d, %d) received from MFC", pSlpOutBuf->handle.dmabuf_fd[0], pSlpOutBuf->handle.dmabuf_fd[1],
309                     pSlpOutBuf->handle.dmabuf_fd[2]);
310
311     ret = OMX_TRUE;
312     goto EXIT;
313 #endif
314
315     pSrcBuf[0] = dstOutputData->buffer.multiPlaneBuffer.dataBuffer[0];
316     pSrcBuf[1] = dstOutputData->buffer.multiPlaneBuffer.dataBuffer[1];
317     pSrcBuf[2] = dstOutputData->buffer.multiPlaneBuffer.dataBuffer[2];
318
319     pYUVBuf[0]  = (unsigned char *)pOutputBuf;
320     pYUVBuf[1]  = (unsigned char *)pOutputBuf + imageSize;
321     pYUVBuf[2]  = (unsigned char *)pOutputBuf + imageSize + imageSize / 4;
322
323     csc_get_method(pVideoDec->csc_handle, &csc_method);
324 #ifdef USE_DMA_BUF
325     if (csc_method == CSC_METHOD_HW) {
326         pSrcBuf[0] = dstOutputData->buffer.multiPlaneBuffer.fd[0];
327         pSrcBuf[1] = dstOutputData->buffer.multiPlaneBuffer.fd[1];
328         pSrcBuf[2] = dstOutputData->buffer.multiPlaneBuffer.fd[2];
329     }
330 #endif
331
332 #ifdef USE_PB
333     if (exynosOutputPort->bIsPBEnabled == OMX_TRUE) {
334         ExynosVideoPlane planes[MAX_BUFFER_PLANE];
335         OMX_U32 stride;
336         Exynos_OSAL_LockPB(pOutputBuf, width, height, exynosOutputPort->portDefinition.format.video.eColorFormat, &stride, planes);
337         width = stride;
338         outputUseBuffer->dataLen = sizeof(void *);
339
340         pYUVBuf[0]  = (unsigned char *)planes[0].addr;
341         pYUVBuf[1]  = (unsigned char *)planes[1].addr;
342         pYUVBuf[2]  = (unsigned char *)planes[2].addr;
343 #ifdef USE_DMA_BUF
344         if (csc_method == CSC_METHOD_HW) {
345             pYUVBuf[0]  = (unsigned char *)planes[0].fd;
346             pYUVBuf[1]  = (unsigned char *)planes[1].fd;
347             pYUVBuf[2]  = (unsigned char *)planes[2].fd;
348         }
349 #endif
350     }
351 #endif
352 #ifdef USE_DMA_BUF
353     if ((exynosOutputPort->bIsPBEnabled == OMX_FALSE) &&
354         (csc_method == CSC_METHOD_HW)) {
355         pYUVBuf[0] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pOutputBuf);
356         pYUVBuf[1] = NULL;
357         pYUVBuf[2] = NULL;
358     }
359 #endif
360
361     if (pVideoDec->csc_set_format == OMX_FALSE) {
362         csc_set_src_format(
363             pVideoDec->csc_handle,  /* handle */
364             width,            /* width */
365             height,           /* height */
366             0,                /* crop_left */
367             0,                /* crop_right */
368             width,            /* crop_width */
369             height,           /* crop_height */
370             omx_2_hal_pixel_format(colorFormat), /* color_format */
371             cacheable);             /* cacheable */
372         csc_set_dst_format(
373             pVideoDec->csc_handle,  /* handle */
374             width,           /* width */
375             height,           /* height */
376             0,                /* crop_left */
377             0,                /* crop_right */
378             width,           /* crop_width */
379             height,           /* crop_height */
380             omx_2_hal_pixel_format(exynosOutputPort->portDefinition.format.video.eColorFormat), /* color_format */
381             cacheable);             /* cacheable */
382         pVideoDec->csc_set_format = OMX_TRUE;
383     }
384     csc_set_src_buffer(
385         pVideoDec->csc_handle,  /* handle */
386         pSrcBuf[0],             /* y addr */
387         pSrcBuf[1],             /* u addr or uv addr */
388         pSrcBuf[2],             /* v addr or none */
389         0);                     /* ion fd */
390     csc_set_dst_buffer(
391         pVideoDec->csc_handle,  /* handle */
392         pYUVBuf[0],             /* y addr */
393         pYUVBuf[1],             /* u addr or uv addr */
394         pYUVBuf[2],             /* v addr or none */
395         0);                     /* ion fd */
396     cscRet = csc_convert(pVideoDec->csc_handle);
397     if (cscRet != CSC_ErrorNone)
398         ret = OMX_FALSE;
399     else
400         ret = OMX_TRUE;
401
402 #ifdef USE_PB
403     if (exynosOutputPort->bIsPBEnabled == OMX_TRUE) {
404 #ifdef SLP_PLATFORM
405         Exynos_OSAL_UnlockPB(pOutputBuf, dstOutputData, exynosOutputPort, exynosInputPort);
406 #else
407         Exynos_OSAL_UnlockPB(pOutputBuf, dstOutputData);
408 #endif
409     }
410 #endif
411
412 EXIT:
413     FunctionOut();
414
415     return ret;
416 }
417
418 OMX_BOOL Exynos_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *srcInputData)
419 {
420     OMX_BOOL               ret = OMX_FALSE;
421     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
422     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
423     EXYNOS_OMX_BASEPORT      *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
424     EXYNOS_OMX_DATABUFFER    *inputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.inputDataBuffer;
425     OMX_U32                copySize = 0;
426     OMX_BYTE               checkInputStream = NULL;
427     OMX_U32                checkInputStreamLen = 0;
428
429     FunctionIn();
430
431     if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
432         if ((srcInputData->buffer.singlePlaneBuffer.dataBuffer == NULL) ||
433             (srcInputData->pPrivate == NULL)) {
434             ret = OMX_FALSE;
435             goto EXIT;
436         }
437     }
438
439     if (inputUseBuffer->dataValid == OMX_TRUE) {
440         if (exynosInputPort->bufferProcessType & BUFFER_SHARE) {
441             Exynos_Shared_BufferToData(inputUseBuffer, srcInputData, ONE_PLANE);
442
443 #ifndef SLP_PLATFORM
444             if (pVideoDec->bDRMPlayerMode == OMX_TRUE) {
445                 OMX_PTR dataBuffer = NULL;
446
447                 dataBuffer = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory,
448                                                             srcInputData->buffer.singlePlaneBuffer.dataBuffer);
449                 if (dataBuffer == NULL) {
450                     ret = OMX_FALSE;
451                     goto EXIT;
452                 }
453
454                 srcInputData->buffer.singlePlaneBuffer.dataBuffer = dataBuffer;
455             }
456 #endif
457             /* reset dataBuffer */
458             Exynos_ResetDataBuffer(inputUseBuffer);
459         } else if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
460             checkInputStream = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen;
461             checkInputStreamLen = inputUseBuffer->remainDataLen;
462
463             pExynosComponent->bUseFlagEOF = OMX_TRUE;
464
465             copySize = checkInputStreamLen;
466             Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "exynos_checkInputFrame : OMX_TRUE");
467
468             if (((srcInputData->allocSize) - (srcInputData->dataLen)) >= copySize) {
469                 if (copySize > 0) {
470                     Exynos_OSAL_Memcpy(srcInputData->buffer.singlePlaneBuffer.dataBuffer + srcInputData->dataLen,
471                                        checkInputStream, copySize);
472                 }
473
474                 inputUseBuffer->dataLen -= copySize;
475                 inputUseBuffer->remainDataLen -= copySize;
476                 inputUseBuffer->usedDataLen += copySize;
477
478                 srcInputData->dataLen += copySize;
479                 srcInputData->remainDataLen += copySize;
480
481                 srcInputData->timeStamp = inputUseBuffer->timeStamp;
482                 srcInputData->nFlags = inputUseBuffer->nFlags;
483                 srcInputData->bufferHeader = inputUseBuffer->bufferHeader;
484             } else {
485                 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "input codec buffer is smaller than decoded input data size Out Length");
486                 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
487                                                         pExynosComponent->callbackData,
488                                                         OMX_EventError, OMX_ErrorUndefined, 0, NULL);
489                 ret = OMX_FALSE;
490             }
491
492             Exynos_InputBufferReturn(pOMXComponent);
493         }
494
495         if ((srcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
496             Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "bSaveFlagEOS : OMX_TRUE");
497             srcInputData->dataLen = 0;
498             srcInputData->remainDataLen = 0;
499             pExynosComponent->bSaveFlagEOS = OMX_TRUE;
500         }
501
502         if (pExynosComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) {
503             pExynosComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE;
504             pExynosComponent->checkTimeStamp.startTimeStamp = srcInputData->timeStamp;
505             pExynosComponent->checkTimeStamp.nStartFlags = srcInputData->nFlags;
506             pExynosComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
507             Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "first frame timestamp after seeking %lld us (%.2f secs)",
508                             srcInputData->timeStamp, srcInputData->timeStamp / 1E6);
509         }
510
511         ret = OMX_TRUE;
512     }
513
514 EXIT:
515
516     FunctionOut();
517
518     return ret;
519 }
520
521 OMX_BOOL Exynos_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *dstOutputData)
522 {
523     OMX_BOOL                   ret = OMX_FALSE;
524     EXYNOS_OMX_BASECOMPONENT  *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
525     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
526     EXYNOS_OMX_BASEPORT       *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
527     EXYNOS_OMX_BASEPORT       *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; 
528     EXYNOS_OMX_DATABUFFER     *outputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer;
529     OMX_U32                    copySize = 0;
530     DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL;
531
532     FunctionIn();
533
534     if (exynosOutputPort->bufferProcessType & BUFFER_SHARE) {
535         if (exynosOutputPort->bIsPBEnabled == OMX_FALSE) {
536             if (Exynos_Shared_DataToBuffer(dstOutputData, outputUseBuffer) == OMX_ErrorNone)
537                 outputUseBuffer->dataValid = OMX_TRUE;
538         } else {
539 #ifdef USE_PB
540 #ifdef SLP_PLATFORM
541             if (Exynos_Shared_DataToPlatformBuffer(dstOutputData, outputUseBuffer, exynosOutputPort,exynosInputPort) == OMX_ErrorNone) {
542 #else
543             if (Exynos_Shared_DataToPlatformBuffer(dstOutputData, outputUseBuffer, exynosOutputPort) == OMX_ErrorNone) {
544 #endif
545                 outputUseBuffer->dataValid = OMX_TRUE;
546             } else {
547                 ret = OMX_FALSE;
548                 goto EXIT;
549             }
550 #else
551             Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s Should not come here", __FUNCTION__);
552             ret = OMX_FALSE;
553             goto EXIT;
554 #endif
555         }
556     }
557
558     if (outputUseBuffer->dataValid == OMX_TRUE) {
559         Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "out timestamp after seeking %lld us (%.2f secs)",
560             dstOutputData->timeStamp, dstOutputData->timeStamp / 1E6);
561         if ((pExynosComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) &&
562             ((dstOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
563             if ((pExynosComponent->checkTimeStamp.startTimeStamp == dstOutputData->timeStamp) &&
564                 (pExynosComponent->checkTimeStamp.nStartFlags == dstOutputData->nFlags)){
565                 pExynosComponent->checkTimeStamp.startTimeStamp = -19761123;
566                 pExynosComponent->checkTimeStamp.nStartFlags = 0x0;
567                 pExynosComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
568                 pExynosComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
569                 pExynosComponent->checkTimeStamp.bImmediateDisplay = OMX_FALSE; 
570             } else {
571                 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "drop frame after seeking", pExynosComponent);
572                 if (exynosOutputPort->bufferProcessType & BUFFER_SHARE)
573                     Exynos_OMX_FillThisBuffer(pOMXComponent, outputUseBuffer->bufferHeader);
574                 ret = OMX_TRUE;
575                 goto EXIT;
576             }
577         } else if ((pExynosComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE)) {
578             ret = OMX_TRUE;
579             Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "not set check timestame after seeking");
580             goto EXIT;
581         }
582
583         if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
584             OMX_U32 width = 0, height = 0;
585             int imageSize = 0;
586             void *pOutputBuf = (void *)outputUseBuffer->bufferHeader->pBuffer;
587
588             pBufferInfo = (DECODE_CODEC_EXTRA_BUFFERINFO *)dstOutputData->extInfo;
589
590             width = pBufferInfo->imageWidth;
591             height = pBufferInfo->imageHeight;
592             imageSize = width * height;
593
594             if ((dstOutputData->remainDataLen <= (outputUseBuffer->allocSize - outputUseBuffer->dataLen)) &&
595                 (!CHECK_PORT_BEING_FLUSHED(exynosOutputPort))) {
596                 copySize = dstOutputData->remainDataLen;
597                 Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"copySize: %d", copySize);
598
599                 outputUseBuffer->dataLen += copySize;
600                 outputUseBuffer->remainDataLen += copySize;
601                 outputUseBuffer->nFlags = dstOutputData->nFlags;
602                 outputUseBuffer->timeStamp = dstOutputData->timeStamp;
603
604                 if (outputUseBuffer->remainDataLen > 0) {
605                     ret = Exynos_CSC_OutputData(pOMXComponent, dstOutputData);
606                 } else {
607                     ret = OMX_TRUE;
608                 }
609
610                 if (ret == OMX_TRUE) {
611                     if ((outputUseBuffer->remainDataLen > 0) ||
612                         ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
613                         (CHECK_PORT_BEING_FLUSHED(exynosOutputPort))) {
614                         Exynos_OutputBufferReturn(pOMXComponent);
615                     }
616                 } else {
617                     Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "csc_convert Error");
618                     pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
619                                                             pExynosComponent->callbackData,
620                                                             OMX_EventError, OMX_ErrorUndefined, 0, NULL);
621                     ret = OMX_FALSE;
622                 }
623             } else if (CHECK_PORT_BEING_FLUSHED(exynosOutputPort)) {
624                 outputUseBuffer->dataLen = 0;
625                 outputUseBuffer->remainDataLen = 0;
626                 outputUseBuffer->nFlags = dstOutputData->nFlags;
627                 outputUseBuffer->timeStamp = dstOutputData->timeStamp;
628                 Exynos_OutputBufferReturn(pOMXComponent);
629             } else {
630 #ifdef SLP_PLATFORM
631                 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "output buffer is SCMN_IMGB type.");
632                 copySize = outputUseBuffer->allocSize - outputUseBuffer->dataLen;
633
634                 outputUseBuffer->dataLen += copySize;
635                 outputUseBuffer->remainDataLen += copySize;
636                 outputUseBuffer->nFlags = 0; /* need to check */
637                 outputUseBuffer->timeStamp = dstOutputData->timeStamp;
638
639                 if (outputUseBuffer->remainDataLen > 0) {
640                     ret = Exynos_CSC_OutputData(pOMXComponent, dstOutputData);
641                 } else {
642                     ret = OMX_TRUE;
643                 }
644
645                 dstOutputData->remainDataLen -= copySize; /* need to check */
646                 dstOutputData->usedDataLen += copySize;
647
648                 Exynos_OutputBufferReturn(pOMXComponent);
649 #else
650                 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "output buffer is smaller than decoded data size Out Length");
651                 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
652                                                         pExynosComponent->callbackData,
653                                                         OMX_EventError, OMX_ErrorUndefined, 0, NULL);
654                 ret = OMX_FALSE;
655 #endif
656             }
657         } else if (exynosOutputPort->bufferProcessType & BUFFER_SHARE) {
658             if ((outputUseBuffer->remainDataLen > 0) ||
659                 ((outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
660                 (CHECK_PORT_BEING_FLUSHED(exynosOutputPort)))
661                 Exynos_OutputBufferReturn(pOMXComponent);
662         }
663     } else {
664         ret = OMX_FALSE;
665     }
666
667 EXIT:
668     FunctionOut();
669
670     return ret;
671 }
672
673 OMX_ERRORTYPE Exynos_OMX_SrcInputBufferProcess(OMX_HANDLETYPE hComponent)
674 {
675     OMX_ERRORTYPE          ret = OMX_ErrorNone;
676     OMX_COMPONENTTYPE     *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
677     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
678     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
679     EXYNOS_OMX_BASEPORT      *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
680     EXYNOS_OMX_BASEPORT      *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
681     EXYNOS_OMX_DATABUFFER    *srcInputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.inputDataBuffer;
682     EXYNOS_OMX_DATA          *pSrcInputData = &exynosInputPort->processData;
683     OMX_BOOL               bCheckInputData = OMX_FALSE;
684     OMX_BOOL               bValidCodecData = OMX_FALSE;
685     OMX_BOOL               bCodecConfigured = OMX_FALSE;
686
687     FunctionIn();
688
689     while (!pVideoDec->bExitBufferProcessThread) {
690         Exynos_OSAL_SleepMillisec(0);
691         Exynos_Wait_ProcessPause(pExynosComponent, INPUT_PORT_INDEX);
692
693         while ((Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) &&
694                (!pVideoDec->bExitBufferProcessThread)) {
695             Exynos_OSAL_SleepMillisec(0);
696
697             if ((CHECK_PORT_BEING_FLUSHED(exynosInputPort)) ||
698                 ((exynosOutputPort->exceptionFlag == NEED_PORT_DISABLE) && (ret == OMX_ErrorInputDataDecodeYet)))
699                 break;
700             if (exynosInputPort->portState != OMX_StateIdle)
701                 break;
702
703             Exynos_OSAL_MutexLock(srcInputUseBuffer->bufferMutex);
704             if (ret != OMX_ErrorInputDataDecodeYet) {
705                 if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
706                     OMX_PTR codecBuffer;
707
708                     if ((pVideoDec->exynos_process_codecConfigData) && !bCodecConfigured) {
709                         EXYNOS_OMX_DATABUFFER *inputUseBuffer = NULL;
710                         ret = Exynos_InputBufferGetQueue(pExynosComponent);
711
712                         inputUseBuffer = &(exynosInputPort->way.port2WayDataBuffer.inputDataBuffer);
713                         pVideoDec->exynos_process_codecConfigData(pOMXComponent, inputUseBuffer); /* SLP_PLATFORM */
714 //                        pVideoDec->exynos_process_codecConfigData(pOMXComponent, pSrcInputData);
715
716                         bCodecConfigured = OMX_TRUE;
717                     }
718
719                     if ((pSrcInputData->buffer.singlePlaneBuffer.dataBuffer == NULL) || (pSrcInputData->pPrivate == NULL)) {
720                         Exynos_CodecBufferDeQueue(pExynosComponent, INPUT_PORT_INDEX, &codecBuffer);
721                         if (codecBuffer != NULL) {
722                             Exynos_Input_CodecBufferToData(pExynosComponent, codecBuffer, pSrcInputData);
723                         }
724                         Exynos_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
725                         break;
726                     }
727                 }
728
729                 if (srcInputUseBuffer->dataValid == OMX_TRUE) {
730                     bCheckInputData = Exynos_Preprocessor_InputData(pOMXComponent, pSrcInputData);
731                 } else {
732                     bCheckInputData = OMX_FALSE;
733                 }
734
735                 if ((bCheckInputData == OMX_FALSE) &&
736                     (!CHECK_PORT_BEING_FLUSHED(exynosInputPort))) {
737                     ret = Exynos_InputBufferGetQueue(pExynosComponent);
738                     Exynos_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
739                     break;
740                 }
741
742                 if (CHECK_PORT_BEING_FLUSHED(exynosInputPort)) {
743                     Exynos_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
744                     break;
745                 }
746             }
747
748             ret = pVideoDec->exynos_codec_srcInputProcess(pOMXComponent, pSrcInputData);
749
750                if (ret == OMX_ErrorCorruptedFrame) {
751                 if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
752                     OMX_PTR codecBuffer;
753                     codecBuffer = pSrcInputData->pPrivate;
754                     if (codecBuffer != NULL)
755                         Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, codecBuffer);
756                 }
757
758                 if (exynosInputPort->bufferProcessType & BUFFER_SHARE) {
759                     Exynos_OMX_InputBufferReturn(pOMXComponent, pSrcInputData->bufferHeader);
760                 }
761             }
762
763             if (ret != OMX_ErrorInputDataDecodeYet) {
764                 Exynos_ResetCodecData(pSrcInputData);
765             }
766             Exynos_OSAL_MutexUnlock(srcInputUseBuffer->bufferMutex);
767             if (ret == OMX_ErrorCodecInit)
768                 pVideoDec->bExitBufferProcessThread = OMX_TRUE;
769         }
770     }
771
772 EXIT:
773
774     FunctionOut();
775
776     return ret;
777 }
778
779 OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent)
780 {
781     OMX_ERRORTYPE          ret = OMX_ErrorNone;
782     OMX_COMPONENTTYPE     *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
783     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
784     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
785     EXYNOS_OMX_BASEPORT      *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
786     EXYNOS_OMX_DATABUFFER    *srcOutputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.outputDataBuffer;
787     EXYNOS_OMX_DATA           srcOutputData;
788
789     FunctionIn();
790
791     while (!pVideoDec->bExitBufferProcessThread) {
792         Exynos_OSAL_SleepMillisec(0);
793
794         while (!pVideoDec->bExitBufferProcessThread) {
795             if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
796                 if (Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX) == OMX_FALSE)
797                     break;
798             }
799             Exynos_OSAL_SleepMillisec(0);
800
801             if (CHECK_PORT_BEING_FLUSHED(exynosInputPort))
802                 break;
803
804             Exynos_OSAL_MutexLock(srcOutputUseBuffer->bufferMutex);
805             ret = pVideoDec->exynos_codec_srcOutputProcess(pOMXComponent, &srcOutputData);
806
807             if (ret == OMX_ErrorNone) {
808                 if (exynosInputPort->bufferProcessType & BUFFER_COPY) {
809                     OMX_PTR codecBuffer;
810                     codecBuffer = srcOutputData.pPrivate;
811                     if (codecBuffer != NULL)
812                         Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, codecBuffer);
813                 }
814                 if (exynosInputPort->bufferProcessType & BUFFER_SHARE) {
815                     Exynos_Shared_DataToBuffer(&srcOutputData, srcOutputUseBuffer);
816                     Exynos_InputBufferReturn(pOMXComponent);
817                 }
818                 Exynos_ResetCodecData(&srcOutputData);
819             }
820             Exynos_OSAL_MutexUnlock(srcOutputUseBuffer->bufferMutex);
821         }
822     }
823
824 EXIT:
825
826     FunctionOut();
827
828     return ret;
829 }
830
831 OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent)
832 {
833     OMX_ERRORTYPE          ret = OMX_ErrorNone;
834     OMX_COMPONENTTYPE     *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
835     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
836     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
837     EXYNOS_OMX_BASEPORT      *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
838     EXYNOS_OMX_DATABUFFER    *dstInputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.inputDataBuffer;
839     EXYNOS_OMX_DATA           dstInputData;
840
841     FunctionIn();
842
843     while (!pVideoDec->bExitBufferProcessThread) {
844         Exynos_OSAL_SleepMillisec(0);
845
846         while ((Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) &&
847                (!pVideoDec->bExitBufferProcessThread)) {
848             Exynos_OSAL_SleepMillisec(0);
849
850             if ((CHECK_PORT_BEING_FLUSHED(exynosOutputPort)) ||
851                 (!CHECK_PORT_POPULATED(exynosOutputPort)))
852                 break;
853             if (exynosOutputPort->portState != OMX_StateIdle)
854                 break;
855
856             Exynos_OSAL_MutexLock(dstInputUseBuffer->bufferMutex);
857             if (ret != OMX_ErrorOutputBufferUseYet) {
858                 if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
859                     OMX_PTR codecBuffer;
860                     ret = Exynos_CodecBufferDeQueue(pExynosComponent, OUTPUT_PORT_INDEX, &codecBuffer);
861                     if (ret != OMX_ErrorNone) {
862                         Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
863                         break;
864                     }
865                     Exynos_Output_CodecBufferToData(pExynosComponent, codecBuffer, &dstInputData);
866                 }
867
868                 if (exynosOutputPort->bufferProcessType & BUFFER_SHARE) {
869                     if ((dstInputUseBuffer->dataValid != OMX_TRUE) &&
870                         (!CHECK_PORT_BEING_FLUSHED(exynosOutputPort))) {
871                         ret = Exynos_OutputBufferGetQueue(pExynosComponent);
872                         if (ret != OMX_ErrorNone) {
873                             Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
874                             break;
875                         }
876                         if (exynosOutputPort->bIsPBEnabled == OMX_FALSE) {
877                             Exynos_Shared_BufferToData(dstInputUseBuffer, &dstInputData, TWO_PLANE);
878                         } else {
879 #ifdef USE_PB
880                             ret = Exynos_Shared_PlatformBufferToData(dstInputUseBuffer, &dstInputData, exynosOutputPort, TWO_PLANE);
881 #endif
882                             if (ret != OMX_ErrorNone) {
883                                 dstInputUseBuffer->dataValid = OMX_FALSE;
884                                 Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
885                                 break;
886                             }
887                         }
888                         Exynos_ResetDataBuffer(dstInputUseBuffer);
889                     }
890                 }
891
892                 if (CHECK_PORT_BEING_FLUSHED(exynosOutputPort)) {
893                     Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
894                     break;
895                 }
896             }
897
898             ret = pVideoDec->exynos_codec_dstInputProcess(pOMXComponent, &dstInputData);
899             if (ret != OMX_ErrorOutputBufferUseYet) {
900                 Exynos_ResetCodecData(&dstInputData);
901             }
902             Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
903         }
904     }
905
906 EXIT:
907
908     FunctionOut();
909
910     return ret;
911 }
912
913 OMX_ERRORTYPE Exynos_OMX_DstOutputBufferProcess(OMX_HANDLETYPE hComponent)
914 {
915     OMX_ERRORTYPE          ret = OMX_ErrorNone;
916     OMX_COMPONENTTYPE     *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
917     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
918     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
919     EXYNOS_OMX_BASEPORT      *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
920     EXYNOS_OMX_DATABUFFER    *dstOutputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer;
921     EXYNOS_OMX_DATA          *pDstOutputData = &exynosOutputPort->processData;
922
923     FunctionIn();
924
925     while (!pVideoDec->bExitBufferProcessThread) {
926         Exynos_OSAL_SleepMillisec(0);
927         Exynos_Wait_ProcessPause(pExynosComponent, OUTPUT_PORT_INDEX);
928
929         while ((Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) &&
930                (!pVideoDec->bExitBufferProcessThread)) {
931             Exynos_OSAL_SleepMillisec(0);
932
933             if (CHECK_PORT_BEING_FLUSHED(exynosOutputPort))
934                 break;
935
936             Exynos_OSAL_MutexLock(dstOutputUseBuffer->bufferMutex);
937             if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
938                 if ((dstOutputUseBuffer->dataValid != OMX_TRUE) &&
939                     (!CHECK_PORT_BEING_FLUSHED(exynosOutputPort))) {
940                     ret = Exynos_OutputBufferGetQueue(pExynosComponent);
941                     if (ret != OMX_ErrorNone) {
942                         Exynos_OSAL_MutexUnlock(dstOutputUseBuffer->bufferMutex);
943                         break;
944                     }
945                 }
946             }
947
948             if ((dstOutputUseBuffer->dataValid == OMX_TRUE) ||
949                 (exynosOutputPort->bufferProcessType & BUFFER_SHARE))
950                 ret = pVideoDec->exynos_codec_dstOutputProcess(pOMXComponent, pDstOutputData);
951
952             if (((ret == OMX_ErrorNone) && (dstOutputUseBuffer->dataValid == OMX_TRUE)) ||
953                 (exynosOutputPort->bufferProcessType & BUFFER_SHARE)) {
954                 Exynos_Postprocess_OutputData(pOMXComponent, pDstOutputData);
955             }
956
957             if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
958                 OMX_PTR codecBuffer;
959                 codecBuffer = pDstOutputData->pPrivate;
960                 if (codecBuffer != NULL) {
961                     Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, codecBuffer);
962                     pDstOutputData->pPrivate = NULL;
963                 }
964             }
965
966             /* reset outputData */
967             Exynos_ResetCodecData(pDstOutputData);
968             Exynos_OSAL_MutexUnlock(dstOutputUseBuffer->bufferMutex);
969         }
970     }
971
972 EXIT:
973
974     FunctionOut();
975
976     return ret;
977 }
978
979 static OMX_ERRORTYPE Exynos_OMX_SrcInputProcessThread(OMX_PTR threadData)
980 {
981     OMX_ERRORTYPE          ret = OMX_ErrorNone;
982     OMX_COMPONENTTYPE     *pOMXComponent = NULL;
983     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
984     EXYNOS_OMX_MESSAGE       *message = NULL;
985
986     FunctionIn();
987
988     if (threadData == NULL) {
989         ret = OMX_ErrorBadParameter;
990         goto EXIT;
991     }
992     pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
993     ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
994     if (ret != OMX_ErrorNone) {
995         goto EXIT;
996     }
997     pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
998     Exynos_OMX_SrcInputBufferProcess(pOMXComponent);
999
1000     Exynos_OSAL_ThreadExit(NULL);
1001
1002 EXIT:
1003     FunctionOut();
1004
1005     return ret;
1006 }
1007
1008 static OMX_ERRORTYPE Exynos_OMX_SrcOutputProcessThread(OMX_PTR threadData)
1009 {
1010     OMX_ERRORTYPE          ret = OMX_ErrorNone;
1011     OMX_COMPONENTTYPE     *pOMXComponent = NULL;
1012     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1013     EXYNOS_OMX_MESSAGE       *message = NULL;
1014
1015     FunctionIn();
1016
1017     if (threadData == NULL) {
1018         ret = OMX_ErrorBadParameter;
1019         goto EXIT;
1020     }
1021     pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
1022     ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1023     if (ret != OMX_ErrorNone) {
1024         goto EXIT;
1025     }
1026     pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1027     Exynos_OMX_SrcOutputBufferProcess(pOMXComponent);
1028
1029     Exynos_OSAL_ThreadExit(NULL);
1030
1031 EXIT:
1032     FunctionOut();
1033
1034     return ret;
1035 }
1036
1037 static OMX_ERRORTYPE Exynos_OMX_DstInputProcessThread(OMX_PTR threadData)
1038 {
1039     OMX_ERRORTYPE          ret = OMX_ErrorNone;
1040     OMX_COMPONENTTYPE     *pOMXComponent = NULL;
1041     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1042     EXYNOS_OMX_MESSAGE       *message = NULL;
1043
1044     FunctionIn();
1045
1046     if (threadData == NULL) {
1047         ret = OMX_ErrorBadParameter;
1048         goto EXIT;
1049     }
1050     pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
1051     ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1052     if (ret != OMX_ErrorNone) {
1053         goto EXIT;
1054     }
1055     pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1056     Exynos_OMX_DstInputBufferProcess(pOMXComponent);
1057
1058     Exynos_OSAL_ThreadExit(NULL);
1059
1060 EXIT:
1061     FunctionOut();
1062
1063     return ret;
1064 }
1065
1066 static OMX_ERRORTYPE Exynos_OMX_DstOutputProcessThread(OMX_PTR threadData)
1067 {
1068     OMX_ERRORTYPE          ret = OMX_ErrorNone;
1069     OMX_COMPONENTTYPE     *pOMXComponent = NULL;
1070     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1071     EXYNOS_OMX_MESSAGE       *message = NULL;
1072
1073     FunctionIn();
1074
1075     if (threadData == NULL) {
1076         ret = OMX_ErrorBadParameter;
1077         goto EXIT;
1078     }
1079     pOMXComponent = (OMX_COMPONENTTYPE *)threadData;
1080     ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1081     if (ret != OMX_ErrorNone) {
1082         goto EXIT;
1083     }
1084     pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1085     Exynos_OMX_DstOutputBufferProcess(pOMXComponent);
1086
1087     Exynos_OSAL_ThreadExit(NULL);
1088
1089 EXIT:
1090     FunctionOut();
1091
1092     return ret;
1093 }
1094
1095 OMX_ERRORTYPE Exynos_OMX_BufferProcess_Create(OMX_HANDLETYPE hComponent)
1096 {
1097     OMX_ERRORTYPE          ret = OMX_ErrorNone;
1098     OMX_COMPONENTTYPE     *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1099     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1100     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1101
1102     FunctionIn();
1103
1104     pVideoDec->bExitBufferProcessThread = OMX_FALSE;
1105
1106     ret = Exynos_OSAL_ThreadCreate(&pVideoDec->hDstOutputThread,
1107                  Exynos_OMX_DstOutputProcessThread,
1108                  pOMXComponent);
1109     if (ret == OMX_ErrorNone)
1110         ret = Exynos_OSAL_ThreadCreate(&pVideoDec->hSrcOutputThread,
1111                      Exynos_OMX_SrcOutputProcessThread,
1112                      pOMXComponent);
1113     if (ret == OMX_ErrorNone)
1114         ret = Exynos_OSAL_ThreadCreate(&pVideoDec->hDstInputThread,
1115                      Exynos_OMX_DstInputProcessThread,
1116                      pOMXComponent);
1117     if (ret == OMX_ErrorNone)
1118         ret = Exynos_OSAL_ThreadCreate(&pVideoDec->hSrcInputThread,
1119                      Exynos_OMX_SrcInputProcessThread,
1120                      pOMXComponent);
1121
1122 EXIT:
1123     FunctionOut();
1124
1125     return ret;
1126 }
1127
1128 OMX_ERRORTYPE Exynos_OMX_BufferProcess_Terminate(OMX_HANDLETYPE hComponent)
1129 {
1130     OMX_ERRORTYPE          ret = OMX_ErrorNone;
1131     OMX_COMPONENTTYPE     *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1132     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1133     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1134     OMX_S32                countValue = 0;
1135     unsigned int           i = 0;
1136
1137     FunctionIn();
1138
1139     pVideoDec->bExitBufferProcessThread = OMX_TRUE;
1140
1141     Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].bufferSemID, &countValue);
1142     if (countValue == 0)
1143         Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].bufferSemID);
1144     Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].codecSemID, &countValue);
1145     if (countValue == 0)
1146         Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].codecSemID);
1147     Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].pauseEvent);
1148     Exynos_OSAL_ThreadTerminate(pVideoDec->hSrcInputThread);
1149     pVideoDec->hSrcInputThread = NULL;
1150
1151     Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].bufferSemID, &countValue);
1152     if (countValue == 0)
1153         Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].bufferSemID);
1154     Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].codecSemID, &countValue);
1155     if (countValue == 0)
1156         Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].codecSemID);
1157     Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].pauseEvent);
1158     Exynos_OSAL_ThreadTerminate(pVideoDec->hDstInputThread);
1159     pVideoDec->hDstInputThread = NULL;
1160
1161     pVideoDec->exynos_codec_stop(pOMXComponent, INPUT_PORT_INDEX);
1162     pVideoDec->exynos_codec_bufferProcessRun(pOMXComponent, INPUT_PORT_INDEX);
1163     Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[INPUT_PORT_INDEX].pauseEvent);
1164     Exynos_OSAL_ThreadTerminate(pVideoDec->hSrcOutputThread);
1165     pVideoDec->hSrcOutputThread = NULL;
1166
1167     pVideoDec->exynos_codec_stop(pOMXComponent, OUTPUT_PORT_INDEX);
1168     pVideoDec->exynos_codec_bufferProcessRun(pOMXComponent, INPUT_PORT_INDEX);
1169     Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].pauseEvent);
1170     Exynos_OSAL_ThreadTerminate(pVideoDec->hDstOutputThread);
1171     pVideoDec->hDstOutputThread = NULL;
1172
1173 EXIT:
1174     FunctionOut();
1175
1176     return ret;
1177 }
1178
1179 OMX_ERRORTYPE Exynos_OMX_VideoDecodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent)
1180 {
1181     OMX_ERRORTYPE          ret = OMX_ErrorNone;
1182     OMX_COMPONENTTYPE     *pOMXComponent = NULL;
1183     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1184     EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;
1185     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
1186
1187     FunctionIn();
1188
1189     if (hComponent == NULL) {
1190         ret = OMX_ErrorBadParameter;
1191         goto EXIT;
1192     }
1193     pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1194     ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1195     if (ret != OMX_ErrorNone) {
1196         Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
1197         goto EXIT;
1198     }
1199
1200     ret = Exynos_OMX_BaseComponent_Constructor(pOMXComponent);
1201     if (ret != OMX_ErrorNone) {
1202         Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
1203         goto EXIT;
1204     }
1205
1206     ret = Exynos_OMX_Port_Constructor(pOMXComponent);
1207     if (ret != OMX_ErrorNone) {
1208         Exynos_OMX_BaseComponent_Destructor(pOMXComponent);
1209         Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
1210         goto EXIT;
1211     }
1212
1213     pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1214
1215     pVideoDec = Exynos_OSAL_Malloc(sizeof(EXYNOS_OMX_VIDEODEC_COMPONENT));
1216     if (pVideoDec == NULL) {
1217         Exynos_OMX_BaseComponent_Destructor(pOMXComponent);
1218         ret = OMX_ErrorInsufficientResources;
1219         Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
1220         goto EXIT;
1221     }
1222
1223     Exynos_OSAL_Memset(pVideoDec, 0, sizeof(EXYNOS_OMX_VIDEODEC_COMPONENT));
1224     pExynosComponent->hComponentHandle = (OMX_HANDLETYPE)pVideoDec;
1225
1226     pExynosComponent->bSaveFlagEOS = OMX_FALSE;
1227     pExynosComponent->bMultiThreadProcess = OMX_TRUE;
1228
1229     /* Input port */
1230     pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1231     pExynosPort->portDefinition.nBufferCountActual = MAX_VIDEO_INPUTBUFFER_NUM;
1232     pExynosPort->portDefinition.nBufferCountMin = MAX_VIDEO_INPUTBUFFER_NUM;
1233     pExynosPort->portDefinition.nBufferSize = 0;
1234     pExynosPort->portDefinition.eDomain = OMX_PortDomainVideo;
1235
1236     pExynosPort->portDefinition.format.video.cMIMEType = Exynos_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
1237     Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video");
1238     pExynosPort->portDefinition.format.video.pNativeRender = 0;
1239     pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
1240     pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
1241
1242     pExynosPort->portDefinition.format.video.nFrameWidth = 0;
1243     pExynosPort->portDefinition.format.video.nFrameHeight= 0;
1244     pExynosPort->portDefinition.format.video.nStride = 0;
1245     pExynosPort->portDefinition.format.video.nSliceHeight = 0;
1246     pExynosPort->portDefinition.format.video.nBitrate = 64000;
1247     pExynosPort->portDefinition.format.video.xFramerate = (15 << 16);
1248     pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
1249     pExynosPort->portDefinition.format.video.pNativeWindow = NULL;
1250
1251     /* Output port */
1252     pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1253     pExynosPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM;
1254     pExynosPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM;
1255     pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
1256     pExynosPort->portDefinition.eDomain = OMX_PortDomainVideo;
1257
1258     pExynosPort->portDefinition.format.video.cMIMEType = Exynos_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
1259     Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video");
1260     pExynosPort->portDefinition.format.video.pNativeRender = 0;
1261     pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
1262     pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
1263
1264     pExynosPort->portDefinition.format.video.nFrameWidth = 0;
1265     pExynosPort->portDefinition.format.video.nFrameHeight= 0;
1266     pExynosPort->portDefinition.format.video.nStride = 0;
1267     pExynosPort->portDefinition.format.video.nSliceHeight = 0;
1268     pExynosPort->portDefinition.format.video.nBitrate = 64000;
1269     pExynosPort->portDefinition.format.video.xFramerate = (15 << 16);
1270     pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
1271     pExynosPort->portDefinition.format.video.pNativeWindow = NULL;
1272
1273     pExynosPort->processData.extInfo = (OMX_PTR)Exynos_OSAL_Malloc(sizeof(DECODE_CODEC_EXTRA_BUFFERINFO));
1274
1275     pOMXComponent->UseBuffer              = &Exynos_OMX_UseBuffer;
1276     pOMXComponent->AllocateBuffer         = &Exynos_OMX_AllocateBuffer;
1277     pOMXComponent->FreeBuffer             = &Exynos_OMX_FreeBuffer;
1278     pOMXComponent->ComponentTunnelRequest = &Exynos_OMX_ComponentTunnelRequest;
1279
1280     pExynosComponent->exynos_AllocateTunnelBuffer = &Exynos_OMX_AllocateTunnelBuffer;
1281     pExynosComponent->exynos_FreeTunnelBuffer     = &Exynos_OMX_FreeTunnelBuffer;
1282     pExynosComponent->exynos_BufferProcessCreate    = &Exynos_OMX_BufferProcess_Create;
1283     pExynosComponent->exynos_BufferProcessTerminate = &Exynos_OMX_BufferProcess_Terminate;
1284     pExynosComponent->exynos_BufferFlush          = &Exynos_OMX_BufferFlush;
1285
1286 EXIT:
1287     FunctionOut();
1288
1289     return ret;
1290 }
1291
1292 OMX_ERRORTYPE Exynos_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent)
1293 {
1294     OMX_ERRORTYPE          ret = OMX_ErrorNone;
1295     OMX_COMPONENTTYPE     *pOMXComponent = NULL;
1296     EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1297     EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;
1298     EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
1299     int                    i = 0;
1300
1301     FunctionIn();
1302
1303     if (hComponent == NULL) {
1304         ret = OMX_ErrorBadParameter;
1305         goto EXIT;
1306     }
1307     pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1308     ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1309     if (ret != OMX_ErrorNone) {
1310         goto EXIT;
1311     }
1312
1313     if (pOMXComponent->pComponentPrivate == NULL) {
1314         ret = OMX_ErrorBadParameter;
1315         goto EXIT;
1316     }
1317     pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1318
1319     pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1320
1321     Exynos_OSAL_Free(pVideoDec);
1322     pExynosComponent->hComponentHandle = pVideoDec = NULL;
1323
1324     pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1325     if (pExynosPort->processData.extInfo != NULL) {
1326         Exynos_OSAL_Free(pExynosPort->processData.extInfo);
1327         pExynosPort->processData.extInfo = NULL;
1328     }
1329
1330     for(i = 0; i < ALL_PORT_NUM; i++) {
1331         pExynosPort = &pExynosComponent->pExynosPort[i];
1332         Exynos_OSAL_Free(pExynosPort->portDefinition.format.video.cMIMEType);
1333         pExynosPort->portDefinition.format.video.cMIMEType = NULL;
1334     }
1335
1336     ret = Exynos_OMX_Port_Destructor(pOMXComponent);
1337
1338     ret = Exynos_OMX_BaseComponent_Destructor(hComponent);
1339
1340 EXIT:
1341     FunctionOut();
1342
1343     return ret;
1344 }