b29dda5669a8be9d9edf9f53d083f80aa9161ec5
[GitHub/LineageOS/android_hardware_samsung_slsi_openmax.git] / component / video / dec / mpeg2 / Exynos_OMX_Mpeg2dec.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_Mpeg2dec.c
20 * @brief
21 * @author Satish Kumar Reddy (palli.satish@samsung.com)
22 * @version 2.0.0
23 * @history
24 * 2012.07.10 : Create
25 */
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30
31 #include "Exynos_OMX_Macros.h"
32 #include "Exynos_OMX_Basecomponent.h"
33 #include "Exynos_OMX_Baseport.h"
34 #include "Exynos_OMX_Vdec.h"
35 #include "Exynos_OSAL_ETC.h"
36 #include "Exynos_OSAL_Semaphore.h"
37 #include "Exynos_OSAL_Thread.h"
38 #include "library_register.h"
39 #include "Exynos_OMX_Mpeg2dec.h"
40 #include "ExynosVideoApi.h"
41 #include "Exynos_OSAL_SharedMemory.h"
42 #include "Exynos_OSAL_Event.h"
43
44 #ifdef USE_ANB
45 #include "Exynos_OSAL_Android.h"
46 #endif
47
48 /* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */
49 /* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
50 #include "csc.h"
51
52 #undef EXYNOS_LOG_TAG
53 #define EXYNOS_LOG_TAG "EXYNOS_MPEG2_DEC"
54 #define EXYNOS_LOG_OFF
55 //#define EXYNOS_TRACE_ON
56 #include "Exynos_OSAL_Log.h"
57
58 #define MPEG2_DEC_NUM_OF_EXTRA_BUFFERS 7
59
60 //#define FULL_FRAME_SEARCH /* Full frame search not support*/
61
62 static OMX_ERRORTYPE GetCodecInputPrivateData(OMX_PTR codecBuffer, void *pVirtAddr, OMX_U32 *dataSize)
63 {
64 OMX_ERRORTYPE ret = OMX_ErrorNone;
65
66 EXIT:
67 return ret;
68 }
69
70 static OMX_ERRORTYPE GetCodecOutputPrivateData(OMX_PTR codecBuffer, void *addr[], int size[])
71 {
72 OMX_ERRORTYPE ret = OMX_ErrorNone;
73 ExynosVideoBuffer *pCodecBuffer;
74
75 if (codecBuffer == NULL) {
76 ret = OMX_ErrorBadParameter;
77 goto EXIT;
78 }
79
80 pCodecBuffer = (ExynosVideoBuffer *)codecBuffer;
81
82 if (addr != NULL) {
83 addr[0] = pCodecBuffer->planes[0].addr;
84 addr[1] = pCodecBuffer->planes[1].addr;
85 addr[2] = pCodecBuffer->planes[2].addr;
86 }
87
88 if (size != NULL) {
89 size[0] = pCodecBuffer->planes[0].allocSize;
90 size[1] = pCodecBuffer->planes[1].allocSize;
91 size[2] = pCodecBuffer->planes[2].allocSize;
92 }
93
94 EXIT:
95 return ret;
96 }
97
98 int Check_Mpeg2_Frame(
99 OMX_U8 *pInputStream,
100 int buffSize,
101 OMX_U32 flag,
102 OMX_BOOL bPreviousFrameEOF,
103 OMX_BOOL *pbEndOfFrame)
104 {
105 FunctionIn();
106
107 *pbEndOfFrame = OMX_TRUE;
108
109 /* Frame Start code*/
110 if (pInputStream[0] != 0x00 || pInputStream[1] != 0x00 || pInputStream[2]!=0x01) {
111 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mpeg2 Frame Start Code not Found");
112 *pbEndOfFrame = OMX_FALSE;
113 }
114
115 FunctionOut();
116 return buffSize;
117 }
118
119 static OMX_BOOL Check_Mpeg2_StartCode(
120 OMX_U8 *pInputStream,
121 OMX_U32 streamSize)
122 {
123 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "streamSize: %d",streamSize);
124
125 if (streamSize < 3) {
126 return OMX_FALSE;
127 }
128
129 /* Frame Start code*/
130 if (pInputStream[0] != 0x00 || pInputStream[1] != 0x00 || pInputStream[2]!=0x01) {
131 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mpeg2 Frame Start Code not Found");
132 return OMX_FALSE;
133 }
134
135 return OMX_TRUE;
136 }
137
138 OMX_ERRORTYPE Mpeg2CodecOpen(EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec)
139 {
140 OMX_ERRORTYPE ret = OMX_ErrorNone;
141 ExynosVideoDecOps *pDecOps = NULL;
142 ExynosVideoDecBufferOps *pInbufOps = NULL;
143 ExynosVideoDecBufferOps *pOutbufOps = NULL;
144
145 FunctionIn();
146
147 if (pMpeg2Dec == NULL) {
148 ret = OMX_ErrorBadParameter;
149 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
150 goto EXIT;
151 }
152
153 /* alloc ops structure */
154 pDecOps = (ExynosVideoDecOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecOps));
155 pInbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecBufferOps));
156 pOutbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecBufferOps));
157
158 if ((pDecOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
159 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate decoder ops buffer");
160 ret = OMX_ErrorInsufficientResources;
161 goto EXIT;
162 }
163
164 pMpeg2Dec->hMFCMpeg2Handle.pDecOps = pDecOps;
165 pMpeg2Dec->hMFCMpeg2Handle.pInbufOps = pInbufOps;
166 pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps = pOutbufOps;
167
168 /* function pointer mapping */
169 pDecOps->nSize = sizeof(ExynosVideoDecOps);
170 pInbufOps->nSize = sizeof(ExynosVideoDecBufferOps);
171 pOutbufOps->nSize = sizeof(ExynosVideoDecBufferOps);
172
173 Exynos_Video_Register_Decoder(pDecOps, pInbufOps, pOutbufOps);
174
175 /* check mandatory functions for decoder ops */
176 if ((pDecOps->Init == NULL) || (pDecOps->Finalize == NULL) ||
177 (pDecOps->Get_ActualBufferCount == NULL) || (pDecOps->Set_FrameTag == NULL) ||
178 (pDecOps->Get_FrameTag == NULL)) {
179 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
180 ret = OMX_ErrorInsufficientResources;
181 goto EXIT;
182 }
183
184 /* check mandatory functions for buffer ops */
185 if ((pInbufOps->Setup == NULL) || (pOutbufOps->Setup == NULL) ||
186 (pInbufOps->Run == NULL) || (pOutbufOps->Run == NULL) ||
187 (pInbufOps->Stop == NULL) || (pOutbufOps->Stop == NULL) ||
188 (pInbufOps->Enqueue == NULL) || (pOutbufOps->Enqueue == NULL) ||
189 (pInbufOps->Dequeue == NULL) || (pOutbufOps->Dequeue == NULL)) {
190 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
191 ret = OMX_ErrorInsufficientResources;
192 goto EXIT;
193 }
194
195 /* alloc context, open, querycap */
196 #ifdef USE_DMA_BUF
197 pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.pDecOps->Init(V4L2_MEMORY_DMABUF);
198 #else
199 pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.pDecOps->Init(V4L2_MEMORY_USERPTR);
200 #endif
201 if (pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle == NULL) {
202 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer");
203 ret = OMX_ErrorInsufficientResources;
204 goto EXIT;
205 }
206
207 ret = OMX_ErrorNone;
208
209 EXIT:
210 if (ret != OMX_ErrorNone) {
211 if (pDecOps != NULL) {
212 Exynos_OSAL_Free(pDecOps);
213 pMpeg2Dec->hMFCMpeg2Handle.pDecOps = NULL;
214 }
215 if (pInbufOps != NULL) {
216 Exynos_OSAL_Free(pInbufOps);
217 pMpeg2Dec->hMFCMpeg2Handle.pInbufOps = NULL;
218 }
219 if (pOutbufOps != NULL) {
220 Exynos_OSAL_Free(pOutbufOps);
221 pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps = NULL;
222 }
223 }
224
225 FunctionOut();
226
227 return ret;
228 }
229
230 OMX_ERRORTYPE Mpeg2CodecClose(EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec)
231 {
232 OMX_ERRORTYPE ret = OMX_ErrorNone;
233 void *hMFCHandle = NULL;
234 ExynosVideoDecOps *pDecOps = NULL;
235 ExynosVideoDecBufferOps *pInbufOps = NULL;
236 ExynosVideoDecBufferOps *pOutbufOps = NULL;
237
238 FunctionIn();
239
240 if (pMpeg2Dec == NULL) {
241 ret = OMX_ErrorBadParameter;
242 goto EXIT;
243 }
244
245 hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
246 pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
247 pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
248 pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
249
250 if (hMFCHandle != NULL) {
251 pDecOps->Finalize(hMFCHandle);
252 pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle = NULL;
253 }
254 if (pOutbufOps != NULL) {
255 Exynos_OSAL_Free(pOutbufOps);
256 pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps = NULL;
257 }
258 if (pInbufOps != NULL) {
259 Exynos_OSAL_Free(pInbufOps);
260 pMpeg2Dec->hMFCMpeg2Handle.pInbufOps = NULL;
261 }
262 if (pDecOps != NULL) {
263 Exynos_OSAL_Free(pDecOps);
264 pMpeg2Dec->hMFCMpeg2Handle.pDecOps = NULL;
265 }
266
267 ret = OMX_ErrorNone;
268
269 EXIT:
270 FunctionOut();
271
272 return ret;
273 }
274
275 OMX_ERRORTYPE Mpeg2CodecStart(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
276 {
277 OMX_ERRORTYPE ret = OMX_ErrorNone;
278 void *hMFCHandle = NULL;
279 ExynosVideoDecOps *pDecOps = NULL;
280 ExynosVideoDecBufferOps *pInbufOps = NULL;
281 ExynosVideoDecBufferOps *pOutbufOps = NULL;
282 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
283 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
284
285 FunctionIn();
286
287 if (pOMXComponent == NULL) {
288 ret = OMX_ErrorBadParameter;
289 goto EXIT;
290 }
291
292 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle;
293 if (pVideoDec == NULL) {
294 ret = OMX_ErrorBadParameter;
295 goto EXIT;
296 }
297
298 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)pVideoDec->hCodecHandle;
299 if (pMpeg2Dec == NULL) {
300 ret = OMX_ErrorBadParameter;
301 goto EXIT;
302 }
303
304 hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
305 pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
306 pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
307 pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
308
309 if (nPortIndex == INPUT_PORT_INDEX)
310 pInbufOps->Run(hMFCHandle);
311 else if (nPortIndex == OUTPUT_PORT_INDEX)
312 pOutbufOps->Run(hMFCHandle);
313
314 ret = OMX_ErrorNone;
315
316 EXIT:
317 FunctionOut();
318
319 return ret;
320 }
321
322 OMX_ERRORTYPE Mpeg2CodecStop(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
323 {
324 OMX_ERRORTYPE ret = OMX_ErrorNone;
325 void *hMFCHandle = NULL;
326 ExynosVideoDecOps *pDecOps = NULL;
327 ExynosVideoDecBufferOps *pInbufOps = NULL;
328 ExynosVideoDecBufferOps *pOutbufOps = NULL;
329 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
330 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
331
332 FunctionIn();
333
334 if (pOMXComponent == NULL) {
335 ret = OMX_ErrorBadParameter;
336 goto EXIT;
337 }
338
339 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle;
340 if (pVideoDec == NULL) {
341 ret = OMX_ErrorBadParameter;
342 goto EXIT;
343 }
344 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)pVideoDec->hCodecHandle;
345 if (pMpeg2Dec == NULL) {
346 ret = OMX_ErrorBadParameter;
347 goto EXIT;
348 }
349
350 hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
351 pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
352 pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
353 pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
354
355 if ((nPortIndex == INPUT_PORT_INDEX) && (pInbufOps != NULL))
356 pInbufOps->Stop(hMFCHandle);
357 else if ((nPortIndex == OUTPUT_PORT_INDEX) && (pOutbufOps != NULL))
358 pOutbufOps->Stop(hMFCHandle);
359
360 ret = OMX_ErrorNone;
361
362 EXIT:
363 FunctionOut();
364
365 return ret;
366 }
367
368 OMX_ERRORTYPE Mpeg2CodecOutputBufferProcessRun(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
369 {
370 OMX_ERRORTYPE ret = OMX_ErrorNone;
371 void *hMFCHandle = NULL;
372 ExynosVideoDecOps *pDecOps = NULL;
373 ExynosVideoDecBufferOps *pInbufOps = NULL;
374 ExynosVideoDecBufferOps *pOutbufOps = NULL;
375 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
376 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
377
378 FunctionIn();
379
380 if (pOMXComponent == NULL) {
381 ret = OMX_ErrorBadParameter;
382 goto EXIT;
383 }
384
385 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle;
386 if (pVideoDec == NULL) {
387 ret = OMX_ErrorBadParameter;
388 goto EXIT;
389 }
390 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)pVideoDec->hCodecHandle;
391 if (pMpeg2Dec == NULL) {
392 ret = OMX_ErrorBadParameter;
393 goto EXIT;
394 }
395
396 hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
397 pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
398 pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
399 pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
400
401 if (nPortIndex == INPUT_PORT_INDEX) {
402 if (pMpeg2Dec->bSourceStart == OMX_FALSE) {
403 Exynos_OSAL_SignalSet(pMpeg2Dec->hSourceStartEvent);
404 Exynos_OSAL_SleepMillisec(0);
405 }
406 }
407
408 if (nPortIndex == OUTPUT_PORT_INDEX) {
409 if (pMpeg2Dec->bDestinationStart == OMX_FALSE) {
410 Exynos_OSAL_SignalSet(pMpeg2Dec->hDestinationStartEvent);
411 Exynos_OSAL_SleepMillisec(0);
412 }
413 }
414
415 ret = OMX_ErrorNone;
416
417 EXIT:
418 FunctionOut();
419
420 return ret;
421 }
422
423 OMX_ERRORTYPE Mpeg2CodecRegistCodecBuffers(
424 OMX_COMPONENTTYPE *pOMXComponent,
425 OMX_U32 nPortIndex,
426 OMX_U32 nBufferCnt)
427 {
428 OMX_ERRORTYPE ret = OMX_ErrorNone;
429 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
430 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
431 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
432 void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
433 CODEC_DEC_BUFFER **ppCodecBuffer = NULL;
434 ExynosVideoDecBufferOps *pBufOps = NULL;
435 ExynosVideoPlane *pPlanes = NULL;
436
437 OMX_U32 nPlaneCnt = 0;
438 int i, j;
439
440 FunctionIn();
441
442 if (nPortIndex == INPUT_PORT_INDEX) {
443 ppCodecBuffer = &(pVideoDec->pMFCDecInputBuffer[0]);
444 nPlaneCnt = MFC_INPUT_BUFFER_PLANE;
445 pBufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
446 } else {
447 ppCodecBuffer = &(pVideoDec->pMFCDecOutputBuffer[0]);
448 nPlaneCnt = MFC_OUTPUT_BUFFER_PLANE;
449 pBufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
450 }
451
452 pPlanes = (ExynosVideoPlane *)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane) * nPlaneCnt);
453 if (pPlanes == NULL) {
454 ret = OMX_ErrorInsufficientResources;
455 goto EXIT;
456 }
457
458 /* Register buffer */
459 for (i = 0; i < nBufferCnt; i++) {
460 for (j = 0; j < nPlaneCnt; j++) {
461 pPlanes[j].addr = ppCodecBuffer[i]->pVirAddr[j];
462 pPlanes[j].fd = ppCodecBuffer[i]->fd[j];
463 pPlanes[j].allocSize = ppCodecBuffer[i]->bufferSize[j];
464 }
465
466 if (pBufOps->Register(hMFCHandle, pPlanes, nPlaneCnt) != VIDEO_ERROR_NONE) {
467 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "PORT[%d]: Failed to Register buffer", nPortIndex);
468 ret = OMX_ErrorInsufficientResources;
469 Exynos_OSAL_Free(pPlanes);
470 goto EXIT;
471 }
472 }
473
474 Exynos_OSAL_Free(pPlanes);
475
476 ret = OMX_ErrorNone;
477
478 EXIT:
479 FunctionOut();
480
481 return ret;
482 }
483
484 OMX_ERRORTYPE Mpeg2CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex)
485 {
486 OMX_ERRORTYPE ret = OMX_ErrorNone;
487 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
488 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
489 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
490 void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
491 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
492 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
493 int i, nOutbufs;
494
495 ExynosVideoDecOps *pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
496 ExynosVideoDecBufferOps *pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
497 ExynosVideoDecBufferOps *pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
498
499 FunctionIn();
500
501 if ((nPortIndex != INPUT_PORT_INDEX) && (nPortIndex != OUTPUT_PORT_INDEX)) {
502 ret = OMX_ErrorBadPortIndex;
503 goto EXIT;
504 }
505
506 if ((nPortIndex == INPUT_PORT_INDEX) &&
507 (pMpeg2Dec->bSourceStart == OMX_TRUE)) {
508 Exynos_CodecBufferReset(pExynosComponent, INPUT_PORT_INDEX);
509
510 for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
511 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]);
512 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]);
513
514 Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
515 }
516
517 pInbufOps->Clear_Queue(hMFCHandle);
518 } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
519 (pMpeg2Dec->bDestinationStart == OMX_TRUE)) {
520 Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX);
521
522 for (i = 0; i < pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum; i++) {
523 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]);
524 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]);
525
526 Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoDec->pMFCDecOutputBuffer[i]);
527 }
528 pOutbufOps->Clear_Queue(hMFCHandle);
529 }
530
531 EXIT:
532 FunctionOut();
533
534 return ret;
535 }
536
537 OMX_ERRORTYPE Mpeg2CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData)
538 {
539 OMX_ERRORTYPE ret = OMX_ErrorNone;
540 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
541 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
542 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
543 void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
544 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
545 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
546 OMX_U32 oneFrameSize = pSrcInputData->dataLen;
547
548 ExynosVideoDecOps *pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
549 ExynosVideoDecBufferOps *pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
550 ExynosVideoDecBufferOps *pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
551 ExynosVideoGeometry bufferConf;
552 OMX_U32 inputBufferNumber = 0;
553 int i;
554
555 FunctionIn();
556
557 if ((oneFrameSize <= 0) && (pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
558 OMX_BUFFERHEADERTYPE *OMXBuffer = NULL;
559 OMXBuffer = Exynos_OutputBufferGetQueue_Direct(pExynosComponent);
560 if (OMXBuffer == NULL) {
561 ret = OMX_ErrorUndefined;
562 goto EXIT;
563 }
564
565 OMXBuffer->nTimeStamp = pSrcInputData->timeStamp;
566 OMXBuffer->nFlags = pSrcInputData->nFlags;
567 Exynos_OMX_OutputBufferReturn(pOMXComponent, OMXBuffer);
568
569 ret = OMX_ErrorNone;
570 goto EXIT;
571 }
572
573 if (pVideoDec->bThumbnailMode == OMX_TRUE)
574 pDecOps->Set_DisplayDelay(hMFCHandle, 0);
575
576 if ((pDecOps->Enable_DTSMode != NULL) &&
577 (pVideoDec->bDTSMode == OMX_TRUE))
578 pDecOps->Enable_DTSMode(hMFCHandle);
579
580 /* input buffer info */
581 Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
582 bufferConf.eCompressionFormat = VIDEO_CODING_MPEG2;
583 pInbufOps->Set_Shareable(hMFCHandle);
584 if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
585 bufferConf.nSizeImage = pExynosInputPort->portDefinition.format.video.nFrameWidth
586 * pExynosInputPort->portDefinition.format.video.nFrameHeight * 3 / 2;
587 inputBufferNumber = MAX_VIDEO_INPUTBUFFER_NUM;
588 } else if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
589 bufferConf.nSizeImage = DEFAULT_MFC_INPUT_BUFFER_SIZE;
590 inputBufferNumber = MFC_INPUT_BUFFER_NUM_MAX;
591 }
592
593 /* should be done before prepare input buffer */
594 if (pInbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
595 ret = OMX_ErrorInsufficientResources;
596 goto EXIT;
597 }
598
599 /* set input buffer geometry */
600 if (pInbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) {
601 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer");
602 ret = OMX_ErrorInsufficientResources;
603 goto EXIT;
604 }
605
606 /* setup input buffer */
607 if (pInbufOps->Setup(hMFCHandle, inputBufferNumber) != VIDEO_ERROR_NONE) {
608 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer");
609 ret = OMX_ErrorInsufficientResources;
610 goto EXIT;
611 }
612
613 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
614 ret = Mpeg2CodecRegistCodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX);
615 if (ret != OMX_ErrorNone)
616 goto EXIT;
617 } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
618 /* Register input buffer */
619 for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) {
620 ExynosVideoPlane plane;
621 plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer;
622 plane.allocSize = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->nAllocLen;
623 plane.fd = pExynosInputPort->extendBufferHeader[i].buf_fd[0];
624 if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
625 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "BUFFER_SHARE Failed to Register input buffer");
626 ret = OMX_ErrorInsufficientResources;
627 goto EXIT;
628 }
629 }
630 }
631
632 /* set output geometry */
633 Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
634 pMpeg2Dec->hMFCMpeg2Handle.MFCOutputColorType = bufferConf.eColorFormat = VIDEO_COLORFORMAT_NV12_TILED;
635 if (pOutbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) {
636 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for output buffer");
637 ret = OMX_ErrorInsufficientResources;
638 goto EXIT;
639 }
640
641 /* input buffer enqueue for header parsing */
642 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d", oneFrameSize);
643 if (pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer,
644 (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader) != VIDEO_ERROR_NONE) {
645 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue input buffer for header parsing");
646 // ret = OMX_ErrorInsufficientResources;
647 ret = (OMX_ERRORTYPE)OMX_ErrorCodecInit;
648 goto EXIT;
649 }
650
651 /* start header parsing */
652 if (pInbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) {
653 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run input buffer for header parsing");
654 ret = OMX_ErrorCodecInit;
655 goto EXIT;
656 }
657
658 /* get geometry for output */
659 Exynos_OSAL_Memset(&pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf, 0, sizeof(ExynosVideoGeometry));
660 if (pOutbufOps->Get_Geometry(hMFCHandle, &pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf) != VIDEO_ERROR_NONE) {
661 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get geometry for parsed header info");
662 ret = OMX_ErrorInsufficientResources;
663 goto EXIT;
664 }
665
666 /* get dpb count */
667 pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle);
668 if (pVideoDec->bThumbnailMode == OMX_FALSE)
669 pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum += EXTRA_DPB_NUM;
670 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Mpeg2CodecSetup nOutbufs: %d", pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum);
671
672 pMpeg2Dec->hMFCMpeg2Handle.bConfiguredMFCSrc = OMX_TRUE;
673
674 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
675 if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameWidth) ||
676 (pExynosInputPort->portDefinition.format.video.nFrameHeight != pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameHeight)) {
677 pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE;
678
679 pExynosInputPort->portDefinition.format.video.nFrameWidth = pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameWidth;
680 pExynosInputPort->portDefinition.format.video.nFrameHeight = pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameHeight;
681 pExynosInputPort->portDefinition.format.video.nStride = ((pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
682 pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
683
684 Exynos_UpdateFrameSize(pOMXComponent);
685
686 /** Send Port Settings changed call back **/
687 (*(pExynosComponent->pCallbacks->EventHandler))
688 (pOMXComponent,
689 pExynosComponent->callbackData,
690 OMX_EventPortSettingsChanged, /* The command was completed */
691 OMX_DirOutput, /* This is the port index */
692 0,
693 NULL);
694 }
695 } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
696 if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameWidth) ||
697 (pExynosInputPort->portDefinition.format.video.nFrameHeight != pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameHeight) ||
698 (pExynosOutputPort->portDefinition.nBufferCountActual != pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum)) {
699 pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE;
700
701 pExynosInputPort->portDefinition.format.video.nFrameWidth = pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameWidth;
702 pExynosInputPort->portDefinition.format.video.nFrameHeight = pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameHeight;
703 pExynosInputPort->portDefinition.format.video.nStride = ((pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
704 pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
705
706 pExynosOutputPort->portDefinition.nBufferCountActual = pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum - 2;
707 pExynosOutputPort->portDefinition.nBufferCountMin = pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum - 2;
708
709 Exynos_UpdateFrameSize(pOMXComponent);
710
711 /** Send Port Settings changed call back **/
712 (*(pExynosComponent->pCallbacks->EventHandler))
713 (pOMXComponent,
714 pExynosComponent->callbackData,
715 OMX_EventPortSettingsChanged, /* The command was completed */
716 OMX_DirOutput, /* This is the port index */
717 0,
718 NULL);
719 }
720 }
721 Exynos_OSAL_SleepMillisec(0);
722 ret = OMX_ErrorInputDataDecodeYet;
723 Mpeg2CodecStop(pOMXComponent, INPUT_PORT_INDEX);
724
725 EXIT:
726 FunctionOut();
727
728 return ret;
729 }
730
731 OMX_ERRORTYPE Mpeg2CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
732 {
733 OMX_ERRORTYPE ret = OMX_ErrorNone;
734 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
735 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
736 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
737 void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
738 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
739 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
740
741 ExynosVideoDecOps *pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
742 ExynosVideoDecBufferOps *pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
743 ExynosVideoDecBufferOps *pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
744
745 int i, nOutbufs;
746
747 OMX_U32 nAllocLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
748 OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
749
750 FunctionIn();
751
752 nAllocLen[0] = pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nAlignPlaneSize[0];
753 nAllocLen[1] = pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf.nAlignPlaneSize[1];
754
755 pOutbufOps->Set_Shareable(hMFCHandle);
756
757 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
758 /* should be done before prepare output buffer */
759 if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
760 ret = OMX_ErrorInsufficientResources;
761 goto EXIT;
762 }
763
764 /* get dpb count */
765 nOutbufs = pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum;
766 if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) {
767 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer");
768 ret = OMX_ErrorInsufficientResources;
769 goto EXIT;
770 }
771
772 ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs, nAllocLen);
773 if (ret != OMX_ErrorNone)
774 goto EXIT;
775
776 ret = Mpeg2CodecRegistCodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, nOutbufs);
777 if (ret != OMX_ErrorNone)
778 goto EXIT;
779
780 /* Enqueue output buffer */
781 for (i = 0; i < nOutbufs; i++) {
782 pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr,
783 (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
784 }
785
786 if (pOutbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) {
787 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run output buffer");
788 ret = OMX_ErrorInsufficientResources;
789 goto EXIT;
790 }
791 } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
792 ExynosVideoPlane planes[MFC_OUTPUT_BUFFER_PLANE];
793 int plane;
794
795 /* get dpb count */
796 nOutbufs = pExynosOutputPort->portDefinition.nBufferCountActual;
797 if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) {
798 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer");
799 ret = OMX_ErrorInsufficientResources;
800 goto EXIT;
801 }
802
803 /* Register output buffer */
804 /*************/
805 /* TBD */
806 /*************/
807 #ifdef USE_ANB
808 if (pExynosOutputPort->bIsANBEnabled == OMX_TRUE) {
809 for (i = 0; i < pExynosOutputPort->assignedBufferNum; i++) {
810 for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
811 planes[plane].fd = pExynosOutputPort->extendBufferHeader[i].buf_fd[plane];
812 planes[plane].addr = pExynosOutputPort->extendBufferHeader[i].pYUVBuf[plane];
813 planes[plane].allocSize = nAllocLen[plane];
814 }
815
816 if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) {
817 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer");
818 ret = OMX_ErrorInsufficientResources;
819 goto EXIT;
820 }
821 pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pExynosOutputPort->extendBufferHeader[i].pYUVBuf,
822 (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL);
823 }
824
825 if (pOutbufOps->Apply_RegisteredBuffer(hMFCHandle) != VIDEO_ERROR_NONE) {
826 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Apply output buffer");
827 ret = OMX_ErrorHardware;
828 goto EXIT;
829 }
830 } else {
831 ret = OMX_ErrorNotImplemented;
832 goto EXIT;
833 }
834 #else
835 ret = OMX_ErrorNotImplemented;
836 goto EXIT;
837 #endif
838 }
839
840 pMpeg2Dec->hMFCMpeg2Handle.bConfiguredMFCDst = OMX_TRUE;
841
842 ret = OMX_ErrorNone;
843
844 EXIT:
845 FunctionOut();
846
847 return ret;
848 }
849
850 OMX_ERRORTYPE Exynos_Mpeg2Dec_GetParameter(
851 OMX_IN OMX_HANDLETYPE hComponent,
852 OMX_IN OMX_INDEXTYPE nParamIndex,
853 OMX_INOUT OMX_PTR pComponentParameterStructure)
854 {
855 OMX_ERRORTYPE ret = OMX_ErrorNone;
856 OMX_COMPONENTTYPE *pOMXComponent = NULL;
857 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
858
859 FunctionIn();
860
861 if (hComponent == NULL || pComponentParameterStructure == NULL) {
862 ret = OMX_ErrorBadParameter;
863 goto EXIT;
864 }
865 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
866 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
867 if (ret != OMX_ErrorNone) {
868 goto EXIT;
869 }
870 if (pOMXComponent->pComponentPrivate == NULL) {
871 ret = OMX_ErrorBadParameter;
872 goto EXIT;
873 }
874
875 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
876 if (pExynosComponent->currentState == OMX_StateInvalid ) {
877 ret = OMX_ErrorInvalidState;
878 goto EXIT;
879 }
880
881 switch (nParamIndex) {
882 case OMX_IndexParamVideoMpeg2:
883 {
884 OMX_VIDEO_PARAM_MPEG2TYPE *pDstMpeg2Param = (OMX_VIDEO_PARAM_MPEG2TYPE *)pComponentParameterStructure;
885 OMX_VIDEO_PARAM_MPEG2TYPE *pSrcMpeg2Param = NULL;
886 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
887 ret = Exynos_OMX_Check_SizeVersion(pDstMpeg2Param, sizeof(OMX_VIDEO_PARAM_MPEG2TYPE));
888 if (ret != OMX_ErrorNone) {
889 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "1");
890 goto EXIT;
891 }
892
893 if (pDstMpeg2Param->nPortIndex > OUTPUT_PORT_INDEX) {
894 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "2");
895 ret = OMX_ErrorBadPortIndex;
896 }
897
898 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
899 pSrcMpeg2Param = &pMpeg2Dec->Mpeg2Component[pDstMpeg2Param->nPortIndex];
900
901 Exynos_OSAL_Memcpy(pDstMpeg2Param, pSrcMpeg2Param, sizeof(OMX_VIDEO_PARAM_MPEG2TYPE));
902 }
903 break;
904 case OMX_IndexParamStandardComponentRole:
905 {
906 OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure;
907 ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
908 if (ret != OMX_ErrorNone) {
909 goto EXIT;
910 }
911
912 Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_MPEG2_DEC_ROLE);
913 }
914 break;
915 case OMX_IndexParamVideoProfileLevelCurrent:
916 {
917 OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure;
918 OMX_VIDEO_PARAM_MPEG2TYPE *pSrcMpeg2Component = NULL;
919 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
920
921 ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
922 if (ret != OMX_ErrorNone) {
923 goto EXIT;
924 }
925
926 if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) {
927 ret = OMX_ErrorBadPortIndex;
928 goto EXIT;
929 }
930
931 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
932 pSrcMpeg2Component = &pMpeg2Dec->Mpeg2Component[pDstProfileLevel->nPortIndex];
933
934 pDstProfileLevel->eProfile = pSrcMpeg2Component->eProfile;
935 pDstProfileLevel->eLevel = pSrcMpeg2Component->eLevel;
936 }
937 break;
938 case OMX_IndexParamVideoErrorCorrection:
939 {
940 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
941 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL;
942 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
943
944 ret = Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
945 if (ret != OMX_ErrorNone) {
946 goto EXIT;
947 }
948
949 if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) {
950 ret = OMX_ErrorBadPortIndex;
951 goto EXIT;
952 }
953
954 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
955 pSrcErrorCorrectionType = &pMpeg2Dec->errorCorrectionType[INPUT_PORT_INDEX];
956
957 pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC;
958 pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync;
959 pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing;
960 pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning;
961 pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC;
962 }
963 break;
964 default:
965 ret = Exynos_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure);
966 break;
967 }
968 EXIT:
969 FunctionOut();
970
971 return ret;
972 }
973
974 OMX_ERRORTYPE Exynos_Mpeg2Dec_SetParameter(
975 OMX_IN OMX_HANDLETYPE hComponent,
976 OMX_IN OMX_INDEXTYPE nIndex,
977 OMX_IN OMX_PTR pComponentParameterStructure)
978 {
979 OMX_ERRORTYPE ret = OMX_ErrorNone;
980 OMX_COMPONENTTYPE *pOMXComponent = NULL;
981 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
982
983 FunctionIn();
984
985 if (hComponent == NULL || pComponentParameterStructure == NULL) {
986 ret = OMX_ErrorBadParameter;
987 goto EXIT;
988 }
989 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
990 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
991 if (ret != OMX_ErrorNone) {
992 goto EXIT;
993 }
994 if (pOMXComponent->pComponentPrivate == NULL) {
995 ret = OMX_ErrorBadParameter;
996 goto EXIT;
997 }
998
999 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1000 if (pExynosComponent->currentState == OMX_StateInvalid ) {
1001 ret = OMX_ErrorInvalidState;
1002 goto EXIT;
1003 }
1004
1005 switch (nIndex) {
1006 case OMX_IndexParamVideoMpeg2:
1007 {
1008 OMX_VIDEO_PARAM_MPEG2TYPE *pDstMpeg2Param = NULL;
1009 OMX_VIDEO_PARAM_MPEG2TYPE *pSrcMpeg2Param = (OMX_VIDEO_PARAM_MPEG2TYPE *)pComponentParameterStructure;
1010 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
1011 ret = Exynos_OMX_Check_SizeVersion(pSrcMpeg2Param, sizeof(OMX_VIDEO_PARAM_MPEG2TYPE));
1012 if (ret != OMX_ErrorNone) {
1013 goto EXIT;
1014 }
1015
1016 if (pSrcMpeg2Param->nPortIndex > OUTPUT_PORT_INDEX) {
1017 ret = OMX_ErrorBadPortIndex;
1018 goto EXIT;
1019 }
1020
1021 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1022 pDstMpeg2Param = &pMpeg2Dec->Mpeg2Component[pSrcMpeg2Param->nPortIndex];
1023
1024 Exynos_OSAL_Memcpy(pDstMpeg2Param, pSrcMpeg2Param, sizeof(OMX_VIDEO_PARAM_MPEG2TYPE));
1025 }
1026 break;
1027 case OMX_IndexParamStandardComponentRole:
1028 {
1029 OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure;
1030
1031 ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
1032 if (ret != OMX_ErrorNone) {
1033 goto EXIT;
1034 }
1035
1036 if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) {
1037 ret = OMX_ErrorIncorrectStateOperation;
1038 goto EXIT;
1039 }
1040
1041 if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_MPEG2_DEC_ROLE)) {
1042 pExynosComponent->pExynosPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG2;
1043 } else {
1044 ret = OMX_ErrorBadParameter;
1045 goto EXIT;
1046 }
1047 }
1048 break;
1049 case OMX_IndexParamVideoProfileLevelCurrent:
1050 {
1051 OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
1052 OMX_VIDEO_PARAM_MPEG2TYPE *pDstMpeg2Component = NULL;
1053 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
1054
1055 ret = Exynos_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
1056 if (ret != OMX_ErrorNone)
1057 goto EXIT;
1058
1059 if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) {
1060 ret = OMX_ErrorBadPortIndex;
1061 goto EXIT;
1062 }
1063
1064 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1065
1066 pDstMpeg2Component = &pMpeg2Dec->Mpeg2Component[pSrcProfileLevel->nPortIndex];
1067 pDstMpeg2Component->eProfile = pSrcProfileLevel->eProfile;
1068 pDstMpeg2Component->eLevel = pSrcProfileLevel->eLevel;
1069 }
1070 break;
1071 case OMX_IndexParamVideoErrorCorrection:
1072 {
1073 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
1074 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL;
1075 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
1076
1077 ret = Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
1078 if (ret != OMX_ErrorNone) {
1079 goto EXIT;
1080 }
1081
1082 if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) {
1083 ret = OMX_ErrorBadPortIndex;
1084 goto EXIT;
1085 }
1086
1087 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1088 pDstErrorCorrectionType = &pMpeg2Dec->errorCorrectionType[INPUT_PORT_INDEX];
1089
1090 pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC;
1091 pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync;
1092 pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing;
1093 pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning;
1094 pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC;
1095 }
1096 break;
1097 default:
1098 ret = Exynos_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure);
1099 break;
1100 }
1101 EXIT:
1102 FunctionOut();
1103
1104 return ret;
1105 }
1106
1107 OMX_ERRORTYPE Exynos_Mpeg2Dec_GetConfig(
1108 OMX_HANDLETYPE hComponent,
1109 OMX_INDEXTYPE nIndex,
1110 OMX_PTR pComponentConfigStructure)
1111 {
1112 OMX_ERRORTYPE ret = OMX_ErrorNone;
1113 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1114 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1115
1116 FunctionIn();
1117
1118 if (hComponent == NULL) {
1119 ret = OMX_ErrorBadParameter;
1120 goto EXIT;
1121 }
1122 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1123 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1124 if (ret != OMX_ErrorNone) {
1125 goto EXIT;
1126 }
1127 if (pOMXComponent->pComponentPrivate == NULL) {
1128 ret = OMX_ErrorBadParameter;
1129 goto EXIT;
1130 }
1131 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1132 if (pExynosComponent->currentState == OMX_StateInvalid) {
1133 ret = OMX_ErrorInvalidState;
1134 goto EXIT;
1135 }
1136
1137 switch (nIndex) {
1138 default:
1139 ret = Exynos_OMX_VideoDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure);
1140 break;
1141 }
1142
1143 EXIT:
1144 FunctionOut();
1145
1146 return ret;
1147 }
1148
1149 OMX_ERRORTYPE Exynos_Mpeg2Dec_SetConfig(
1150 OMX_HANDLETYPE hComponent,
1151 OMX_INDEXTYPE nIndex,
1152 OMX_PTR pComponentConfigStructure)
1153 {
1154 OMX_ERRORTYPE ret = OMX_ErrorNone;
1155 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1156 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1157
1158 FunctionIn();
1159
1160 if (hComponent == NULL) {
1161 ret = OMX_ErrorBadParameter;
1162 goto EXIT;
1163 }
1164 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1165 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1166 if (ret != OMX_ErrorNone) {
1167 goto EXIT;
1168 }
1169 if (pOMXComponent->pComponentPrivate == NULL) {
1170 ret = OMX_ErrorBadParameter;
1171 goto EXIT;
1172 }
1173 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1174 if (pExynosComponent->currentState == OMX_StateInvalid) {
1175 ret = OMX_ErrorInvalidState;
1176 goto EXIT;
1177 }
1178
1179 switch (nIndex) {
1180 default:
1181 ret = Exynos_OMX_VideoDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure);
1182 break;
1183 }
1184
1185 EXIT:
1186 FunctionOut();
1187
1188 return ret;
1189 }
1190
1191 OMX_ERRORTYPE Exynos_Mpeg2Dec_GetExtensionIndex(
1192 OMX_IN OMX_HANDLETYPE hComponent,
1193 OMX_IN OMX_STRING cParameterName,
1194 OMX_OUT OMX_INDEXTYPE *pIndexType)
1195 {
1196 OMX_ERRORTYPE ret = OMX_ErrorNone;
1197 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1198 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1199
1200 FunctionIn();
1201
1202 if (hComponent == NULL) {
1203 ret = OMX_ErrorBadParameter;
1204 goto EXIT;
1205 }
1206 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1207 ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
1208 if (ret != OMX_ErrorNone) {
1209 goto EXIT;
1210 }
1211 if (pOMXComponent->pComponentPrivate == NULL) {
1212 ret = OMX_ErrorBadParameter;
1213 goto EXIT;
1214 }
1215 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1216 if ((cParameterName == NULL) || (pIndexType == NULL)) {
1217 ret = OMX_ErrorBadParameter;
1218 goto EXIT;
1219 }
1220 if (pExynosComponent->currentState == OMX_StateInvalid) {
1221 ret = OMX_ErrorInvalidState;
1222 goto EXIT;
1223 }
1224
1225 if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
1226 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1227 *pIndexType = OMX_IndexVendorThumbnailMode;
1228 ret = OMX_ErrorNone;
1229 } else {
1230 ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
1231 }
1232
1233 EXIT:
1234 FunctionOut();
1235
1236 return ret;
1237 }
1238
1239 OMX_ERRORTYPE Exynos_Mpeg2Dec_ComponentRoleEnum(
1240 OMX_HANDLETYPE hComponent,
1241 OMX_U8 *cRole,
1242 OMX_U32 nIndex)
1243 {
1244 OMX_ERRORTYPE ret = OMX_ErrorNone;
1245 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1246 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1247
1248 FunctionIn();
1249
1250 if ((hComponent == NULL) || (cRole == NULL)) {
1251 ret = OMX_ErrorBadParameter;
1252 goto EXIT;
1253 }
1254 if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) {
1255 Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_MPEG2_DEC_ROLE);
1256 ret = OMX_ErrorNone;
1257 } else {
1258 ret = OMX_ErrorNoMore;
1259 }
1260
1261 EXIT:
1262 FunctionOut();
1263
1264 return ret;
1265 }
1266
1267 /* MFC Init */
1268 OMX_ERRORTYPE Exynos_Mpeg2Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
1269 {
1270 OMX_ERRORTYPE ret = OMX_ErrorNone;
1271 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1272 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1273 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1274 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1275 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)pVideoDec->hCodecHandle;
1276 OMX_PTR hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
1277
1278 ExynosVideoDecOps *pDecOps = NULL;
1279 ExynosVideoDecBufferOps *pInbufOps = NULL;
1280 ExynosVideoDecBufferOps *pOutbufOps = NULL;
1281
1282 CSC_METHOD csc_method = CSC_METHOD_SW;
1283 int i, plane;
1284
1285 FunctionIn();
1286
1287 pMpeg2Dec->hMFCMpeg2Handle.bConfiguredMFCSrc = OMX_FALSE;
1288 pMpeg2Dec->hMFCMpeg2Handle.bConfiguredMFCDst = OMX_FALSE;
1289 pExynosComponent->bUseFlagEOF = OMX_TRUE;
1290 pExynosComponent->bSaveFlagEOS = OMX_FALSE;
1291
1292 /* Mpeg2 Codec Open */
1293 ret = Mpeg2CodecOpen(pMpeg2Dec);
1294 if (ret != OMX_ErrorNone) {
1295 goto EXIT;
1296 }
1297
1298 pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
1299 pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
1300 pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
1301
1302 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
1303 OMX_U32 nPlaneSize[MFC_INPUT_BUFFER_PLANE] = {DEFAULT_MFC_INPUT_BUFFER_SIZE};
1304 Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID);
1305 Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
1306 ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize);
1307 if (ret != OMX_ErrorNone)
1308 goto EXIT;
1309
1310 for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++)
1311 Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
1312 } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
1313 /*************/
1314 /* TBD */
1315 /*************/
1316 /* Does not require any actions. */
1317 }
1318
1319 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
1320 Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID);
1321 Exynos_OSAL_QueueCreate(&pExynosOutputPort->codecBufferQ, MAX_QUEUE_ELEMENTS);
1322 } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
1323 /*************/
1324 /* TBD */
1325 /*************/
1326 /* Does not require any actions. */
1327 }
1328
1329 pMpeg2Dec->bSourceStart = OMX_FALSE;
1330 Exynos_OSAL_SignalCreate(&pMpeg2Dec->hSourceStartEvent);
1331 pMpeg2Dec->bDestinationStart = OMX_FALSE;
1332 Exynos_OSAL_SignalCreate(&pMpeg2Dec->hDestinationStartEvent);
1333
1334 Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
1335 Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
1336 pMpeg2Dec->hMFCMpeg2Handle.indexTimestamp = 0;
1337 pMpeg2Dec->hMFCMpeg2Handle.outputIndexTimestamp = 0;
1338
1339 pExynosComponent->getAllDelayBuffer = OMX_FALSE;
1340
1341 #ifdef USE_CSC_HW
1342 csc_method = CSC_METHOD_HW;
1343 #endif
1344 pVideoDec->csc_handle = csc_init(csc_method);
1345 if (pVideoDec->csc_handle == NULL) {
1346 ret = OMX_ErrorInsufficientResources;
1347 goto EXIT;
1348 }
1349 pVideoDec->csc_set_format = OMX_FALSE;
1350
1351 EXIT:
1352 FunctionOut();
1353
1354 return ret;
1355 }
1356
1357 /* MFC Terminate */
1358 OMX_ERRORTYPE Exynos_Mpeg2Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
1359 {
1360 OMX_ERRORTYPE ret = OMX_ErrorNone;
1361 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1362 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1363 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1364 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1365 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1366 OMX_PTR hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
1367
1368 ExynosVideoDecOps *pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
1369 ExynosVideoDecBufferOps *pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
1370 ExynosVideoDecBufferOps *pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
1371
1372 int i, plane;
1373
1374 FunctionIn();
1375
1376 if (pVideoDec->csc_handle != NULL) {
1377 csc_deinit(pVideoDec->csc_handle);
1378 pVideoDec->csc_handle = NULL;
1379 }
1380
1381 Exynos_OSAL_SignalTerminate(pMpeg2Dec->hDestinationStartEvent);
1382 pMpeg2Dec->hDestinationStartEvent = NULL;
1383 pMpeg2Dec->bDestinationStart = OMX_FALSE;
1384 Exynos_OSAL_SignalTerminate(pMpeg2Dec->hSourceStartEvent);
1385 pMpeg2Dec->hSourceStartEvent = NULL;
1386 pMpeg2Dec->bSourceStart = OMX_FALSE;
1387
1388 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
1389 Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX);
1390 Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ);
1391 Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID);
1392 } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
1393 /*************/
1394 /* TBD */
1395 /*************/
1396 /* Does not require any actions. */
1397 }
1398
1399 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
1400 Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX);
1401 Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ);
1402 Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID);
1403 } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) {
1404 /*************/
1405 /* TBD */
1406 /*************/
1407 /* Does not require any actions. */
1408 }
1409 Mpeg2CodecClose(pMpeg2Dec);
1410
1411 EXIT:
1412 FunctionOut();
1413
1414 return ret;
1415 }
1416
1417 OMX_ERRORTYPE Exynos_Mpeg2Dec_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData)
1418 {
1419 OMX_ERRORTYPE ret = OMX_ErrorNone;
1420 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1421 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1422 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1423 void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
1424 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1425 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1426 OMX_U32 oneFrameSize = pSrcInputData->dataLen;
1427 OMX_BOOL bInStartCode = OMX_FALSE;
1428 ExynosVideoDecOps *pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
1429 ExynosVideoDecBufferOps *pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
1430 ExynosVideoDecBufferOps *pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
1431 ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE;
1432 int i;
1433
1434 FunctionIn();
1435
1436 if (pMpeg2Dec->hMFCMpeg2Handle.bConfiguredMFCSrc == OMX_FALSE) {
1437 ret = Mpeg2CodecSrcSetup(pOMXComponent, pSrcInputData);
1438 goto EXIT;
1439 }
1440 if (pMpeg2Dec->hMFCMpeg2Handle.bConfiguredMFCDst == OMX_FALSE) {
1441 ret = Mpeg2CodecDstSetup(pOMXComponent);
1442 }
1443
1444 if (((bInStartCode = Check_Mpeg2_StartCode(pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, oneFrameSize)) == OMX_TRUE) ||
1445 ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) {
1446 pExynosComponent->timeStamp[pMpeg2Dec->hMFCMpeg2Handle.indexTimestamp] = pSrcInputData->timeStamp;
1447 pExynosComponent->nFlags[pMpeg2Dec->hMFCMpeg2Handle.indexTimestamp] = pSrcInputData->nFlags;
1448 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "input timestamp %lld us (%.2f secs), Tag: %d, nFlags: 0x%x", pSrcInputData->timeStamp, pSrcInputData->timeStamp / 1E6, pMpeg2Dec->hMFCMpeg2Handle.indexTimestamp, pSrcInputData->nFlags);
1449 pDecOps->Set_FrameTag(hMFCHandle, pMpeg2Dec->hMFCMpeg2Handle.indexTimestamp);
1450 pMpeg2Dec->hMFCMpeg2Handle.indexTimestamp++;
1451 pMpeg2Dec->hMFCMpeg2Handle.indexTimestamp %= MAX_TIMESTAMP;
1452
1453 /* queue work for input buffer */
1454 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize, pSrcInputData->bufferHeader, pSrcInputData->buffer.singlePlaneBuffer.dataBuffer);
1455 codecReturn = pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer,
1456 (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader);
1457 if (codecReturn != VIDEO_ERROR_NONE) {
1458 ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
1459 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
1460 goto EXIT;
1461 }
1462 Mpeg2CodecStart(pOMXComponent, INPUT_PORT_INDEX);
1463 if (pMpeg2Dec->bSourceStart == OMX_FALSE) {
1464 pMpeg2Dec->bSourceStart = OMX_TRUE;
1465 Exynos_OSAL_SignalSet(pMpeg2Dec->hSourceStartEvent);
1466 Exynos_OSAL_SleepMillisec(0);
1467 }
1468 if (pMpeg2Dec->bDestinationStart == OMX_FALSE) {
1469 pMpeg2Dec->bDestinationStart = OMX_TRUE;
1470 Exynos_OSAL_SignalSet(pMpeg2Dec->hDestinationStartEvent);
1471 Exynos_OSAL_SleepMillisec(0);
1472 }
1473 } else if (bInStartCode == OMX_FALSE) {
1474 ret = OMX_ErrorCorruptedFrame;
1475 goto EXIT;
1476 }
1477
1478 ret = OMX_ErrorNone;
1479
1480 EXIT:
1481 FunctionOut();
1482
1483 return ret;
1484 }
1485
1486 OMX_ERRORTYPE Exynos_Mpeg2Dec_SrcOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData)
1487 {
1488 OMX_ERRORTYPE ret = OMX_ErrorNone;
1489 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1490 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1491 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1492 void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
1493 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1494 ExynosVideoDecOps *pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
1495 ExynosVideoDecBufferOps *pInbufOps = pMpeg2Dec->hMFCMpeg2Handle.pInbufOps;
1496 ExynosVideoBuffer *pVideoBuffer;
1497
1498 FunctionIn();
1499
1500 pVideoBuffer = pInbufOps->Dequeue(hMFCHandle);
1501
1502 pSrcOutputData->dataLen = 0;
1503 pSrcOutputData->usedDataLen = 0;
1504 pSrcOutputData->remainDataLen = 0;
1505 pSrcOutputData->nFlags = 0;
1506 pSrcOutputData->timeStamp = 0;
1507
1508 if (pVideoBuffer == NULL) {
1509 pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = NULL;
1510 pSrcOutputData->allocSize = 0;
1511 pSrcOutputData->pPrivate = NULL;
1512 pSrcOutputData->bufferHeader = NULL;
1513 } else {
1514 pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = pVideoBuffer->planes[0].addr;
1515 pSrcOutputData->buffer.singlePlaneBuffer.fd = pVideoBuffer->planes[0].fd;
1516 pSrcOutputData->allocSize = pVideoBuffer->planes[0].allocSize;
1517
1518 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
1519 int i;
1520 for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
1521 if (pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer ==
1522 pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]) {
1523 pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
1524 pSrcOutputData->pPrivate = pVideoDec->pMFCDecInputBuffer[i];
1525 break;
1526 }
1527 }
1528
1529 if (i >= MFC_INPUT_BUFFER_NUM_MAX) {
1530 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
1531 ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
1532 goto EXIT;
1533 }
1534 }
1535
1536 /* For Share Buffer */
1537 pSrcOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE*)pVideoBuffer->pPrivate;
1538 }
1539
1540 ret = OMX_ErrorNone;
1541
1542 EXIT:
1543 FunctionOut();
1544
1545 return ret;
1546 }
1547
1548 OMX_ERRORTYPE Exynos_Mpeg2Dec_DstIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData)
1549 {
1550 OMX_ERRORTYPE ret = OMX_ErrorNone;
1551 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1552 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1553 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1554 void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
1555 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1556 ExynosVideoDecOps *pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
1557 ExynosVideoDecBufferOps *pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
1558 OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0,};
1559 ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE;
1560
1561 FunctionIn();
1562
1563 if (pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0] == NULL) {
1564 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to find input buffer");
1565 ret = OMX_ErrorBadParameter;
1566 goto EXIT;
1567 }
1568
1569 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x", __FUNCTION__, __LINE__,
1570 pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0],
1571 pDstInputData->buffer.multiPlaneBuffer.dataBuffer[1]);
1572
1573 codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pDstInputData->buffer.multiPlaneBuffer.dataBuffer,
1574 (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, pDstInputData->bufferHeader);
1575
1576 if (codecReturn != VIDEO_ERROR_NONE) {
1577 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__);
1578 ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
1579 goto EXIT;
1580 }
1581 Mpeg2CodecStart(pOMXComponent, OUTPUT_PORT_INDEX);
1582
1583 ret = OMX_ErrorNone;
1584
1585 EXIT:
1586 FunctionOut();
1587
1588 return ret;
1589 }
1590
1591 OMX_ERRORTYPE Exynos_Mpeg2Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData)
1592 {
1593 OMX_ERRORTYPE ret = OMX_ErrorNone;
1594 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1595 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1596 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1597 void *hMFCHandle = pMpeg2Dec->hMFCMpeg2Handle.hMFCHandle;
1598 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1599 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1600 ExynosVideoDecOps *pDecOps = pMpeg2Dec->hMFCMpeg2Handle.pDecOps;
1601 ExynosVideoDecBufferOps *pOutbufOps = pMpeg2Dec->hMFCMpeg2Handle.pOutbufOps;
1602 ExynosVideoBuffer *pVideoBuffer = NULL;
1603 ExynosVideoFrameStatusType displayStatus = VIDEO_FRAME_STATUS_UNKNOWN;
1604 ExynosVideoGeometry *bufferGeometry;
1605 DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL;
1606 OMX_S32 indexTimestamp = 0;
1607 int plane;
1608
1609 FunctionIn();
1610
1611 if (pMpeg2Dec->bDestinationStart == OMX_FALSE) {
1612 ret = OMX_ErrorNone;
1613 goto EXIT;
1614 }
1615
1616 while (1) {
1617 if ((pVideoBuffer = pOutbufOps->Dequeue(hMFCHandle)) == NULL) {
1618 ret = OMX_ErrorNone;
1619 goto EXIT;
1620 }
1621 displayStatus = pVideoBuffer->displayStatus;
1622 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus: 0x%x", displayStatus);
1623
1624 if ((displayStatus == VIDEO_FRAME_STATUS_DISPLAY_DECODING) ||
1625 (displayStatus == VIDEO_FRAME_STATUS_DISPLAY_ONLY) ||
1626 (displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) ||
1627 (displayStatus == VIDEO_FRAME_STATUS_DECODING_FINISHED) ||
1628 (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) {
1629 ret = OMX_ErrorNone;
1630 break;
1631 }
1632 }
1633
1634 pMpeg2Dec->hMFCMpeg2Handle.outputIndexTimestamp++;
1635 pMpeg2Dec->hMFCMpeg2Handle.outputIndexTimestamp %= MAX_TIMESTAMP;
1636
1637 pDstOutputData->allocSize = pDstOutputData->dataLen = 0;
1638 for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
1639 pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[plane] = pVideoBuffer->planes[plane].addr;
1640 pDstOutputData->buffer.multiPlaneBuffer.fd[plane] = pVideoBuffer->planes[plane].fd;
1641 pDstOutputData->allocSize += pVideoBuffer->planes[plane].allocSize;
1642 pDstOutputData->dataLen += pVideoBuffer->planes[plane].dataSize;
1643 }
1644 pDstOutputData->usedDataLen = 0;
1645 pDstOutputData->pPrivate = pVideoBuffer;
1646 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
1647 int i = 0;
1648 pDstOutputData->pPrivate = NULL;
1649 for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
1650 if (pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[0] ==
1651 pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]) {
1652 pDstOutputData->pPrivate = pVideoDec->pMFCDecOutputBuffer[i];
1653 break;
1654 }
1655 }
1656
1657 if (pDstOutputData->pPrivate == NULL) {
1658 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
1659 ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
1660 goto EXIT;
1661 }
1662 }
1663
1664 /* For Share Buffer */
1665 pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate;
1666
1667 pBufferInfo = (DECODE_CODEC_EXTRA_BUFFERINFO *)pDstOutputData->extInfo;
1668 bufferGeometry = &pMpeg2Dec->hMFCMpeg2Handle.codecOutbufConf;
1669 pBufferInfo->imageWidth = bufferGeometry->nFrameWidth;
1670 pBufferInfo->imageHeight = bufferGeometry->nFrameHeight;
1671 switch (bufferGeometry->eColorFormat) {
1672 case VIDEO_COLORFORMAT_NV12:
1673 pBufferInfo->ColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
1674 break;
1675 case VIDEO_COLORFORMAT_NV12_TILED:
1676 default:
1677 pBufferInfo->ColorFormat = OMX_SEC_COLOR_FormatNV12Tiled;
1678 break;
1679 }
1680
1681 indexTimestamp = pDecOps->Get_FrameTag(hMFCHandle);
1682 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "out indexTimestamp: %d", indexTimestamp);
1683 if ((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)) {
1684 if ((pExynosComponent->checkTimeStamp.needSetStartTimeStamp != OMX_TRUE) &&
1685 (pExynosComponent->checkTimeStamp.needCheckStartTimeStamp != OMX_TRUE)) {
1686 if (indexTimestamp == INDEX_AFTER_EOS) {
1687 pDstOutputData->timeStamp = 0x00;
1688 pDstOutputData->nFlags = 0x00;
1689 } else {
1690 pDstOutputData->timeStamp = pExynosComponent->timeStamp[pMpeg2Dec->hMFCMpeg2Handle.outputIndexTimestamp];
1691 pDstOutputData->nFlags = pExynosComponent->nFlags[pMpeg2Dec->hMFCMpeg2Handle.outputIndexTimestamp];
1692 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "missing out indexTimestamp: %d", indexTimestamp);
1693 }
1694 } else {
1695 pDstOutputData->timeStamp = 0x00;
1696 pDstOutputData->nFlags = 0x00;
1697 }
1698 } else {
1699 /* For timestamp correction. if mfc support frametype detect */
1700 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoBuffer->frameType);
1701
1702 /* NEED TIMESTAMP REORDER */
1703 if (pVideoDec->bDTSMode == OMX_TRUE) {
1704 if (pVideoBuffer->frameType == VIDEO_FRAME_I)
1705 pMpeg2Dec->hMFCMpeg2Handle.outputIndexTimestamp = indexTimestamp;
1706 else
1707 indexTimestamp = pMpeg2Dec->hMFCMpeg2Handle.outputIndexTimestamp;
1708 }
1709
1710 pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp];
1711 pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp];
1712
1713 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData->timeStamp, pDstOutputData->timeStamp / 1E6, indexTimestamp, pDstOutputData->nFlags);
1714 }
1715
1716 if ((displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) ||
1717 (displayStatus == VIDEO_FRAME_STATUS_DECODING_FINISHED) ||
1718 ((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) {
1719 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus:%d, nFlags0x%x", displayStatus, pDstOutputData->nFlags);
1720 pDstOutputData->remainDataLen = 0;
1721 } else {
1722 pDstOutputData->remainDataLen = bufferGeometry->nFrameWidth * bufferGeometry->nFrameHeight * 3 / 2;
1723 }
1724
1725 ret = OMX_ErrorNone;
1726
1727 EXIT:
1728 FunctionOut();
1729
1730 return ret;
1731 }
1732
1733 OMX_ERRORTYPE Exynos_Mpeg2Dec_srcInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData)
1734 {
1735 OMX_ERRORTYPE ret = OMX_ErrorNone;
1736 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1737 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1738 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1739
1740 FunctionIn();
1741
1742 if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) {
1743 ret = OMX_ErrorNone;
1744 goto EXIT;
1745 }
1746 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) {
1747 ret = OMX_ErrorNone;
1748 goto EXIT;
1749 }
1750
1751 ret = Exynos_Mpeg2Dec_SrcIn(pOMXComponent, pSrcInputData);
1752 if ((ret != OMX_ErrorNone) &&
1753 (ret != OMX_ErrorInputDataDecodeYet) &&
1754 (ret != OMX_ErrorCorruptedFrame)) {
1755 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
1756 pExynosComponent->callbackData,
1757 OMX_EventError, ret, 0, NULL);
1758 }
1759
1760 EXIT:
1761 FunctionOut();
1762
1763 return ret;
1764 }
1765
1766 OMX_ERRORTYPE Exynos_Mpeg2Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData)
1767 {
1768 OMX_ERRORTYPE ret = OMX_ErrorNone;
1769 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1770 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1771 EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1772
1773 FunctionIn();
1774
1775 if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) {
1776 ret = OMX_ErrorNone;
1777 goto EXIT;
1778 }
1779
1780 if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
1781 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) {
1782 ret = OMX_ErrorNone;
1783 goto EXIT;
1784 }
1785 }
1786 if ((pMpeg2Dec->bSourceStart == OMX_FALSE) &&
1787 (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort))) {
1788 Exynos_OSAL_SignalWait(pMpeg2Dec->hSourceStartEvent, DEF_MAX_WAIT_TIME);
1789 Exynos_OSAL_SignalReset(pMpeg2Dec->hSourceStartEvent);
1790 }
1791
1792 ret = Exynos_Mpeg2Dec_SrcOut(pOMXComponent, pSrcOutputData);
1793 if ((ret != OMX_ErrorNone) &&
1794 (pExynosComponent->currentState == OMX_StateExecuting)) {
1795 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
1796 pExynosComponent->callbackData,
1797 OMX_EventError, ret, 0, NULL);
1798 }
1799
1800 EXIT:
1801 FunctionOut();
1802
1803 return ret;
1804 }
1805
1806 OMX_ERRORTYPE Exynos_Mpeg2Dec_dstInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData)
1807 {
1808 OMX_ERRORTYPE ret = OMX_ErrorNone;
1809 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1810 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1811 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1812
1813 FunctionIn();
1814
1815 if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) {
1816 ret = OMX_ErrorNone;
1817 goto EXIT;
1818 }
1819 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) {
1820 ret = OMX_ErrorNone;
1821 goto EXIT;
1822 }
1823 if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
1824 if ((pMpeg2Dec->bDestinationStart == OMX_FALSE) &&
1825 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) {
1826 Exynos_OSAL_SignalWait(pMpeg2Dec->hDestinationStartEvent, DEF_MAX_WAIT_TIME);
1827 Exynos_OSAL_SignalReset(pMpeg2Dec->hDestinationStartEvent);
1828 }
1829 }
1830 if (pMpeg2Dec->hMFCMpeg2Handle.bConfiguredMFCDst == OMX_TRUE) {
1831 ret = Exynos_Mpeg2Dec_DstIn(pOMXComponent, pDstInputData);
1832 if (ret != OMX_ErrorNone) {
1833 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
1834 pExynosComponent->callbackData,
1835 OMX_EventError, ret, 0, NULL);
1836 }
1837 }
1838
1839 EXIT:
1840 FunctionOut();
1841
1842 return ret;
1843 }
1844
1845 OMX_ERRORTYPE Exynos_Mpeg2Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData)
1846 {
1847 OMX_ERRORTYPE ret = OMX_ErrorNone;
1848 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1849 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
1850 EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1851
1852 FunctionIn();
1853
1854 if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) {
1855 ret = OMX_ErrorNone;
1856 goto EXIT;
1857 }
1858 if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) {
1859 ret = OMX_ErrorNone;
1860 goto EXIT;
1861 }
1862
1863 if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
1864 if ((pMpeg2Dec->bDestinationStart == OMX_FALSE) &&
1865 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) {
1866 Exynos_OSAL_SignalWait(pMpeg2Dec->hDestinationStartEvent, DEF_MAX_WAIT_TIME);
1867 Exynos_OSAL_SignalReset(pMpeg2Dec->hDestinationStartEvent);
1868 }
1869 }
1870 ret = Exynos_Mpeg2Dec_DstOut(pOMXComponent, pDstOutputData);
1871 if ((ret != OMX_ErrorNone) &&
1872 (pExynosComponent->currentState == OMX_StateExecuting)) {
1873 pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
1874 pExynosComponent->callbackData,
1875 OMX_EventError, ret, 0, NULL);
1876 }
1877
1878 EXIT:
1879 FunctionOut();
1880
1881 return ret;
1882 }
1883
1884 OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(
1885 OMX_HANDLETYPE hComponent,
1886 OMX_STRING componentName)
1887 {
1888 OMX_ERRORTYPE ret = OMX_ErrorNone;
1889 OMX_COMPONENTTYPE *pOMXComponent = NULL;
1890 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
1891 EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
1892 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
1893 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
1894 int i = 0;
1895
1896 FunctionIn();
1897
1898 if ((hComponent == NULL) || (componentName == NULL)) {
1899 ret = OMX_ErrorBadParameter;
1900 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
1901 goto EXIT;
1902 }
1903 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_MPEG2_DEC, componentName) != 0) {
1904 ret = OMX_ErrorBadParameter;
1905 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__);
1906 goto EXIT;
1907 }
1908
1909 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
1910 ret = Exynos_OMX_VideoDecodeComponentInit(pOMXComponent);
1911 if (ret != OMX_ErrorNone) {
1912 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
1913 goto EXIT;
1914 }
1915 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
1916 pExynosComponent->codecType = HW_VIDEO_DEC_CODEC;
1917
1918 pExynosComponent->componentName = (OMX_STRING)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
1919 if (pExynosComponent->componentName == NULL) {
1920 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
1921 ret = OMX_ErrorInsufficientResources;
1922 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
1923 goto EXIT;
1924 }
1925 Exynos_OSAL_Memset(pExynosComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
1926
1927 pMpeg2Dec = Exynos_OSAL_Malloc(sizeof(EXYNOS_MPEG2DEC_HANDLE));
1928 if (pMpeg2Dec == NULL) {
1929 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
1930 ret = OMX_ErrorInsufficientResources;
1931 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
1932 goto EXIT;
1933 }
1934 Exynos_OSAL_Memset(pMpeg2Dec, 0, sizeof(EXYNOS_MPEG2DEC_HANDLE));
1935 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
1936 pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pMpeg2Dec;
1937
1938 Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_MPEG2_DEC);
1939
1940 /* Set componentVersion */
1941 pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
1942 pExynosComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
1943 pExynosComponent->componentVersion.s.nRevision = REVISION_NUMBER;
1944 pExynosComponent->componentVersion.s.nStep = STEP_NUMBER;
1945 /* Set specVersion */
1946 pExynosComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
1947 pExynosComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
1948 pExynosComponent->specVersion.s.nRevision = REVISION_NUMBER;
1949 pExynosComponent->specVersion.s.nStep = STEP_NUMBER;
1950
1951 /* Input port */
1952 pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
1953 pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
1954 pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT;
1955 pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
1956 pExynosPort->portDefinition.format.video.nSliceHeight = 0;
1957 pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
1958 pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG2;
1959 Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
1960 Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/mpeg2");
1961 pExynosPort->portDefinition.format.video.pNativeRender = 0;
1962 pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
1963 pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
1964 pExynosPort->portDefinition.bEnabled = OMX_TRUE;
1965 //pExynosPort->bufferProcessType = BUFFER_SHARE;
1966 pExynosPort->bufferProcessType = BUFFER_COPY;
1967 pExynosPort->portWayType = WAY2_PORT;
1968
1969 /* Output port */
1970 pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
1971 pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
1972 pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT;
1973 pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
1974 pExynosPort->portDefinition.format.video.nSliceHeight = 0;
1975 pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
1976 pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
1977 Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
1978 Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video");
1979 pExynosPort->portDefinition.format.video.pNativeRender = 0;
1980 pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
1981 pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
1982 pExynosPort->portDefinition.bEnabled = OMX_TRUE;
1983 pExynosPort->bufferProcessType = BUFFER_COPY | BUFFER_ANBSHARE;
1984 pExynosPort->portWayType = WAY2_PORT;
1985
1986 for(i = 0; i < ALL_PORT_NUM; i++) {
1987 INIT_SET_SIZE_VERSION(&pMpeg2Dec->Mpeg2Component[i], OMX_VIDEO_PARAM_MPEG2TYPE);
1988 pMpeg2Dec->Mpeg2Component[i].nPortIndex = i;
1989 pMpeg2Dec->Mpeg2Component[i].eProfile = OMX_VIDEO_MPEG2ProfileMain;
1990 pMpeg2Dec->Mpeg2Component[i].eLevel = OMX_VIDEO_MPEG2LevelML; /* Check again**** */
1991 }
1992
1993 pOMXComponent->GetParameter = &Exynos_Mpeg2Dec_GetParameter;
1994 pOMXComponent->SetParameter = &Exynos_Mpeg2Dec_SetParameter;
1995 pOMXComponent->GetConfig = &Exynos_Mpeg2Dec_GetConfig;
1996 pOMXComponent->SetConfig = &Exynos_Mpeg2Dec_SetConfig;
1997 pOMXComponent->GetExtensionIndex = &Exynos_Mpeg2Dec_GetExtensionIndex;
1998 pOMXComponent->ComponentRoleEnum = &Exynos_Mpeg2Dec_ComponentRoleEnum;
1999 pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit;
2000
2001 pExynosComponent->exynos_codec_componentInit = &Exynos_Mpeg2Dec_Init;
2002 pExynosComponent->exynos_codec_componentTerminate = &Exynos_Mpeg2Dec_Terminate;
2003
2004 pVideoDec->exynos_codec_srcInputProcess = &Exynos_Mpeg2Dec_srcInputBufferProcess;
2005 pVideoDec->exynos_codec_srcOutputProcess = &Exynos_Mpeg2Dec_srcOutputBufferProcess;
2006 pVideoDec->exynos_codec_dstInputProcess = &Exynos_Mpeg2Dec_dstInputBufferProcess;
2007 pVideoDec->exynos_codec_dstOutputProcess = &Exynos_Mpeg2Dec_dstOutputBufferProcess;
2008
2009 pVideoDec->exynos_codec_start = &Mpeg2CodecStart;
2010 pVideoDec->exynos_codec_stop = &Mpeg2CodecStop;
2011 pVideoDec->exynos_codec_bufferProcessRun = &Mpeg2CodecOutputBufferProcessRun;
2012 pVideoDec->exynos_codec_enqueueAllBuffer = &Mpeg2CodecEnQueueAllBuffer;
2013
2014 pVideoDec->exynos_checkInputFrame = &Check_Mpeg2_Frame;
2015 pVideoDec->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData;
2016 pVideoDec->exynos_codec_getCodecOutputPrivateData = &GetCodecOutputPrivateData;
2017
2018 pVideoDec->hSharedMemory = Exynos_OSAL_SharedMemory_Open();
2019 if (pVideoDec->hSharedMemory == NULL) {
2020 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
2021 Exynos_OSAL_Free(pMpeg2Dec);
2022 pMpeg2Dec = ((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL;
2023 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
2024 ret = OMX_ErrorInsufficientResources;
2025 goto EXIT;
2026 }
2027
2028 pExynosComponent->currentState = OMX_StateLoaded;
2029
2030 ret = OMX_ErrorNone;
2031
2032 EXIT:
2033 FunctionOut();
2034
2035 return ret;
2036 }
2037
2038 OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(
2039 OMX_HANDLETYPE hComponent)
2040 {
2041 OMX_ERRORTYPE ret = OMX_ErrorNone;
2042 OMX_COMPONENTTYPE *pOMXComponent = NULL;
2043 EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
2044 EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
2045 EXYNOS_MPEG2DEC_HANDLE *pMpeg2Dec = NULL;
2046
2047 FunctionIn();
2048
2049 if (hComponent == NULL) {
2050 ret = OMX_ErrorBadParameter;
2051 goto EXIT;
2052 }
2053 pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
2054 pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
2055 pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
2056
2057 Exynos_OSAL_SharedMemory_Close(pVideoDec->hSharedMemory);
2058
2059 Exynos_OSAL_Free(pExynosComponent->componentName);
2060 pExynosComponent->componentName = NULL;
2061
2062 pMpeg2Dec = (EXYNOS_MPEG2DEC_HANDLE *)pVideoDec->hCodecHandle;
2063 if (pMpeg2Dec != NULL) {
2064 Exynos_OSAL_Free(pMpeg2Dec);
2065 pMpeg2Dec = pVideoDec->hCodecHandle = NULL;
2066 }
2067
2068 ret = Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
2069 if (ret != OMX_ErrorNone) {
2070 goto EXIT;
2071 }
2072
2073 ret = OMX_ErrorNone;
2074
2075 EXIT:
2076 FunctionOut();
2077
2078 return ret;
2079 }