3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * @file Exynos_OMX_Mpeg2dec.c
21 * @author Satish Kumar Reddy (palli.satish@samsung.com)
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"
45 #include "Exynos_OSAL_Android.h"
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 */
53 #define EXYNOS_LOG_TAG "EXYNOS_MPEG2_DEC"
54 #define EXYNOS_LOG_OFF
55 //#define EXYNOS_TRACE_ON
56 #include "Exynos_OSAL_Log.h"
58 #define MPEG2_DEC_NUM_OF_EXTRA_BUFFERS 7
60 //#define FULL_FRAME_SEARCH /* Full frame search not support*/
62 static OMX_ERRORTYPE
GetCodecInputPrivateData(OMX_PTR codecBuffer
, void *pVirtAddr
, OMX_U32
*dataSize
)
64 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
70 static OMX_ERRORTYPE
GetCodecOutputPrivateData(OMX_PTR codecBuffer
, void *addr
[], int size
[])
72 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
73 ExynosVideoBuffer
*pCodecBuffer
;
75 if (codecBuffer
== NULL
) {
76 ret
= OMX_ErrorBadParameter
;
80 pCodecBuffer
= (ExynosVideoBuffer
*)codecBuffer
;
83 addr
[0] = pCodecBuffer
->planes
[0].addr
;
84 addr
[1] = pCodecBuffer
->planes
[1].addr
;
85 addr
[2] = pCodecBuffer
->planes
[2].addr
;
89 size
[0] = pCodecBuffer
->planes
[0].allocSize
;
90 size
[1] = pCodecBuffer
->planes
[1].allocSize
;
91 size
[2] = pCodecBuffer
->planes
[2].allocSize
;
98 int Check_Mpeg2_Frame(
102 OMX_BOOL bPreviousFrameEOF
,
103 OMX_BOOL
*pbEndOfFrame
)
107 *pbEndOfFrame
= OMX_TRUE
;
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
;
119 static OMX_BOOL
Check_Mpeg2_StartCode(
120 OMX_U8
*pInputStream
,
123 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "streamSize: %d",streamSize
);
125 if (streamSize
< 3) {
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");
138 OMX_ERRORTYPE
Mpeg2CodecOpen(EXYNOS_MPEG2DEC_HANDLE
*pMpeg2Dec
)
140 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
141 ExynosVideoDecOps
*pDecOps
= NULL
;
142 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
143 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
147 if (pMpeg2Dec
== NULL
) {
148 ret
= OMX_ErrorBadParameter
;
149 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
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
));
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
;
164 pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
= pDecOps
;
165 pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
= pInbufOps
;
166 pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
= pOutbufOps
;
168 /* function pointer mapping */
169 pDecOps
->nSize
= sizeof(ExynosVideoDecOps
);
170 pInbufOps
->nSize
= sizeof(ExynosVideoDecBufferOps
);
171 pOutbufOps
->nSize
= sizeof(ExynosVideoDecBufferOps
);
173 Exynos_Video_Register_Decoder(pDecOps
, pInbufOps
, pOutbufOps
);
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
;
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
;
195 /* alloc context, open, querycap */
197 pMpeg2Dec
->hMFCMpeg2Handle
.hMFCHandle
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
->Init(V4L2_MEMORY_DMABUF
);
199 pMpeg2Dec
->hMFCMpeg2Handle
.hMFCHandle
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
->Init(V4L2_MEMORY_USERPTR
);
201 if (pMpeg2Dec
->hMFCMpeg2Handle
.hMFCHandle
== NULL
) {
202 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to allocate context buffer");
203 ret
= OMX_ErrorInsufficientResources
;
210 if (ret
!= OMX_ErrorNone
) {
211 if (pDecOps
!= NULL
) {
212 Exynos_OSAL_Free(pDecOps
);
213 pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
= NULL
;
215 if (pInbufOps
!= NULL
) {
216 Exynos_OSAL_Free(pInbufOps
);
217 pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
= NULL
;
219 if (pOutbufOps
!= NULL
) {
220 Exynos_OSAL_Free(pOutbufOps
);
221 pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
= NULL
;
230 OMX_ERRORTYPE
Mpeg2CodecClose(EXYNOS_MPEG2DEC_HANDLE
*pMpeg2Dec
)
232 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
233 void *hMFCHandle
= NULL
;
234 ExynosVideoDecOps
*pDecOps
= NULL
;
235 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
236 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
240 if (pMpeg2Dec
== NULL
) {
241 ret
= OMX_ErrorBadParameter
;
245 hMFCHandle
= pMpeg2Dec
->hMFCMpeg2Handle
.hMFCHandle
;
246 pDecOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
;
247 pInbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
248 pOutbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
250 if (hMFCHandle
!= NULL
) {
251 pDecOps
->Finalize(hMFCHandle
);
252 pMpeg2Dec
->hMFCMpeg2Handle
.hMFCHandle
= NULL
;
254 if (pOutbufOps
!= NULL
) {
255 Exynos_OSAL_Free(pOutbufOps
);
256 pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
= NULL
;
258 if (pInbufOps
!= NULL
) {
259 Exynos_OSAL_Free(pInbufOps
);
260 pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
= NULL
;
262 if (pDecOps
!= NULL
) {
263 Exynos_OSAL_Free(pDecOps
);
264 pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
= NULL
;
275 OMX_ERRORTYPE
Mpeg2CodecStart(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
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
;
287 if (pOMXComponent
== NULL
) {
288 ret
= OMX_ErrorBadParameter
;
292 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
293 if (pVideoDec
== NULL
) {
294 ret
= OMX_ErrorBadParameter
;
298 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
299 if (pMpeg2Dec
== NULL
) {
300 ret
= OMX_ErrorBadParameter
;
304 hMFCHandle
= pMpeg2Dec
->hMFCMpeg2Handle
.hMFCHandle
;
305 pDecOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
;
306 pInbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
307 pOutbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
309 if (nPortIndex
== INPUT_PORT_INDEX
)
310 pInbufOps
->Run(hMFCHandle
);
311 else if (nPortIndex
== OUTPUT_PORT_INDEX
)
312 pOutbufOps
->Run(hMFCHandle
);
322 OMX_ERRORTYPE
Mpeg2CodecStop(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
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
;
334 if (pOMXComponent
== NULL
) {
335 ret
= OMX_ErrorBadParameter
;
339 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
340 if (pVideoDec
== NULL
) {
341 ret
= OMX_ErrorBadParameter
;
344 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
345 if (pMpeg2Dec
== NULL
) {
346 ret
= OMX_ErrorBadParameter
;
350 hMFCHandle
= pMpeg2Dec
->hMFCMpeg2Handle
.hMFCHandle
;
351 pDecOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
;
352 pInbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
353 pOutbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
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
);
368 OMX_ERRORTYPE
Mpeg2CodecOutputBufferProcessRun(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
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
;
380 if (pOMXComponent
== NULL
) {
381 ret
= OMX_ErrorBadParameter
;
385 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
386 if (pVideoDec
== NULL
) {
387 ret
= OMX_ErrorBadParameter
;
390 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
391 if (pMpeg2Dec
== NULL
) {
392 ret
= OMX_ErrorBadParameter
;
396 hMFCHandle
= pMpeg2Dec
->hMFCMpeg2Handle
.hMFCHandle
;
397 pDecOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
;
398 pInbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
399 pOutbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
401 if (nPortIndex
== INPUT_PORT_INDEX
) {
402 if (pMpeg2Dec
->bSourceStart
== OMX_FALSE
) {
403 Exynos_OSAL_SignalSet(pMpeg2Dec
->hSourceStartEvent
);
404 Exynos_OSAL_SleepMillisec(0);
408 if (nPortIndex
== OUTPUT_PORT_INDEX
) {
409 if (pMpeg2Dec
->bDestinationStart
== OMX_FALSE
) {
410 Exynos_OSAL_SignalSet(pMpeg2Dec
->hDestinationStartEvent
);
411 Exynos_OSAL_SleepMillisec(0);
423 OMX_ERRORTYPE
Mpeg2CodecRegistCodecBuffers(
424 OMX_COMPONENTTYPE
*pOMXComponent
,
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
;
437 OMX_U32 nPlaneCnt
= 0;
442 if (nPortIndex
== INPUT_PORT_INDEX
) {
443 ppCodecBuffer
= &(pVideoDec
->pMFCDecInputBuffer
[0]);
444 nPlaneCnt
= MFC_INPUT_BUFFER_PLANE
;
445 pBufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
447 ppCodecBuffer
= &(pVideoDec
->pMFCDecOutputBuffer
[0]);
448 nPlaneCnt
= MFC_OUTPUT_BUFFER_PLANE
;
449 pBufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
452 pPlanes
= (ExynosVideoPlane
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane
) * nPlaneCnt
);
453 if (pPlanes
== NULL
) {
454 ret
= OMX_ErrorInsufficientResources
;
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
];
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
);
474 Exynos_OSAL_Free(pPlanes
);
484 OMX_ERRORTYPE
Mpeg2CodecEnQueueAllBuffer(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
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
];
495 ExynosVideoDecOps
*pDecOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
;
496 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
497 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
501 if ((nPortIndex
!= INPUT_PORT_INDEX
) && (nPortIndex
!= OUTPUT_PORT_INDEX
)) {
502 ret
= OMX_ErrorBadPortIndex
;
506 if ((nPortIndex
== INPUT_PORT_INDEX
) &&
507 (pMpeg2Dec
->bSourceStart
== OMX_TRUE
)) {
508 Exynos_CodecBufferReset(pExynosComponent
, INPUT_PORT_INDEX
);
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]);
514 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
517 pInbufOps
->Clear_Queue(hMFCHandle
);
518 } else if ((nPortIndex
== OUTPUT_PORT_INDEX
) &&
519 (pMpeg2Dec
->bDestinationStart
== OMX_TRUE
)) {
520 Exynos_CodecBufferReset(pExynosComponent
, OUTPUT_PORT_INDEX
);
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]);
526 Exynos_CodecBufferEnQueue(pExynosComponent
, OUTPUT_PORT_INDEX
, pVideoDec
->pMFCDecOutputBuffer
[i
]);
528 pOutbufOps
->Clear_Queue(hMFCHandle
);
537 OMX_ERRORTYPE
Mpeg2CodecSrcSetup(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
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
;
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;
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
;
565 OMXBuffer
->nTimeStamp
= pSrcInputData
->timeStamp
;
566 OMXBuffer
->nFlags
= pSrcInputData
->nFlags
;
567 Exynos_OMX_OutputBufferReturn(pOMXComponent
, OMXBuffer
);
573 if (pVideoDec
->bThumbnailMode
== OMX_TRUE
)
574 pDecOps
->Set_DisplayDelay(hMFCHandle
, 0);
576 if ((pDecOps
->Enable_DTSMode
!= NULL
) &&
577 (pVideoDec
->bDTSMode
== OMX_TRUE
))
578 pDecOps
->Enable_DTSMode(hMFCHandle
);
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
;
593 /* should be done before prepare input buffer */
594 if (pInbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
595 ret
= OMX_ErrorInsufficientResources
;
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
;
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
;
613 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
614 ret
= Mpeg2CodecRegistCodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
);
615 if (ret
!= OMX_ErrorNone
)
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
;
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
;
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
;
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
;
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
;
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
);
672 pMpeg2Dec
->hMFCMpeg2Handle
.bConfiguredMFCSrc
= OMX_TRUE
;
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
;
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));
684 Exynos_UpdateFrameSize(pOMXComponent
);
686 /** Send Port Settings changed call back **/
687 (*(pExynosComponent
->pCallbacks
->EventHandler
))
689 pExynosComponent
->callbackData
,
690 OMX_EventPortSettingsChanged
, /* The command was completed */
691 OMX_DirOutput
, /* This is the port index */
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
;
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));
706 pExynosOutputPort
->portDefinition
.nBufferCountActual
= pMpeg2Dec
->hMFCMpeg2Handle
.maxDPBNum
- 2;
707 pExynosOutputPort
->portDefinition
.nBufferCountMin
= pMpeg2Dec
->hMFCMpeg2Handle
.maxDPBNum
- 2;
709 Exynos_UpdateFrameSize(pOMXComponent
);
711 /** Send Port Settings changed call back **/
712 (*(pExynosComponent
->pCallbacks
->EventHandler
))
714 pExynosComponent
->callbackData
,
715 OMX_EventPortSettingsChanged
, /* The command was completed */
716 OMX_DirOutput
, /* This is the port index */
721 Exynos_OSAL_SleepMillisec(0);
722 ret
= OMX_ErrorInputDataDecodeYet
;
723 Mpeg2CodecStop(pOMXComponent
, INPUT_PORT_INDEX
);
731 OMX_ERRORTYPE
Mpeg2CodecDstSetup(OMX_COMPONENTTYPE
*pOMXComponent
)
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
];
741 ExynosVideoDecOps
*pDecOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
;
742 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
743 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
747 OMX_U32 nAllocLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
748 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
752 nAllocLen
[0] = pMpeg2Dec
->hMFCMpeg2Handle
.codecOutbufConf
.nAlignPlaneSize
[0];
753 nAllocLen
[1] = pMpeg2Dec
->hMFCMpeg2Handle
.codecOutbufConf
.nAlignPlaneSize
[1];
755 pOutbufOps
->Set_Shareable(hMFCHandle
);
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
;
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
;
772 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, nOutbufs
, nAllocLen
);
773 if (ret
!= OMX_ErrorNone
)
776 ret
= Mpeg2CodecRegistCodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, nOutbufs
);
777 if (ret
!= OMX_ErrorNone
)
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
);
786 if (pOutbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
787 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run output buffer");
788 ret
= OMX_ErrorInsufficientResources
;
791 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
792 ExynosVideoPlane planes
[MFC_OUTPUT_BUFFER_PLANE
];
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
;
803 /* Register output buffer */
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
];
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
;
821 pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pExynosOutputPort
->extendBufferHeader
[i
].pYUVBuf
,
822 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
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
;
831 ret
= OMX_ErrorNotImplemented
;
835 ret
= OMX_ErrorNotImplemented
;
840 pMpeg2Dec
->hMFCMpeg2Handle
.bConfiguredMFCDst
= OMX_TRUE
;
850 OMX_ERRORTYPE
Exynos_Mpeg2Dec_GetParameter(
851 OMX_IN OMX_HANDLETYPE hComponent
,
852 OMX_IN OMX_INDEXTYPE nParamIndex
,
853 OMX_INOUT OMX_PTR pComponentParameterStructure
)
855 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
856 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
857 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
861 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
862 ret
= OMX_ErrorBadParameter
;
865 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
866 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
867 if (ret
!= OMX_ErrorNone
) {
870 if (pOMXComponent
->pComponentPrivate
== NULL
) {
871 ret
= OMX_ErrorBadParameter
;
875 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
876 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
877 ret
= OMX_ErrorInvalidState
;
881 switch (nParamIndex
) {
882 case OMX_IndexParamVideoMpeg2
:
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");
893 if (pDstMpeg2Param
->nPortIndex
> OUTPUT_PORT_INDEX
) {
894 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "2");
895 ret
= OMX_ErrorBadPortIndex
;
898 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
899 pSrcMpeg2Param
= &pMpeg2Dec
->Mpeg2Component
[pDstMpeg2Param
->nPortIndex
];
901 Exynos_OSAL_Memcpy(pDstMpeg2Param
, pSrcMpeg2Param
, sizeof(OMX_VIDEO_PARAM_MPEG2TYPE
));
904 case OMX_IndexParamStandardComponentRole
:
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
) {
912 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG2_DEC_ROLE
);
915 case OMX_IndexParamVideoProfileLevelCurrent
:
917 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
918 OMX_VIDEO_PARAM_MPEG2TYPE
*pSrcMpeg2Component
= NULL
;
919 EXYNOS_MPEG2DEC_HANDLE
*pMpeg2Dec
= NULL
;
921 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
922 if (ret
!= OMX_ErrorNone
) {
926 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
927 ret
= OMX_ErrorBadPortIndex
;
931 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
932 pSrcMpeg2Component
= &pMpeg2Dec
->Mpeg2Component
[pDstProfileLevel
->nPortIndex
];
934 pDstProfileLevel
->eProfile
= pSrcMpeg2Component
->eProfile
;
935 pDstProfileLevel
->eLevel
= pSrcMpeg2Component
->eLevel
;
938 case OMX_IndexParamVideoErrorCorrection
:
940 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
941 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= NULL
;
942 EXYNOS_MPEG2DEC_HANDLE
*pMpeg2Dec
= NULL
;
944 ret
= Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
945 if (ret
!= OMX_ErrorNone
) {
949 if (pDstErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
950 ret
= OMX_ErrorBadPortIndex
;
954 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
955 pSrcErrorCorrectionType
= &pMpeg2Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
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
;
965 ret
= Exynos_OMX_VideoDecodeGetParameter(hComponent
, nParamIndex
, pComponentParameterStructure
);
974 OMX_ERRORTYPE
Exynos_Mpeg2Dec_SetParameter(
975 OMX_IN OMX_HANDLETYPE hComponent
,
976 OMX_IN OMX_INDEXTYPE nIndex
,
977 OMX_IN OMX_PTR pComponentParameterStructure
)
979 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
980 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
981 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
985 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
986 ret
= OMX_ErrorBadParameter
;
989 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
990 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
991 if (ret
!= OMX_ErrorNone
) {
994 if (pOMXComponent
->pComponentPrivate
== NULL
) {
995 ret
= OMX_ErrorBadParameter
;
999 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1000 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1001 ret
= OMX_ErrorInvalidState
;
1006 case OMX_IndexParamVideoMpeg2
:
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
) {
1016 if (pSrcMpeg2Param
->nPortIndex
> OUTPUT_PORT_INDEX
) {
1017 ret
= OMX_ErrorBadPortIndex
;
1021 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1022 pDstMpeg2Param
= &pMpeg2Dec
->Mpeg2Component
[pSrcMpeg2Param
->nPortIndex
];
1024 Exynos_OSAL_Memcpy(pDstMpeg2Param
, pSrcMpeg2Param
, sizeof(OMX_VIDEO_PARAM_MPEG2TYPE
));
1027 case OMX_IndexParamStandardComponentRole
:
1029 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1031 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1032 if (ret
!= OMX_ErrorNone
) {
1036 if ((pExynosComponent
->currentState
!= OMX_StateLoaded
) && (pExynosComponent
->currentState
!= OMX_StateWaitForResources
)) {
1037 ret
= OMX_ErrorIncorrectStateOperation
;
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
;
1044 ret
= OMX_ErrorBadParameter
;
1049 case OMX_IndexParamVideoProfileLevelCurrent
:
1051 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pSrcProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1052 OMX_VIDEO_PARAM_MPEG2TYPE
*pDstMpeg2Component
= NULL
;
1053 EXYNOS_MPEG2DEC_HANDLE
*pMpeg2Dec
= NULL
;
1055 ret
= Exynos_OMX_Check_SizeVersion(pSrcProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1056 if (ret
!= OMX_ErrorNone
)
1059 if (pSrcProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1060 ret
= OMX_ErrorBadPortIndex
;
1064 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1066 pDstMpeg2Component
= &pMpeg2Dec
->Mpeg2Component
[pSrcProfileLevel
->nPortIndex
];
1067 pDstMpeg2Component
->eProfile
= pSrcProfileLevel
->eProfile
;
1068 pDstMpeg2Component
->eLevel
= pSrcProfileLevel
->eLevel
;
1071 case OMX_IndexParamVideoErrorCorrection
:
1073 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1074 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= NULL
;
1075 EXYNOS_MPEG2DEC_HANDLE
*pMpeg2Dec
= NULL
;
1077 ret
= Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1078 if (ret
!= OMX_ErrorNone
) {
1082 if (pSrcErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1083 ret
= OMX_ErrorBadPortIndex
;
1087 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1088 pDstErrorCorrectionType
= &pMpeg2Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
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
;
1098 ret
= Exynos_OMX_VideoDecodeSetParameter(hComponent
, nIndex
, pComponentParameterStructure
);
1107 OMX_ERRORTYPE
Exynos_Mpeg2Dec_GetConfig(
1108 OMX_HANDLETYPE hComponent
,
1109 OMX_INDEXTYPE nIndex
,
1110 OMX_PTR pComponentConfigStructure
)
1112 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1113 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1114 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1118 if (hComponent
== NULL
) {
1119 ret
= OMX_ErrorBadParameter
;
1122 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1123 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1124 if (ret
!= OMX_ErrorNone
) {
1127 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1128 ret
= OMX_ErrorBadParameter
;
1131 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1132 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1133 ret
= OMX_ErrorInvalidState
;
1139 ret
= Exynos_OMX_VideoDecodeGetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1149 OMX_ERRORTYPE
Exynos_Mpeg2Dec_SetConfig(
1150 OMX_HANDLETYPE hComponent
,
1151 OMX_INDEXTYPE nIndex
,
1152 OMX_PTR pComponentConfigStructure
)
1154 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1155 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1156 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1160 if (hComponent
== NULL
) {
1161 ret
= OMX_ErrorBadParameter
;
1164 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1165 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1166 if (ret
!= OMX_ErrorNone
) {
1169 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1170 ret
= OMX_ErrorBadParameter
;
1173 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1174 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1175 ret
= OMX_ErrorInvalidState
;
1181 ret
= Exynos_OMX_VideoDecodeSetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1191 OMX_ERRORTYPE
Exynos_Mpeg2Dec_GetExtensionIndex(
1192 OMX_IN OMX_HANDLETYPE hComponent
,
1193 OMX_IN OMX_STRING cParameterName
,
1194 OMX_OUT OMX_INDEXTYPE
*pIndexType
)
1196 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1197 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1198 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1202 if (hComponent
== NULL
) {
1203 ret
= OMX_ErrorBadParameter
;
1206 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1207 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1208 if (ret
!= OMX_ErrorNone
) {
1211 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1212 ret
= OMX_ErrorBadParameter
;
1215 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1216 if ((cParameterName
== NULL
) || (pIndexType
== NULL
)) {
1217 ret
= OMX_ErrorBadParameter
;
1220 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1221 ret
= OMX_ErrorInvalidState
;
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
;
1230 ret
= Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent
, cParameterName
, pIndexType
);
1239 OMX_ERRORTYPE
Exynos_Mpeg2Dec_ComponentRoleEnum(
1240 OMX_HANDLETYPE hComponent
,
1244 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1245 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1246 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1250 if ((hComponent
== NULL
) || (cRole
== NULL
)) {
1251 ret
= OMX_ErrorBadParameter
;
1254 if (nIndex
== (MAX_COMPONENT_ROLE_NUM
-1)) {
1255 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_MPEG2_DEC_ROLE
);
1256 ret
= OMX_ErrorNone
;
1258 ret
= OMX_ErrorNoMore
;
1268 OMX_ERRORTYPE
Exynos_Mpeg2Dec_Init(OMX_COMPONENTTYPE
*pOMXComponent
)
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
;
1278 ExynosVideoDecOps
*pDecOps
= NULL
;
1279 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
1280 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
1282 CSC_METHOD csc_method
= CSC_METHOD_SW
;
1287 pMpeg2Dec
->hMFCMpeg2Handle
.bConfiguredMFCSrc
= OMX_FALSE
;
1288 pMpeg2Dec
->hMFCMpeg2Handle
.bConfiguredMFCDst
= OMX_FALSE
;
1289 pExynosComponent
->bUseFlagEOF
= OMX_TRUE
;
1290 pExynosComponent
->bSaveFlagEOS
= OMX_FALSE
;
1292 /* Mpeg2 Codec Open */
1293 ret
= Mpeg2CodecOpen(pMpeg2Dec
);
1294 if (ret
!= OMX_ErrorNone
) {
1298 pDecOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
;
1299 pInbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
1300 pOutbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
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
)
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
) {
1316 /* Does not require any actions. */
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
) {
1326 /* Does not require any actions. */
1329 pMpeg2Dec
->bSourceStart
= OMX_FALSE
;
1330 Exynos_OSAL_SignalCreate(&pMpeg2Dec
->hSourceStartEvent
);
1331 pMpeg2Dec
->bDestinationStart
= OMX_FALSE
;
1332 Exynos_OSAL_SignalCreate(&pMpeg2Dec
->hDestinationStartEvent
);
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;
1339 pExynosComponent
->getAllDelayBuffer
= OMX_FALSE
;
1342 csc_method
= CSC_METHOD_HW
;
1344 pVideoDec
->csc_handle
= csc_init(csc_method
);
1345 if (pVideoDec
->csc_handle
== NULL
) {
1346 ret
= OMX_ErrorInsufficientResources
;
1349 pVideoDec
->csc_set_format
= OMX_FALSE
;
1358 OMX_ERRORTYPE
Exynos_Mpeg2Dec_Terminate(OMX_COMPONENTTYPE
*pOMXComponent
)
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
;
1368 ExynosVideoDecOps
*pDecOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pDecOps
;
1369 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pInbufOps
;
1370 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg2Dec
->hMFCMpeg2Handle
.pOutbufOps
;
1376 if (pVideoDec
->csc_handle
!= NULL
) {
1377 csc_deinit(pVideoDec
->csc_handle
);
1378 pVideoDec
->csc_handle
= NULL
;
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
;
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
) {
1396 /* Does not require any actions. */
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
) {
1407 /* Does not require any actions. */
1409 Mpeg2CodecClose(pMpeg2Dec
);
1417 OMX_ERRORTYPE
Exynos_Mpeg2Dec_SrcIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
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
;
1436 if (pMpeg2Dec
->hMFCMpeg2Handle
.bConfiguredMFCSrc
== OMX_FALSE
) {
1437 ret
= Mpeg2CodecSrcSetup(pOMXComponent
, pSrcInputData
);
1440 if (pMpeg2Dec
->hMFCMpeg2Handle
.bConfiguredMFCDst
== OMX_FALSE
) {
1441 ret
= Mpeg2CodecDstSetup(pOMXComponent
);
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
;
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__
);
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);
1468 if (pMpeg2Dec
->bDestinationStart
== OMX_FALSE
) {
1469 pMpeg2Dec
->bDestinationStart
= OMX_TRUE
;
1470 Exynos_OSAL_SignalSet(pMpeg2Dec
->hDestinationStartEvent
);
1471 Exynos_OSAL_SleepMillisec(0);
1473 } else if (bInStartCode
== OMX_FALSE
) {
1474 ret
= OMX_ErrorCorruptedFrame
;
1478 ret
= OMX_ErrorNone
;
1486 OMX_ERRORTYPE
Exynos_Mpeg2Dec_SrcOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
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
;
1500 pVideoBuffer
= pInbufOps
->Dequeue(hMFCHandle
);
1502 pSrcOutputData
->dataLen
= 0;
1503 pSrcOutputData
->usedDataLen
= 0;
1504 pSrcOutputData
->remainDataLen
= 0;
1505 pSrcOutputData
->nFlags
= 0;
1506 pSrcOutputData
->timeStamp
= 0;
1508 if (pVideoBuffer
== NULL
) {
1509 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= NULL
;
1510 pSrcOutputData
->allocSize
= 0;
1511 pSrcOutputData
->pPrivate
= NULL
;
1512 pSrcOutputData
->bufferHeader
= NULL
;
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
;
1518 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
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
];
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
;
1536 /* For Share Buffer */
1537 pSrcOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
1540 ret
= OMX_ErrorNone
;
1548 OMX_ERRORTYPE
Exynos_Mpeg2Dec_DstIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
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
;
1563 if (pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] == NULL
) {
1564 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to find input buffer");
1565 ret
= OMX_ErrorBadParameter
;
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]);
1573 codecReturn
= pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
,
1574 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, pDstInputData
->bufferHeader
);
1576 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1577 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1578 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1581 Mpeg2CodecStart(pOMXComponent
, OUTPUT_PORT_INDEX
);
1583 ret
= OMX_ErrorNone
;
1591 OMX_ERRORTYPE
Exynos_Mpeg2Dec_DstOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
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;
1611 if (pMpeg2Dec
->bDestinationStart
== OMX_FALSE
) {
1612 ret
= OMX_ErrorNone
;
1617 if ((pVideoBuffer
= pOutbufOps
->Dequeue(hMFCHandle
)) == NULL
) {
1618 ret
= OMX_ErrorNone
;
1621 displayStatus
= pVideoBuffer
->displayStatus
;
1622 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus: 0x%x", displayStatus
);
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
;
1634 pMpeg2Dec
->hMFCMpeg2Handle
.outputIndexTimestamp
++;
1635 pMpeg2Dec
->hMFCMpeg2Handle
.outputIndexTimestamp
%= MAX_TIMESTAMP
;
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
;
1644 pDstOutputData
->usedDataLen
= 0;
1645 pDstOutputData
->pPrivate
= pVideoBuffer
;
1646 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
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
];
1657 if (pDstOutputData
->pPrivate
== NULL
) {
1658 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
1659 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1664 /* For Share Buffer */
1665 pDstOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
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
;
1675 case VIDEO_COLORFORMAT_NV12_TILED
:
1677 pBufferInfo
->ColorFormat
= OMX_SEC_COLOR_FormatNV12Tiled
;
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;
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
);
1695 pDstOutputData
->timeStamp
= 0x00;
1696 pDstOutputData
->nFlags
= 0x00;
1699 /* For timestamp correction. if mfc support frametype detect */
1700 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "disp_pic_frame_type: %d", pVideoBuffer
->frameType
);
1702 /* NEED TIMESTAMP REORDER */
1703 if (pVideoDec
->bDTSMode
== OMX_TRUE
) {
1704 if (pVideoBuffer
->frameType
== VIDEO_FRAME_I
)
1705 pMpeg2Dec
->hMFCMpeg2Handle
.outputIndexTimestamp
= indexTimestamp
;
1707 indexTimestamp
= pMpeg2Dec
->hMFCMpeg2Handle
.outputIndexTimestamp
;
1710 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
1711 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
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
);
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;
1722 pDstOutputData
->remainDataLen
= bufferGeometry
->nFrameWidth
* bufferGeometry
->nFrameHeight
* 3 / 2;
1725 ret
= OMX_ErrorNone
;
1733 OMX_ERRORTYPE
Exynos_Mpeg2Dec_srcInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
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
];
1742 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
1743 ret
= OMX_ErrorNone
;
1746 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
1747 ret
= OMX_ErrorNone
;
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
);
1766 OMX_ERRORTYPE
Exynos_Mpeg2Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
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
];
1775 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
1776 ret
= OMX_ErrorNone
;
1780 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1781 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
1782 ret
= OMX_ErrorNone
;
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
);
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
);
1806 OMX_ERRORTYPE
Exynos_Mpeg2Dec_dstInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
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
];
1815 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
1816 ret
= OMX_ErrorNone
;
1819 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
1820 ret
= OMX_ErrorNone
;
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
);
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
);
1845 OMX_ERRORTYPE
Exynos_Mpeg2Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
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
];
1854 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
1855 ret
= OMX_ErrorNone
;
1858 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
1859 ret
= OMX_ErrorNone
;
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
);
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
);
1884 OSCL_EXPORT_REF OMX_ERRORTYPE
Exynos_OMX_ComponentInit(
1885 OMX_HANDLETYPE hComponent
,
1886 OMX_STRING componentName
)
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
;
1898 if ((hComponent
== NULL
) || (componentName
== NULL
)) {
1899 ret
= OMX_ErrorBadParameter
;
1900 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
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__
);
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__
);
1915 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1916 pExynosComponent
->codecType
= HW_VIDEO_DEC_CODEC
;
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__
);
1925 Exynos_OSAL_Memset(pExynosComponent
->componentName
, 0, MAX_OMX_COMPONENT_NAME_SIZE
);
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__
);
1934 Exynos_OSAL_Memset(pMpeg2Dec
, 0, sizeof(EXYNOS_MPEG2DEC_HANDLE
));
1935 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1936 pVideoDec
->hCodecHandle
= (OMX_HANDLETYPE
)pMpeg2Dec
;
1938 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_MPEG2_DEC
);
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
;
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
;
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
;
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**** */
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
;
2001 pExynosComponent
->exynos_codec_componentInit
= &Exynos_Mpeg2Dec_Init
;
2002 pExynosComponent
->exynos_codec_componentTerminate
= &Exynos_Mpeg2Dec_Terminate
;
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
;
2009 pVideoDec
->exynos_codec_start
= &Mpeg2CodecStart
;
2010 pVideoDec
->exynos_codec_stop
= &Mpeg2CodecStop
;
2011 pVideoDec
->exynos_codec_bufferProcessRun
= &Mpeg2CodecOutputBufferProcessRun
;
2012 pVideoDec
->exynos_codec_enqueueAllBuffer
= &Mpeg2CodecEnQueueAllBuffer
;
2014 pVideoDec
->exynos_checkInputFrame
= &Check_Mpeg2_Frame
;
2015 pVideoDec
->exynos_codec_getCodecInputPrivateData
= &GetCodecInputPrivateData
;
2016 pVideoDec
->exynos_codec_getCodecOutputPrivateData
= &GetCodecOutputPrivateData
;
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
;
2028 pExynosComponent
->currentState
= OMX_StateLoaded
;
2030 ret
= OMX_ErrorNone
;
2038 OMX_ERRORTYPE
Exynos_OMX_ComponentDeinit(
2039 OMX_HANDLETYPE hComponent
)
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
;
2049 if (hComponent
== NULL
) {
2050 ret
= OMX_ErrorBadParameter
;
2053 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2054 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2055 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2057 Exynos_OSAL_SharedMemory_Close(pVideoDec
->hSharedMemory
);
2059 Exynos_OSAL_Free(pExynosComponent
->componentName
);
2060 pExynosComponent
->componentName
= NULL
;
2062 pMpeg2Dec
= (EXYNOS_MPEG2DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
2063 if (pMpeg2Dec
!= NULL
) {
2064 Exynos_OSAL_Free(pMpeg2Dec
);
2065 pMpeg2Dec
= pVideoDec
->hCodecHandle
= NULL
;
2068 ret
= Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2069 if (ret
!= OMX_ErrorNone
) {
2073 ret
= OMX_ErrorNone
;