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_Mpeg4dec.c
21 * @author Yunji Kim (yunji.kim@samsung.com)
22 * @author SeungBeom Kim (sbcrux.kim@samsung.com)
32 #include "Exynos_OMX_Macros.h"
33 #include "Exynos_OMX_Basecomponent.h"
34 #include "Exynos_OMX_Baseport.h"
35 #include "Exynos_OMX_Vdec.h"
36 #include "Exynos_OSAL_ETC.h"
37 #include "Exynos_OSAL_Semaphore.h"
38 #include "Exynos_OSAL_Thread.h"
39 #include "library_register.h"
40 #include "Exynos_OMX_Mpeg4dec.h"
41 #include "ExynosVideoApi.h"
42 #include "Exynos_OSAL_SharedMemory.h"
43 #include "Exynos_OSAL_Event.h"
46 #include "Exynos_OSAL_Android.h"
49 /* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */
50 /* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
54 #define EXYNOS_LOG_TAG "EXYNOS_MPEG4_DEC"
55 #define EXYNOS_LOG_OFF
56 //#define EXYNOS_TRACE_ON
57 #include "Exynos_OSAL_Log.h"
59 #define MPEG4_DEC_NUM_OF_EXTRA_BUFFERS 7
61 //#define FULL_FRAME_SEARCH
63 /* MPEG4 Decoder Supported Levels & profiles */
64 EXYNOS_OMX_VIDEO_PROFILELEVEL supportedMPEG4ProfileLevels
[] ={
65 {OMX_VIDEO_MPEG4ProfileSimple
, OMX_VIDEO_MPEG4Level0
},
66 {OMX_VIDEO_MPEG4ProfileSimple
, OMX_VIDEO_MPEG4Level0b
},
67 {OMX_VIDEO_MPEG4ProfileSimple
, OMX_VIDEO_MPEG4Level1
},
68 {OMX_VIDEO_MPEG4ProfileSimple
, OMX_VIDEO_MPEG4Level2
},
69 {OMX_VIDEO_MPEG4ProfileSimple
, OMX_VIDEO_MPEG4Level3
},
70 {OMX_VIDEO_MPEG4ProfileSimple
, OMX_VIDEO_MPEG4Level4
},
71 {OMX_VIDEO_MPEG4ProfileSimple
, OMX_VIDEO_MPEG4Level4a
},
72 {OMX_VIDEO_MPEG4ProfileSimple
, OMX_VIDEO_MPEG4Level5
},
73 {OMX_VIDEO_MPEG4ProfileAdvancedSimple
, OMX_VIDEO_MPEG4Level0
},
74 {OMX_VIDEO_MPEG4ProfileAdvancedSimple
, OMX_VIDEO_MPEG4Level0b
},
75 {OMX_VIDEO_MPEG4ProfileAdvancedSimple
, OMX_VIDEO_MPEG4Level1
},
76 {OMX_VIDEO_MPEG4ProfileAdvancedSimple
, OMX_VIDEO_MPEG4Level2
},
77 {OMX_VIDEO_MPEG4ProfileAdvancedSimple
, OMX_VIDEO_MPEG4Level3
},
78 {OMX_VIDEO_MPEG4ProfileAdvancedSimple
, OMX_VIDEO_MPEG4Level4
},
79 {OMX_VIDEO_MPEG4ProfileAdvancedSimple
, OMX_VIDEO_MPEG4Level4a
},
80 {OMX_VIDEO_MPEG4ProfileAdvancedSimple
, OMX_VIDEO_MPEG4Level5
}};
82 /* H.263 Decoder Supported Levels & profiles */
83 EXYNOS_OMX_VIDEO_PROFILELEVEL supportedH263ProfileLevels
[] = {
84 /* Baseline (Profile 0) */
85 {OMX_VIDEO_H263ProfileBaseline
, OMX_VIDEO_H263Level10
},
86 {OMX_VIDEO_H263ProfileBaseline
, OMX_VIDEO_H263Level20
},
87 {OMX_VIDEO_H263ProfileBaseline
, OMX_VIDEO_H263Level30
},
88 {OMX_VIDEO_H263ProfileBaseline
, OMX_VIDEO_H263Level40
},
89 {OMX_VIDEO_H263ProfileBaseline
, OMX_VIDEO_H263Level45
},
90 {OMX_VIDEO_H263ProfileBaseline
, OMX_VIDEO_H263Level50
},
91 {OMX_VIDEO_H263ProfileBaseline
, OMX_VIDEO_H263Level60
},
92 {OMX_VIDEO_H263ProfileBaseline
, OMX_VIDEO_H263Level70
},
94 {OMX_VIDEO_H263ProfileH320Coding
, OMX_VIDEO_H263Level10
},
95 {OMX_VIDEO_H263ProfileH320Coding
, OMX_VIDEO_H263Level20
},
96 {OMX_VIDEO_H263ProfileH320Coding
, OMX_VIDEO_H263Level30
},
97 {OMX_VIDEO_H263ProfileH320Coding
, OMX_VIDEO_H263Level40
},
98 {OMX_VIDEO_H263ProfileH320Coding
, OMX_VIDEO_H263Level45
},
99 {OMX_VIDEO_H263ProfileH320Coding
, OMX_VIDEO_H263Level50
},
100 {OMX_VIDEO_H263ProfileH320Coding
, OMX_VIDEO_H263Level60
},
101 {OMX_VIDEO_H263ProfileH320Coding
, OMX_VIDEO_H263Level70
},
103 {OMX_VIDEO_H263ProfileBackwardCompatible
, OMX_VIDEO_H263Level10
},
104 {OMX_VIDEO_H263ProfileBackwardCompatible
, OMX_VIDEO_H263Level20
},
105 {OMX_VIDEO_H263ProfileBackwardCompatible
, OMX_VIDEO_H263Level30
},
106 {OMX_VIDEO_H263ProfileBackwardCompatible
, OMX_VIDEO_H263Level40
},
107 {OMX_VIDEO_H263ProfileBackwardCompatible
, OMX_VIDEO_H263Level45
},
108 {OMX_VIDEO_H263ProfileBackwardCompatible
, OMX_VIDEO_H263Level50
},
109 {OMX_VIDEO_H263ProfileBackwardCompatible
, OMX_VIDEO_H263Level60
},
110 {OMX_VIDEO_H263ProfileBackwardCompatible
, OMX_VIDEO_H263Level70
},
111 /* Profile 3, restricted up to SD resolution */
112 {OMX_VIDEO_H263ProfileISWV2
, OMX_VIDEO_H263Level10
},
113 {OMX_VIDEO_H263ProfileISWV2
, OMX_VIDEO_H263Level20
},
114 {OMX_VIDEO_H263ProfileISWV2
, OMX_VIDEO_H263Level30
},
115 {OMX_VIDEO_H263ProfileISWV2
, OMX_VIDEO_H263Level40
},
116 {OMX_VIDEO_H263ProfileISWV2
, OMX_VIDEO_H263Level45
},
117 {OMX_VIDEO_H263ProfileISWV2
, OMX_VIDEO_H263Level50
},
118 {OMX_VIDEO_H263ProfileISWV2
, OMX_VIDEO_H263Level60
},
119 {OMX_VIDEO_H263ProfileISWV2
, OMX_VIDEO_H263Level70
}};
122 static OMX_ERRORTYPE
GetCodecInputPrivateData(OMX_PTR codecBuffer
, void *pVirtAddr
, OMX_U32
*dataSize
)
124 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
130 static OMX_ERRORTYPE
GetCodecOutputPrivateData(OMX_PTR codecBuffer
, void *addr
[], int size
[])
132 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
133 ExynosVideoBuffer
*pCodecBuffer
;
135 if (codecBuffer
== NULL
) {
136 ret
= OMX_ErrorBadParameter
;
140 pCodecBuffer
= (ExynosVideoBuffer
*)codecBuffer
;
143 addr
[0] = pCodecBuffer
->planes
[0].addr
;
144 addr
[1] = pCodecBuffer
->planes
[1].addr
;
145 addr
[2] = pCodecBuffer
->planes
[2].addr
;
149 size
[0] = pCodecBuffer
->planes
[0].allocSize
;
150 size
[1] = pCodecBuffer
->planes
[1].allocSize
;
151 size
[2] = pCodecBuffer
->planes
[2].allocSize
;
158 static OMX_BOOL gbFIMV1
= OMX_FALSE
;
160 static int Check_Mpeg4_Frame(
161 OMX_U8
*pInputStream
,
164 OMX_BOOL bPreviousFrameEOF
,
165 OMX_BOOL
*pbEndOfFrame
)
170 OMX_BOOL bFrameStart
;
173 bFrameStart
= OMX_FALSE
;
175 if (flag
& OMX_BUFFERFLAG_CODECCONFIG
) {
176 if (*pInputStream
== 0x03) { /* FIMV1 */
177 BitmapInfoHhr
*pInfoHeader
;
179 pInfoHeader
= (BitmapInfoHhr
*)(pInputStream
+ 1);
181 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "############## NOT SUPPORTED #################");
182 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "width(%d), height(%d)", pInfoHeader
->BiWidth
, pInfoHeader
->BiHeight
);
184 *pbEndOfFrame
= OMX_TRUE
;
190 *pbEndOfFrame
= OMX_TRUE
;
194 if (bPreviousFrameEOF
== OMX_FALSE
)
195 bFrameStart
= OMX_TRUE
;
197 startCode
= 0xFFFFFFFF;
198 if (bFrameStart
== OMX_FALSE
) {
199 /* find VOP start code */
200 while(startCode
!= 0x1B6) {
201 readStream
= *(pInputStream
+ len
);
202 startCode
= (startCode
<< 8) | readStream
;
209 /* find next VOP start code */
210 startCode
= 0xFFFFFFFF;
211 while ((startCode
!= 0x1B6)) {
212 readStream
= *(pInputStream
+ len
);
213 startCode
= (startCode
<< 8) | readStream
;
219 *pbEndOfFrame
= OMX_TRUE
;
221 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "1. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame
, len
- 4, buffSize
);
226 *pbEndOfFrame
= OMX_FALSE
;
228 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "2. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame
, len
- 1, buffSize
);
233 static int Check_H263_Frame(
234 OMX_U8
*pInputStream
,
237 OMX_BOOL bPreviousFrameEOF
,
238 OMX_BOOL
*pbEndOfFrame
)
243 OMX_BOOL bFrameStart
= 0;
244 unsigned pTypeMask
= 0x03;
248 bFrameStart
= OMX_FALSE
;
250 if (bPreviousFrameEOF
== OMX_FALSE
)
251 bFrameStart
= OMX_TRUE
;
253 startCode
= 0xFFFFFFFF;
254 if (bFrameStart
== OMX_FALSE
) {
255 /* find PSC(Picture Start Code) : 0000 0000 0000 0000 1000 00 */
256 while (((startCode
<< 8 >> 10) != 0x20) || (pType
!= 0x02)) {
257 readStream
= *(pInputStream
+ len
);
258 startCode
= (startCode
<< 8) | readStream
;
260 readStream
= *(pInputStream
+ len
+ 1);
261 pType
= readStream
& pTypeMask
;
270 startCode
= 0xFFFFFFFF;
272 while (((startCode
<< 8 >> 10) != 0x20) || (pType
!= 0x02)) {
273 readStream
= *(pInputStream
+ len
);
274 startCode
= (startCode
<< 8) | readStream
;
276 readStream
= *(pInputStream
+ len
+ 1);
277 pType
= readStream
& pTypeMask
;
284 *pbEndOfFrame
= OMX_TRUE
;
286 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "1. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame
, len
- 3, buffSize
);
292 *pbEndOfFrame
= OMX_FALSE
;
294 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "2. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame
, len
- 1, buffSize
);
299 static OMX_BOOL
Check_Stream_StartCode(
300 OMX_U8
*pInputStream
,
302 CODEC_TYPE codecType
)
305 case CODEC_TYPE_MPEG4
:
309 if (streamSize
< 3) {
311 } else if ((pInputStream
[0] == 0x00) &&
312 (pInputStream
[1] == 0x00) &&
313 (pInputStream
[2] == 0x01)) {
320 case CODEC_TYPE_H263
:
321 if (streamSize
> 0) {
322 unsigned startCode
= 0xFFFFFFFF;
323 unsigned pTypeMask
= 0x03;
327 /* Check PSC(Picture Start Code) : 0000 0000 0000 0000 1000 00 */
328 while (((startCode
<< 8 >> 10) != 0x20) || (pType
!= 0x02)) {
329 readStream
= *(pInputStream
+ len
);
330 startCode
= (startCode
<< 8) | readStream
;
332 readStream
= *(pInputStream
+ len
+ 1);
333 pType
= readStream
& pTypeMask
;
341 Exynos_OSAL_Log(EXYNOS_LOG_WARNING
, "[%s] Picture Start Code Missing", __FUNCTION__
);
350 Exynos_OSAL_Log(EXYNOS_LOG_WARNING
, "%s: undefined codec type (%d)", __FUNCTION__
, codecType
);
355 OMX_ERRORTYPE
Mpeg4CodecOpen(EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
)
357 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
358 ExynosVideoDecOps
*pDecOps
= NULL
;
359 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
360 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
364 if (pMpeg4Dec
== NULL
) {
365 ret
= OMX_ErrorBadParameter
;
366 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
370 /* alloc ops structure */
371 pDecOps
= (ExynosVideoDecOps
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecOps
));
372 pInbufOps
= (ExynosVideoDecBufferOps
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecBufferOps
));
373 pOutbufOps
= (ExynosVideoDecBufferOps
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecBufferOps
));
375 if ((pDecOps
== NULL
) || (pInbufOps
== NULL
) || (pOutbufOps
== NULL
)) {
376 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to allocate decoder ops buffer");
377 ret
= OMX_ErrorInsufficientResources
;
381 pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
= pDecOps
;
382 pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
= pInbufOps
;
383 pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
= pOutbufOps
;
385 /* function pointer mapping */
386 pDecOps
->nSize
= sizeof(ExynosVideoDecOps
);
387 pInbufOps
->nSize
= sizeof(ExynosVideoDecBufferOps
);
388 pOutbufOps
->nSize
= sizeof(ExynosVideoDecBufferOps
);
390 Exynos_Video_Register_Decoder(pDecOps
, pInbufOps
, pOutbufOps
);
392 /* check mandatory functions for decoder ops */
393 if ((pDecOps
->Init
== NULL
) || (pDecOps
->Finalize
== NULL
) ||
394 (pDecOps
->Get_ActualBufferCount
== NULL
) || (pDecOps
->Set_FrameTag
== NULL
) ||
395 (pDecOps
->Get_FrameTag
== NULL
)) {
396 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Mandatory functions must be supplied");
397 ret
= OMX_ErrorInsufficientResources
;
401 /* check mandatory functions for buffer ops */
402 if ((pInbufOps
->Setup
== NULL
) || (pOutbufOps
->Setup
== NULL
) ||
403 (pInbufOps
->Run
== NULL
) || (pOutbufOps
->Run
== NULL
) ||
404 (pInbufOps
->Stop
== NULL
) || (pOutbufOps
->Stop
== NULL
) ||
405 (pInbufOps
->Enqueue
== NULL
) || (pOutbufOps
->Enqueue
== NULL
) ||
406 (pInbufOps
->Dequeue
== NULL
) || (pOutbufOps
->Dequeue
== NULL
)) {
407 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Mandatory functions must be supplied");
408 ret
= OMX_ErrorInsufficientResources
;
412 /* alloc context, open, querycap */
414 pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
->Init(V4L2_MEMORY_DMABUF
);
416 pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
->Init(V4L2_MEMORY_USERPTR
);
418 if (pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
== NULL
) {
419 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to allocate context buffer");
420 ret
= OMX_ErrorInsufficientResources
;
427 if (ret
!= OMX_ErrorNone
) {
428 if (pDecOps
!= NULL
) {
429 Exynos_OSAL_Free(pDecOps
);
430 pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
= NULL
;
432 if (pInbufOps
!= NULL
) {
433 Exynos_OSAL_Free(pInbufOps
);
434 pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
= NULL
;
436 if (pOutbufOps
!= NULL
) {
437 Exynos_OSAL_Free(pOutbufOps
);
438 pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
= NULL
;
447 OMX_ERRORTYPE
Mpeg4CodecClose(EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
)
449 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
450 void *hMFCHandle
= NULL
;
451 ExynosVideoDecOps
*pDecOps
= NULL
;
452 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
453 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
457 if (pMpeg4Dec
== NULL
) {
458 ret
= OMX_ErrorBadParameter
;
462 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
463 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
464 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
465 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
467 if (hMFCHandle
!= NULL
) {
468 pDecOps
->Finalize(hMFCHandle
);
469 pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
= NULL
;
471 if (pOutbufOps
!= NULL
) {
472 Exynos_OSAL_Free(pOutbufOps
);
473 pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
= NULL
;
475 if (pInbufOps
!= NULL
) {
476 Exynos_OSAL_Free(pInbufOps
);
477 pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
= NULL
;
479 if (pDecOps
!= NULL
) {
480 Exynos_OSAL_Free(pDecOps
);
481 pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
= NULL
;
492 OMX_ERRORTYPE
Mpeg4CodecStart(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
494 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
495 void *hMFCHandle
= NULL
;
496 ExynosVideoDecOps
*pDecOps
= NULL
;
497 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
498 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
499 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
500 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
504 if (pOMXComponent
== NULL
) {
505 ret
= OMX_ErrorBadParameter
;
509 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
510 if (pVideoDec
== NULL
) {
511 ret
= OMX_ErrorBadParameter
;
515 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
516 if (pMpeg4Dec
== NULL
) {
517 ret
= OMX_ErrorBadParameter
;
521 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
522 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
523 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
524 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
526 if (nPortIndex
== INPUT_PORT_INDEX
)
527 pInbufOps
->Run(hMFCHandle
);
528 else if (nPortIndex
== OUTPUT_PORT_INDEX
)
529 pOutbufOps
->Run(hMFCHandle
);
539 OMX_ERRORTYPE
Mpeg4CodecStop(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
541 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
542 void *hMFCHandle
= NULL
;
543 ExynosVideoDecOps
*pDecOps
= NULL
;
544 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
545 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
546 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
547 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
551 if (pOMXComponent
== NULL
) {
552 ret
= OMX_ErrorBadParameter
;
556 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
557 if (pVideoDec
== NULL
) {
558 ret
= OMX_ErrorBadParameter
;
561 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
562 if (pMpeg4Dec
== NULL
) {
563 ret
= OMX_ErrorBadParameter
;
567 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
568 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
569 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
570 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
572 if ((nPortIndex
== INPUT_PORT_INDEX
) && (pInbufOps
!= NULL
))
573 pInbufOps
->Stop(hMFCHandle
);
574 else if ((nPortIndex
== OUTPUT_PORT_INDEX
) && (pOutbufOps
!= NULL
))
575 pOutbufOps
->Stop(hMFCHandle
);
585 OMX_ERRORTYPE
Mpeg4CodecOutputBufferProcessRun(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
587 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
588 void *hMFCHandle
= NULL
;
589 ExynosVideoDecOps
*pDecOps
= NULL
;
590 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
591 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
592 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
593 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
597 if (pOMXComponent
== NULL
) {
598 ret
= OMX_ErrorBadParameter
;
602 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
603 if (pVideoDec
== NULL
) {
604 ret
= OMX_ErrorBadParameter
;
607 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
608 if (pMpeg4Dec
== NULL
) {
609 ret
= OMX_ErrorBadParameter
;
613 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
614 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
615 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
616 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
618 if (nPortIndex
== INPUT_PORT_INDEX
) {
619 if (pMpeg4Dec
->bSourceStart
== OMX_FALSE
) {
620 Exynos_OSAL_SignalSet(pMpeg4Dec
->hSourceStartEvent
);
621 Exynos_OSAL_SleepMillisec(0);
625 if (nPortIndex
== OUTPUT_PORT_INDEX
) {
626 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
627 Exynos_OSAL_SignalSet(pMpeg4Dec
->hDestinationStartEvent
);
628 Exynos_OSAL_SleepMillisec(0);
640 OMX_ERRORTYPE
Mpeg4CodecRegistCodecBuffers(
641 OMX_COMPONENTTYPE
*pOMXComponent
,
645 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
646 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
647 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
648 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
649 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
650 CODEC_DEC_BUFFER
**ppCodecBuffer
= NULL
;
651 ExynosVideoDecBufferOps
*pBufOps
= NULL
;
652 ExynosVideoPlane
*pPlanes
= NULL
;
654 OMX_U32 nPlaneCnt
= 0;
659 if (nPortIndex
== INPUT_PORT_INDEX
) {
660 ppCodecBuffer
= &(pVideoDec
->pMFCDecInputBuffer
[0]);
661 nPlaneCnt
= MFC_INPUT_BUFFER_PLANE
;
662 pBufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
664 ppCodecBuffer
= &(pVideoDec
->pMFCDecOutputBuffer
[0]);
665 nPlaneCnt
= MFC_OUTPUT_BUFFER_PLANE
;
666 pBufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
669 pPlanes
= (ExynosVideoPlane
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane
) * nPlaneCnt
);
670 if (pPlanes
== NULL
) {
671 ret
= OMX_ErrorInsufficientResources
;
675 /* Register buffer */
676 for (i
= 0; i
< nBufferCnt
; i
++) {
677 for (j
= 0; j
< nPlaneCnt
; j
++) {
678 pPlanes
[j
].addr
= ppCodecBuffer
[i
]->pVirAddr
[j
];
679 pPlanes
[j
].fd
= ppCodecBuffer
[i
]->fd
[j
];
680 pPlanes
[j
].allocSize
= ppCodecBuffer
[i
]->bufferSize
[j
];
683 if (pBufOps
->Register(hMFCHandle
, pPlanes
, nPlaneCnt
) != VIDEO_ERROR_NONE
) {
684 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "PORT[%d]: Failed to Register buffer", nPortIndex
);
685 ret
= OMX_ErrorInsufficientResources
;
686 Exynos_OSAL_Free(pPlanes
);
691 Exynos_OSAL_Free(pPlanes
);
701 OMX_ERRORTYPE
Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
703 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
704 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
705 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
706 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
707 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
708 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
709 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
712 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
713 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
714 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
718 if ((nPortIndex
!= INPUT_PORT_INDEX
) && (nPortIndex
!= OUTPUT_PORT_INDEX
)) {
719 ret
= OMX_ErrorBadPortIndex
;
723 if ((nPortIndex
== INPUT_PORT_INDEX
) &&
724 (pMpeg4Dec
->bSourceStart
== OMX_TRUE
)) {
725 Exynos_CodecBufferReset(pExynosComponent
, INPUT_PORT_INDEX
);
727 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
728 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]);
729 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[0]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]);
731 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
734 pInbufOps
->Clear_Queue(hMFCHandle
);
735 } else if ((nPortIndex
== OUTPUT_PORT_INDEX
) &&
736 (pMpeg4Dec
->bDestinationStart
== OMX_TRUE
)) {
737 Exynos_CodecBufferReset(pExynosComponent
, OUTPUT_PORT_INDEX
);
739 for (i
= 0; i
< pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
; i
++) {
740 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecOutputBuffer[%d]: 0x%x", i
, pVideoDec
->pMFCDecOutputBuffer
[i
]);
741 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecOutputBuffer[%d]->pVirAddr[0]: 0x%x", i
, pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[0]);
743 Exynos_CodecBufferEnQueue(pExynosComponent
, OUTPUT_PORT_INDEX
, pVideoDec
->pMFCDecOutputBuffer
[i
]);
745 pOutbufOps
->Clear_Queue(hMFCHandle
);
754 OMX_ERRORTYPE
Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
756 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
757 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
758 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
759 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
760 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
761 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
762 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
763 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
765 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
766 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
767 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
768 ExynosVideoGeometry bufferConf
;
769 OMX_U32 inputBufferNumber
= 0;
774 if ((oneFrameSize
<= 0) && (pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
)) {
775 OMX_BUFFERHEADERTYPE
*OMXBuffer
= NULL
;
776 OMXBuffer
= Exynos_OutputBufferGetQueue_Direct(pExynosComponent
);
777 if (OMXBuffer
== NULL
) {
778 ret
= OMX_ErrorUndefined
;
782 OMXBuffer
->nTimeStamp
= pSrcInputData
->timeStamp
;
783 OMXBuffer
->nFlags
= pSrcInputData
->nFlags
;
784 Exynos_OMX_OutputBufferReturn(pOMXComponent
, OMXBuffer
);
790 if (pVideoDec
->bThumbnailMode
== OMX_TRUE
)
791 pDecOps
->Set_DisplayDelay(hMFCHandle
, 0);
793 /* input buffer info */
794 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
795 if (pMpeg4Dec
->hMFCMpeg4Handle
.codecType
== CODEC_TYPE_MPEG4
)
796 bufferConf
.eCompressionFormat
= VIDEO_CODING_MPEG4
;
798 bufferConf
.eCompressionFormat
= VIDEO_CODING_H263
;
800 pInbufOps
->Set_Shareable(hMFCHandle
);
801 if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
802 bufferConf
.nSizeImage
= pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
803 * pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
* 3 / 2;
804 inputBufferNumber
= MAX_VIDEO_INPUTBUFFER_NUM
;
805 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
806 bufferConf
.nSizeImage
= DEFAULT_MFC_INPUT_BUFFER_SIZE
;
807 inputBufferNumber
= MFC_INPUT_BUFFER_NUM_MAX
;
810 /* should be done before prepare input buffer */
811 if (pInbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
812 ret
= OMX_ErrorInsufficientResources
;
816 /* set input buffer geometry */
817 if (pInbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
818 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for input buffer");
819 ret
= OMX_ErrorInsufficientResources
;
823 /* setup input buffer */
824 if (pInbufOps
->Setup(hMFCHandle
, inputBufferNumber
) != VIDEO_ERROR_NONE
) {
825 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup input buffer");
826 ret
= OMX_ErrorInsufficientResources
;
830 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
831 ret
= Mpeg4CodecRegistCodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
);
832 if (ret
!= OMX_ErrorNone
)
834 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
835 /* Register input buffer */
836 for (i
= 0; i
< pExynosInputPort
->portDefinition
.nBufferCountActual
; i
++) {
837 ExynosVideoPlane plane
;
838 plane
.addr
= pExynosInputPort
->extendBufferHeader
[i
].OMXBufferHeader
->pBuffer
;
839 plane
.allocSize
= pExynosInputPort
->extendBufferHeader
[i
].OMXBufferHeader
->nAllocLen
;
840 plane
.fd
= pExynosInputPort
->extendBufferHeader
[i
].buf_fd
[0];
841 if (pInbufOps
->Register(hMFCHandle
, &plane
, MFC_INPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
842 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register input buffer");
843 ret
= OMX_ErrorInsufficientResources
;
849 /* set output geometry */
850 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
851 pMpeg4Dec
->hMFCMpeg4Handle
.MFCOutputColorType
= bufferConf
.eColorFormat
= VIDEO_COLORFORMAT_NV12_TILED
;
852 if (pOutbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
853 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for output buffer");
854 ret
= OMX_ErrorInsufficientResources
;
858 /* input buffer enqueue for header parsing */
859 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d", oneFrameSize
);
860 if (pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
861 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
) != VIDEO_ERROR_NONE
) {
862 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to enqueue input buffer for header parsing");
863 // ret = OMX_ErrorInsufficientResources;
864 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecInit
;
868 /* start header parsing */
869 if (pInbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
870 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run input buffer for header parsing");
871 ret
= OMX_ErrorCodecInit
;
875 /* get geometry for output */
876 Exynos_OSAL_Memset(&pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
, 0, sizeof(ExynosVideoGeometry
));
877 if (pOutbufOps
->Get_Geometry(hMFCHandle
, &pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
) != VIDEO_ERROR_NONE
) {
878 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to get geometry for parsed header info");
879 ret
= OMX_ErrorInsufficientResources
;
884 pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
= pDecOps
->Get_ActualBufferCount(hMFCHandle
);
885 if (pVideoDec
->bThumbnailMode
== OMX_FALSE
)
886 pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
+= EXTRA_DPB_NUM
;
887 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Mpeg4CodecSetup nOutbufs: %d", pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
);
889 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_TRUE
;
891 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
892 if ((pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
) ||
893 (pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
)) {
894 pExynosOutputPort
->exceptionFlag
= NEED_PORT_DISABLE
;
896 pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
897 pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
898 pExynosInputPort
->portDefinition
.format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
899 pExynosInputPort
->portDefinition
.format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
901 Exynos_UpdateFrameSize(pOMXComponent
);
903 /** Send Port Settings changed call back **/
904 (*(pExynosComponent
->pCallbacks
->EventHandler
))
906 pExynosComponent
->callbackData
,
907 OMX_EventPortSettingsChanged
, /* The command was completed */
908 OMX_DirOutput
, /* This is the port index */
912 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
913 if ((pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
) ||
914 (pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
) ||
915 (pExynosOutputPort
->portDefinition
.nBufferCountActual
!= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
)) {
916 pExynosOutputPort
->exceptionFlag
= NEED_PORT_DISABLE
;
918 pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
919 pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
920 pExynosInputPort
->portDefinition
.format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
921 pExynosInputPort
->portDefinition
.format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
923 pExynosOutputPort
->portDefinition
.nBufferCountActual
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
- 2;
924 pExynosOutputPort
->portDefinition
.nBufferCountMin
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
- 2;
926 Exynos_UpdateFrameSize(pOMXComponent
);
928 /** Send Port Settings changed call back **/
929 (*(pExynosComponent
->pCallbacks
->EventHandler
))
931 pExynosComponent
->callbackData
,
932 OMX_EventPortSettingsChanged
, /* The command was completed */
933 OMX_DirOutput
, /* This is the port index */
938 Exynos_OSAL_SleepMillisec(0);
939 ret
= OMX_ErrorInputDataDecodeYet
;
940 Mpeg4CodecStop(pOMXComponent
, INPUT_PORT_INDEX
);
948 OMX_ERRORTYPE
Mpeg4CodecDstSetup(OMX_COMPONENTTYPE
*pOMXComponent
)
950 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
951 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
952 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
953 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
954 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
955 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
956 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
958 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
959 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
960 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
967 nOutbufs
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
969 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
970 /* should be done before prepare output buffer */
971 if (pOutbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
972 ret
= OMX_ErrorInsufficientResources
;
976 pOutbufOps
->Set_Shareable(hMFCHandle
);
977 if (pOutbufOps
->Setup(hMFCHandle
, nOutbufs
) != VIDEO_ERROR_NONE
) {
978 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup output buffer");
979 ret
= OMX_ErrorInsufficientResources
;
983 ExynosVideoPlane planes
[MFC_OUTPUT_BUFFER_PLANE
];
984 OMX_U32 nAllocLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
985 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
988 nAllocLen
[0] = pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nAlignPlaneSize
[0];
989 nAllocLen
[1] = pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nAlignPlaneSize
[1];
991 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
992 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, nOutbufs
, nAllocLen
);
993 if (ret
!= OMX_ErrorNone
)
996 ret
= Mpeg4CodecRegistCodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, nOutbufs
);
997 if (ret
!= OMX_ErrorNone
)
1000 /* Enqueue output buffer */
1001 for (i
= 0; i
< nOutbufs
; i
++) {
1002 pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
,
1003 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
1005 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1006 /* Register output buffer */
1011 if (pExynosOutputPort
->bIsANBEnabled
== OMX_TRUE
) {
1012 for (i
= 0; i
< pExynosOutputPort
->assignedBufferNum
; i
++) {
1013 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
1014 planes
[plane
].fd
= pExynosOutputPort
->extendBufferHeader
[i
].buf_fd
[plane
];
1015 planes
[plane
].addr
= pExynosOutputPort
->extendBufferHeader
[i
].pYUVBuf
[plane
];
1016 planes
[plane
].allocSize
= nAllocLen
[plane
];
1019 if (pOutbufOps
->Register(hMFCHandle
, planes
, MFC_OUTPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
1020 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register output buffer");
1021 ret
= OMX_ErrorInsufficientResources
;
1024 pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pExynosOutputPort
->extendBufferHeader
[i
].pYUVBuf
,
1025 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
1028 ret
= OMX_ErrorNotImplemented
;
1032 ret
= OMX_ErrorNotImplemented
;
1037 if (pOutbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
1038 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run output buffer");
1039 ret
= OMX_ErrorInsufficientResources
;
1043 if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1044 Mpeg4CodecStop(pOMXComponent
, OUTPUT_PORT_INDEX
);
1046 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_TRUE
;
1048 ret
= OMX_ErrorNone
;
1056 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetParameter(
1057 OMX_IN OMX_HANDLETYPE hComponent
,
1058 OMX_IN OMX_INDEXTYPE nParamIndex
,
1059 OMX_INOUT OMX_PTR pComponentParameterStructure
)
1061 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1062 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1063 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1067 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1068 ret
= OMX_ErrorBadParameter
;
1071 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1072 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1073 if (ret
!= OMX_ErrorNone
) {
1076 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1077 ret
= OMX_ErrorBadParameter
;
1081 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1082 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1083 ret
= OMX_ErrorInvalidState
;
1087 switch (nParamIndex
) {
1088 case OMX_IndexParamVideoMpeg4
:
1090 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1091 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1092 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1094 ret
= Exynos_OMX_Check_SizeVersion(pDstMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1095 if (ret
!= OMX_ErrorNone
) {
1099 if (pDstMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1100 ret
= OMX_ErrorBadPortIndex
;
1104 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1105 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstMpeg4Param
->nPortIndex
];
1107 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1110 case OMX_IndexParamVideoH263
:
1112 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1113 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1114 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1116 ret
= Exynos_OMX_Check_SizeVersion(pDstH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1117 if (ret
!= OMX_ErrorNone
) {
1121 if (pDstH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1122 ret
= OMX_ErrorBadPortIndex
;
1126 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1127 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstH263Param
->nPortIndex
];
1129 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1132 case OMX_IndexParamStandardComponentRole
:
1135 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1137 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1138 if (ret
!= OMX_ErrorNone
) {
1142 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1143 if (codecType
== CODEC_TYPE_MPEG4
)
1144 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1146 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1149 case OMX_IndexParamVideoProfileLevelQuerySupported
:
1151 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1152 EXYNOS_OMX_VIDEO_PROFILELEVEL
*pProfileLevel
= NULL
;
1153 OMX_U32 maxProfileLevelNum
= 0;
1156 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1157 if (ret
!= OMX_ErrorNone
) {
1161 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1162 ret
= OMX_ErrorBadPortIndex
;
1166 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1167 if (codecType
== CODEC_TYPE_MPEG4
) {
1168 pProfileLevel
= supportedMPEG4ProfileLevels
;
1169 maxProfileLevelNum
= sizeof(supportedMPEG4ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1171 pProfileLevel
= supportedH263ProfileLevels
;
1172 maxProfileLevelNum
= sizeof(supportedH263ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1175 if (pDstProfileLevel
->nProfileIndex
>= maxProfileLevelNum
) {
1176 ret
= OMX_ErrorNoMore
;
1180 pProfileLevel
+= pDstProfileLevel
->nProfileIndex
;
1181 pDstProfileLevel
->eProfile
= pProfileLevel
->profile
;
1182 pDstProfileLevel
->eLevel
= pProfileLevel
->level
;
1185 case OMX_IndexParamVideoProfileLevelCurrent
:
1187 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1188 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1189 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1190 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1193 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1194 if (ret
!= OMX_ErrorNone
) {
1198 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1199 ret
= OMX_ErrorBadPortIndex
;
1203 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1204 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1205 if (codecType
== CODEC_TYPE_MPEG4
) {
1206 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstProfileLevel
->nPortIndex
];
1207 pDstProfileLevel
->eProfile
= pSrcMpeg4Param
->eProfile
;
1208 pDstProfileLevel
->eLevel
= pSrcMpeg4Param
->eLevel
;
1210 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstProfileLevel
->nPortIndex
];
1211 pDstProfileLevel
->eProfile
= pSrcH263Param
->eProfile
;
1212 pDstProfileLevel
->eLevel
= pSrcH263Param
->eLevel
;
1216 case OMX_IndexParamVideoErrorCorrection
:
1218 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1219 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= NULL
;
1220 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1222 ret
= Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1223 if (ret
!= OMX_ErrorNone
) {
1227 if (pDstErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1228 ret
= OMX_ErrorBadPortIndex
;
1232 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1233 pSrcErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1235 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1236 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1237 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1238 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1239 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1243 ret
= Exynos_OMX_VideoDecodeGetParameter(hComponent
, nParamIndex
, pComponentParameterStructure
);
1252 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetParameter(
1253 OMX_IN OMX_HANDLETYPE hComponent
,
1254 OMX_IN OMX_INDEXTYPE nIndex
,
1255 OMX_IN OMX_PTR pComponentParameterStructure
)
1257 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1258 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1259 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1263 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1264 ret
= OMX_ErrorBadParameter
;
1267 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1268 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1269 if (ret
!= OMX_ErrorNone
) {
1272 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1273 ret
= OMX_ErrorBadParameter
;
1277 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1278 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1279 ret
= OMX_ErrorInvalidState
;
1284 case OMX_IndexParamVideoMpeg4
:
1286 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1287 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1288 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1290 ret
= Exynos_OMX_Check_SizeVersion(pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1291 if (ret
!= OMX_ErrorNone
) {
1295 if (pSrcMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1296 ret
= OMX_ErrorBadPortIndex
;
1300 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1301 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcMpeg4Param
->nPortIndex
];
1303 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1306 case OMX_IndexParamVideoH263
:
1308 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1309 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1310 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1312 ret
= Exynos_OMX_Check_SizeVersion(pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1313 if (ret
!= OMX_ErrorNone
) {
1317 if (pSrcH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1318 ret
= OMX_ErrorBadPortIndex
;
1322 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1323 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcH263Param
->nPortIndex
];
1325 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1328 case OMX_IndexParamStandardComponentRole
:
1330 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1332 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1333 if (ret
!= OMX_ErrorNone
) {
1337 if ((pExynosComponent
->currentState
!= OMX_StateLoaded
) && (pExynosComponent
->currentState
!= OMX_StateWaitForResources
)) {
1338 ret
= OMX_ErrorIncorrectStateOperation
;
1342 if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
)) {
1343 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
1344 } else if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
)) {
1345 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
1347 ret
= OMX_ErrorBadParameter
;
1352 case OMX_IndexParamVideoProfileLevelCurrent
:
1354 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pSrcProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1355 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1356 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1357 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1360 ret
= Exynos_OMX_Check_SizeVersion(pSrcProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1361 if (ret
!= OMX_ErrorNone
)
1364 if (pSrcProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1365 ret
= OMX_ErrorBadPortIndex
;
1369 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1370 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1371 if (codecType
== CODEC_TYPE_MPEG4
) {
1373 * To do: Check validity of profile & level parameters
1376 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcProfileLevel
->nPortIndex
];
1377 pDstMpeg4Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1378 pDstMpeg4Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1381 * To do: Check validity of profile & level parameters
1384 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcProfileLevel
->nPortIndex
];
1385 pDstH263Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1386 pDstH263Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1390 case OMX_IndexParamVideoErrorCorrection
:
1392 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1393 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= NULL
;
1394 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1396 ret
= Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1397 if (ret
!= OMX_ErrorNone
) {
1401 if (pSrcErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1402 ret
= OMX_ErrorBadPortIndex
;
1406 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1407 pDstErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1409 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1410 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1411 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1412 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1413 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1417 ret
= Exynos_OMX_VideoDecodeSetParameter(hComponent
, nIndex
, pComponentParameterStructure
);
1426 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetConfig(
1427 OMX_IN OMX_HANDLETYPE hComponent
,
1428 OMX_IN OMX_INDEXTYPE nIndex
,
1429 OMX_IN OMX_PTR pComponentConfigStructure
)
1431 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1432 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1433 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1437 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1438 ret
= OMX_ErrorBadParameter
;
1441 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1442 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1443 if (ret
!= OMX_ErrorNone
) {
1446 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1447 ret
= OMX_ErrorBadParameter
;
1450 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1451 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1452 ret
= OMX_ErrorInvalidState
;
1458 ret
= Exynos_OMX_VideoDecodeGetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1468 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetConfig(
1469 OMX_IN OMX_HANDLETYPE hComponent
,
1470 OMX_IN OMX_INDEXTYPE nIndex
,
1471 OMX_IN OMX_PTR pComponentConfigStructure
)
1473 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1474 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1475 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1479 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1480 ret
= OMX_ErrorBadParameter
;
1483 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1484 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1485 if (ret
!= OMX_ErrorNone
) {
1488 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1489 ret
= OMX_ErrorBadParameter
;
1492 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1493 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1494 ret
= OMX_ErrorInvalidState
;
1500 ret
= Exynos_OMX_VideoDecodeSetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1510 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetExtensionIndex(
1511 OMX_IN OMX_HANDLETYPE hComponent
,
1512 OMX_IN OMX_STRING cParameterName
,
1513 OMX_OUT OMX_INDEXTYPE
*pIndexType
)
1515 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1516 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1517 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1521 if (hComponent
== NULL
) {
1522 ret
= OMX_ErrorBadParameter
;
1525 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1526 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1527 if (ret
!= OMX_ErrorNone
) {
1530 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1531 ret
= OMX_ErrorBadParameter
;
1534 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1535 if ((cParameterName
== NULL
) || (pIndexType
== NULL
)) {
1536 ret
= OMX_ErrorBadParameter
;
1539 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1540 ret
= OMX_ErrorInvalidState
;
1544 if (Exynos_OSAL_Strcmp(cParameterName
, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL
) == 0) {
1545 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1546 *pIndexType
= OMX_IndexVendorThumbnailMode
;
1547 ret
= OMX_ErrorNone
;
1549 ret
= Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent
, cParameterName
, pIndexType
);
1558 OMX_ERRORTYPE
Exynos_Mpeg4Dec_ComponentRoleEnum(
1559 OMX_IN OMX_HANDLETYPE hComponent
,
1560 OMX_OUT OMX_U8
*cRole
,
1561 OMX_IN OMX_U32 nIndex
)
1563 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1564 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1565 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1570 if ((hComponent
== NULL
) || (cRole
== NULL
)) {
1571 ret
= OMX_ErrorBadParameter
;
1574 if (nIndex
!= (MAX_COMPONENT_ROLE_NUM
- 1)) {
1575 ret
= OMX_ErrorNoMore
;
1578 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1579 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1580 if (ret
!= OMX_ErrorNone
) {
1583 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1584 ret
= OMX_ErrorBadParameter
;
1587 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1588 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1589 ret
= OMX_ErrorInvalidState
;
1593 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1594 if (codecType
== CODEC_TYPE_MPEG4
)
1595 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1597 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1606 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Init(OMX_COMPONENTTYPE
*pOMXComponent
)
1608 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1609 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1610 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1611 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1612 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1613 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
1614 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1616 ExynosVideoDecOps
*pDecOps
= NULL
;
1617 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
1618 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
1620 CSC_METHOD csc_method
= CSC_METHOD_SW
;
1625 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_FALSE
;
1626 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_FALSE
;
1627 pExynosComponent
->bUseFlagEOF
= OMX_TRUE
;
1628 pExynosComponent
->bSaveFlagEOS
= OMX_FALSE
;
1630 /* Mpeg4 Codec Open */
1631 ret
= Mpeg4CodecOpen(pMpeg4Dec
);
1632 if (ret
!= OMX_ErrorNone
) {
1636 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1637 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1638 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1640 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1641 OMX_U32 nPlaneSize
[MFC_INPUT_BUFFER_PLANE
] = {DEFAULT_MFC_INPUT_BUFFER_SIZE
};
1642 Exynos_OSAL_SemaphoreCreate(&pExynosInputPort
->codecSemID
);
1643 Exynos_OSAL_QueueCreate(&pExynosInputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1644 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
, nPlaneSize
);
1645 if (ret
!= OMX_ErrorNone
)
1648 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++)
1649 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
1650 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
1654 /* Does not require any actions. */
1657 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1658 Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort
->codecSemID
);
1659 Exynos_OSAL_QueueCreate(&pExynosOutputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1660 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1664 /* Does not require any actions. */
1667 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1668 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hSourceStartEvent
);
1669 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1670 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hDestinationStartEvent
);
1672 Exynos_OSAL_Memset(pExynosComponent
->timeStamp
, -19771003, sizeof(OMX_TICKS
) * MAX_TIMESTAMP
);
1673 Exynos_OSAL_Memset(pExynosComponent
->nFlags
, 0, sizeof(OMX_U32
) * MAX_FLAGS
);
1674 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
= 0;
1675 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= 0;
1677 pExynosComponent
->getAllDelayBuffer
= OMX_FALSE
;
1680 csc_method
= CSC_METHOD_HW
;
1682 pVideoDec
->csc_handle
= csc_init(csc_method
);
1683 if (pVideoDec
->csc_handle
== NULL
) {
1684 ret
= OMX_ErrorInsufficientResources
;
1687 pVideoDec
->csc_set_format
= OMX_FALSE
;
1696 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE
*pOMXComponent
)
1698 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1699 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1700 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1701 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1702 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1703 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1704 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1706 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1707 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1708 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1714 if (pVideoDec
->csc_handle
!= NULL
) {
1715 csc_deinit(pVideoDec
->csc_handle
);
1716 pVideoDec
->csc_handle
= NULL
;
1719 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hDestinationStartEvent
);
1720 pMpeg4Dec
->hDestinationStartEvent
= NULL
;
1721 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1722 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hSourceStartEvent
);
1723 pMpeg4Dec
->hSourceStartEvent
= NULL
;
1724 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1726 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1727 Exynos_Free_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
);
1728 Exynos_OSAL_QueueTerminate(&pExynosOutputPort
->codecBufferQ
);
1729 Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort
->codecSemID
);
1730 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1734 /* Does not require any actions. */
1737 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1738 Exynos_Free_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
);
1739 Exynos_OSAL_QueueTerminate(&pExynosInputPort
->codecBufferQ
);
1740 Exynos_OSAL_SemaphoreTerminate(pExynosInputPort
->codecSemID
);
1741 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
1745 /* Does not require any actions. */
1747 Mpeg4CodecClose(pMpeg4Dec
);
1755 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
1757 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1758 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1759 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1760 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1761 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1762 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1763 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1764 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
1765 OMX_BOOL bInStartCode
= OMX_FALSE
;
1766 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1767 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1768 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1769 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1774 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
== OMX_FALSE
) {
1775 ret
= Mpeg4CodecSrcSetup(pOMXComponent
, pSrcInputData
);
1778 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_FALSE
) {
1779 ret
= Mpeg4CodecDstSetup(pOMXComponent
);
1782 if (((bInStartCode
= Check_Stream_StartCode(pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
, oneFrameSize
, pMpeg4Dec
->hMFCMpeg4Handle
.codecType
)) == OMX_TRUE
) ||
1783 ((pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
1784 pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->timeStamp
;
1785 pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->nFlags
;
1786 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "input timestamp %lld us (%.2f secs), Tag: %d, nFlags: 0x%x", pSrcInputData
->timeStamp
, pSrcInputData
->timeStamp
/ 1E6
, pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
, pSrcInputData
->nFlags
);
1787 pDecOps
->Set_FrameTag(hMFCHandle
, pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
);
1788 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
++;
1789 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
%= MAX_TIMESTAMP
;
1791 /* queue work for input buffer */
1792 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize
, pSrcInputData
->bufferHeader
, pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
);
1793 codecReturn
= pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
1794 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
);
1795 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1796 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1797 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1800 Mpeg4CodecStart(pOMXComponent
, INPUT_PORT_INDEX
);
1801 if (pMpeg4Dec
->bSourceStart
== OMX_FALSE
) {
1802 pMpeg4Dec
->bSourceStart
= OMX_TRUE
;
1803 Exynos_OSAL_SignalSet(pMpeg4Dec
->hSourceStartEvent
);
1804 Exynos_OSAL_SleepMillisec(0);
1806 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1807 pMpeg4Dec
->bDestinationStart
= OMX_TRUE
;
1808 Exynos_OSAL_SignalSet(pMpeg4Dec
->hDestinationStartEvent
);
1809 Exynos_OSAL_SleepMillisec(0);
1811 } else if (bInStartCode
== OMX_FALSE
) {
1812 ret
= OMX_ErrorCorruptedFrame
;
1816 ret
= OMX_ErrorNone
;
1824 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
1826 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1827 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1828 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1829 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1830 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1831 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1832 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1833 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1834 ExynosVideoBuffer
*pVideoBuffer
;
1838 pVideoBuffer
= pInbufOps
->Dequeue(hMFCHandle
);
1840 pSrcOutputData
->dataLen
= 0;
1841 pSrcOutputData
->usedDataLen
= 0;
1842 pSrcOutputData
->remainDataLen
= 0;
1843 pSrcOutputData
->nFlags
= 0;
1844 pSrcOutputData
->timeStamp
= 0;
1846 if (pVideoBuffer
== NULL
) {
1847 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= NULL
;
1848 pSrcOutputData
->allocSize
= 0;
1849 pSrcOutputData
->pPrivate
= NULL
;
1850 pSrcOutputData
->bufferHeader
= NULL
;
1852 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= pVideoBuffer
->planes
[0].addr
;
1853 pSrcOutputData
->buffer
.singlePlaneBuffer
.fd
= pVideoBuffer
->planes
[0].fd
;
1854 pSrcOutputData
->allocSize
= pVideoBuffer
->planes
[0].allocSize
;
1856 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1858 while (pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
!= pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]) {
1859 if (i
>= MFC_INPUT_BUFFER_NUM_MAX
) {
1860 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
1861 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1866 pVideoDec
->pMFCDecInputBuffer
[i
]->dataSize
= 0;
1867 pSrcOutputData
->pPrivate
= pVideoDec
->pMFCDecInputBuffer
[i
];
1870 /* For Share Buffer */
1871 pSrcOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
1874 ret
= OMX_ErrorNone
;
1882 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
1884 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1885 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1886 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1887 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1888 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1889 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1890 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1891 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1892 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0,};
1893 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1897 if (pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] == NULL
) {
1898 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to find input buffer");
1899 ret
= OMX_ErrorBadParameter
;
1903 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x", __FUNCTION__
, __LINE__
,
1904 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0],
1905 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[1]);
1907 codecReturn
= pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
,
1908 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, pDstInputData
->bufferHeader
);
1910 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1911 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1912 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1915 Mpeg4CodecStart(pOMXComponent
, OUTPUT_PORT_INDEX
);
1917 ret
= OMX_ErrorNone
;
1925 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
1927 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1928 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1929 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1930 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1931 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1932 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1933 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1934 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1935 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1936 ExynosVideoBuffer
*pVideoBuffer
= NULL
;
1937 ExynosVideoFrameStatusType displayStatus
= VIDEO_FRAME_STATUS_UNKNOWN
;
1938 ExynosVideoGeometry
*bufferGeometry
;
1939 DECODE_CODEC_EXTRA_BUFFERINFO
*pBufferInfo
= NULL
;
1940 OMX_S32 indexTimestamp
= 0;
1945 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1946 ret
= OMX_ErrorNone
;
1951 if ((pVideoBuffer
= pOutbufOps
->Dequeue(hMFCHandle
)) == NULL
) {
1952 ret
= OMX_ErrorNone
;
1955 displayStatus
= pVideoBuffer
->displayStatus
;
1956 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus: 0x%x", displayStatus
);
1958 if ((displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_DECODING
) ||
1959 (displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_ONLY
) ||
1960 (displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
1961 (displayStatus
== VIDEO_FRAME_STATUS_DECODING_FINISHED
) ||
1962 (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
1963 ret
= OMX_ErrorNone
;
1968 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
++;
1969 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
%= MAX_TIMESTAMP
;
1971 pDstOutputData
->allocSize
= pDstOutputData
->dataLen
= 0;
1972 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
1973 pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[plane
] = pVideoBuffer
->planes
[plane
].addr
;
1974 pDstOutputData
->buffer
.multiPlaneBuffer
.fd
[plane
] = pVideoBuffer
->planes
[plane
].fd
;
1975 pDstOutputData
->allocSize
+= pVideoBuffer
->planes
[plane
].allocSize
;
1976 pDstOutputData
->dataLen
+= pVideoBuffer
->planes
[plane
].dataSize
;
1978 pDstOutputData
->usedDataLen
= 0;
1979 pDstOutputData
->pPrivate
= pVideoBuffer
;
1980 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1982 pDstOutputData
->pPrivate
= NULL
;
1983 for (i
= 0; i
< MFC_OUTPUT_BUFFER_NUM_MAX
; i
++) {
1984 if (pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] ==
1985 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[0]) {
1986 pDstOutputData
->pPrivate
= pVideoDec
->pMFCDecOutputBuffer
[i
];
1991 if (pDstOutputData
->pPrivate
== NULL
) {
1992 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
1993 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1998 /* For Share Buffer */
1999 pDstOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
2001 pBufferInfo
= (DECODE_CODEC_EXTRA_BUFFERINFO
*)pDstOutputData
->extInfo
;
2002 bufferGeometry
= &pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
;
2003 pBufferInfo
->imageWidth
= bufferGeometry
->nFrameWidth
;
2004 pBufferInfo
->imageHeight
= bufferGeometry
->nFrameHeight
;
2005 switch (bufferGeometry
->eColorFormat
) {
2006 case VIDEO_COLORFORMAT_NV12
:
2007 pBufferInfo
->ColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
2009 case VIDEO_COLORFORMAT_NV12_TILED
:
2011 pBufferInfo
->ColorFormat
= OMX_SEC_COLOR_FormatNV12Tiled
;
2015 indexTimestamp
= pDecOps
->Get_FrameTag(hMFCHandle
);
2016 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "out indexTimestamp: %d", indexTimestamp
);
2017 if ((indexTimestamp
< 0) || (indexTimestamp
>= MAX_TIMESTAMP
)) {
2018 if ((pExynosComponent
->checkTimeStamp
.needSetStartTimeStamp
!= OMX_TRUE
) &&
2019 (pExynosComponent
->checkTimeStamp
.needCheckStartTimeStamp
!= OMX_TRUE
)) {
2020 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2021 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2022 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "missing out indexTimestamp: %d", indexTimestamp
);
2024 pDstOutputData
->timeStamp
= 0x00;
2025 pDstOutputData
->nFlags
= 0x00;
2028 /* For timestamp correction. if mfc support frametype detect */
2029 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "disp_pic_frame_type: %d", pVideoBuffer
->frameType
);
2030 #ifdef NEED_TIMESTAMP_REORDER
2031 if ((pVideoBuffer
->frameType
== VIDEO_FRAME_I
)) {
2032 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2033 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2034 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= indexTimestamp
;
2036 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2037 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2040 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2041 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2043 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData
->timeStamp
, pDstOutputData
->timeStamp
/ 1E6
, indexTimestamp
, pDstOutputData
->nFlags
);
2046 if ((displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
2047 (displayStatus
== VIDEO_FRAME_STATUS_DECODING_FINISHED
) ||
2048 ((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
2049 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus:%d, nFlags0x%x", displayStatus
, pDstOutputData
->nFlags
);
2050 pDstOutputData
->remainDataLen
= 0;
2052 pDstOutputData
->remainDataLen
= bufferGeometry
->nFrameWidth
* bufferGeometry
->nFrameHeight
* 3 / 2;
2055 ret
= OMX_ErrorNone
;
2063 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
2065 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2066 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2067 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2068 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2072 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2073 ret
= OMX_ErrorNone
;
2076 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2077 ret
= OMX_ErrorNone
;
2081 ret
= Exynos_Mpeg4Dec_SrcIn(pOMXComponent
, pSrcInputData
);
2082 if ((ret
!= OMX_ErrorNone
) &&
2083 (ret
!= OMX_ErrorInputDataDecodeYet
) &&
2084 (ret
!= OMX_ErrorCorruptedFrame
)) {
2085 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2086 pExynosComponent
->callbackData
,
2087 OMX_EventError
, ret
, 0, NULL
);
2096 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
2098 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2099 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2100 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2101 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2105 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2106 ret
= OMX_ErrorNone
;
2110 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
2111 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2112 ret
= OMX_ErrorNone
;
2116 if ((pMpeg4Dec
->bSourceStart
== OMX_FALSE
) &&
2117 (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort
))) {
2118 Exynos_OSAL_SignalWait(pMpeg4Dec
->hSourceStartEvent
, DEF_MAX_WAIT_TIME
);
2119 Exynos_OSAL_SignalReset(pMpeg4Dec
->hSourceStartEvent
);
2122 ret
= Exynos_Mpeg4Dec_SrcOut(pOMXComponent
, pSrcOutputData
);
2123 if ((ret
!= OMX_ErrorNone
) &&
2124 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2125 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2126 pExynosComponent
->callbackData
,
2127 OMX_EventError
, ret
, 0, NULL
);
2136 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
2138 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2139 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2140 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2141 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2145 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2146 ret
= OMX_ErrorNone
;
2149 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2150 ret
= OMX_ErrorNone
;
2153 if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
2154 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2155 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2156 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2157 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2160 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_TRUE
) {
2161 ret
= Exynos_Mpeg4Dec_DstIn(pOMXComponent
, pDstInputData
);
2162 if (ret
!= OMX_ErrorNone
) {
2163 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2164 pExynosComponent
->callbackData
,
2165 OMX_EventError
, ret
, 0, NULL
);
2175 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
2177 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2178 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2179 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2180 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2184 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2185 ret
= OMX_ErrorNone
;
2188 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2189 ret
= OMX_ErrorNone
;
2193 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
2194 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2195 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2196 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2197 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2200 ret
= Exynos_Mpeg4Dec_DstOut(pOMXComponent
, pDstOutputData
);
2201 if ((ret
!= OMX_ErrorNone
) &&
2202 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2203 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2204 pExynosComponent
->callbackData
,
2205 OMX_EventError
, ret
, 0, NULL
);
2214 OSCL_EXPORT_REF OMX_ERRORTYPE
Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent
, OMX_STRING componentName
)
2216 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2217 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2218 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2219 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
2220 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2221 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2223 OMX_S32 codecType
= -1;
2227 if ((hComponent
== NULL
) || (componentName
== NULL
)) {
2228 ret
= OMX_ErrorBadParameter
;
2229 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
2232 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_MPEG4_DEC
, componentName
) == 0) {
2233 codecType
= CODEC_TYPE_MPEG4
;
2234 } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H263_DEC
, componentName
) == 0) {
2235 codecType
= CODEC_TYPE_H263
;
2237 ret
= OMX_ErrorBadParameter
;
2238 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName
, __LINE__
);
2242 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2243 ret
= Exynos_OMX_VideoDecodeComponentInit(pOMXComponent
);
2244 if (ret
!= OMX_ErrorNone
) {
2245 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_Error, Line:%d", __LINE__
);
2248 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2249 pExynosComponent
->codecType
= HW_VIDEO_DEC_CODEC
;
2251 pExynosComponent
->componentName
= (OMX_STRING
)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE
);
2252 if (pExynosComponent
->componentName
== NULL
) {
2253 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2254 ret
= OMX_ErrorInsufficientResources
;
2255 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2258 Exynos_OSAL_Memset(pExynosComponent
->componentName
, 0, MAX_OMX_COMPONENT_NAME_SIZE
);
2260 pMpeg4Dec
= Exynos_OSAL_Malloc(sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2261 if (pMpeg4Dec
== NULL
) {
2262 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2263 ret
= OMX_ErrorInsufficientResources
;
2264 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2267 Exynos_OSAL_Memset(pMpeg4Dec
, 0, sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2268 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2269 pVideoDec
->hCodecHandle
= (OMX_HANDLETYPE
)pMpeg4Dec
;
2270 pMpeg4Dec
->hMFCMpeg4Handle
.codecType
= codecType
;
2272 if (codecType
== CODEC_TYPE_MPEG4
)
2273 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_MPEG4_DEC
);
2275 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_H263_DEC
);
2277 /* Set componentVersion */
2278 pExynosComponent
->componentVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2279 pExynosComponent
->componentVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2280 pExynosComponent
->componentVersion
.s
.nRevision
= REVISION_NUMBER
;
2281 pExynosComponent
->componentVersion
.s
.nStep
= STEP_NUMBER
;
2282 /* Set specVersion */
2283 pExynosComponent
->specVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2284 pExynosComponent
->specVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2285 pExynosComponent
->specVersion
.s
.nRevision
= REVISION_NUMBER
;
2286 pExynosComponent
->specVersion
.s
.nStep
= STEP_NUMBER
;
2289 pExynosPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2290 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2291 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2292 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2293 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2294 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_INPUT_BUFFER_SIZE
;
2295 if (codecType
== CODEC_TYPE_MPEG4
) {
2296 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
2297 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2298 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/mpeg4");
2300 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
2301 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2302 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/h263");
2304 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2305 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2306 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatUnused
;
2307 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2308 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
2309 pExynosPort
->portWayType
= WAY2_PORT
;
2312 pExynosPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2313 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2314 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2315 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2316 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2317 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE
;
2318 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingUnused
;
2319 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2320 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "raw/video");
2321 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2322 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2323 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420Planar
;
2324 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2325 pExynosPort
->bufferProcessType
= BUFFER_COPY
| BUFFER_ANBSHARE
;
2326 pExynosPort
->portWayType
= WAY2_PORT
;
2328 if (codecType
== CODEC_TYPE_MPEG4
) {
2329 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2330 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->mpeg4Component
[i
], OMX_VIDEO_PARAM_MPEG4TYPE
);
2331 pMpeg4Dec
->mpeg4Component
[i
].nPortIndex
= i
;
2332 pMpeg4Dec
->mpeg4Component
[i
].eProfile
= OMX_VIDEO_MPEG4ProfileSimple
;
2333 pMpeg4Dec
->mpeg4Component
[i
].eLevel
= OMX_VIDEO_MPEG4Level3
;
2336 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2337 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->h263Component
[i
], OMX_VIDEO_PARAM_H263TYPE
);
2338 pMpeg4Dec
->h263Component
[i
].nPortIndex
= i
;
2339 pMpeg4Dec
->h263Component
[i
].eProfile
= OMX_VIDEO_H263ProfileBaseline
| OMX_VIDEO_H263ProfileISWV2
;
2340 pMpeg4Dec
->h263Component
[i
].eLevel
= OMX_VIDEO_H263Level45
;
2344 pOMXComponent
->GetParameter
= &Exynos_Mpeg4Dec_GetParameter
;
2345 pOMXComponent
->SetParameter
= &Exynos_Mpeg4Dec_SetParameter
;
2346 pOMXComponent
->GetConfig
= &Exynos_Mpeg4Dec_GetConfig
;
2347 pOMXComponent
->SetConfig
= &Exynos_Mpeg4Dec_SetConfig
;
2348 pOMXComponent
->GetExtensionIndex
= &Exynos_Mpeg4Dec_GetExtensionIndex
;
2349 pOMXComponent
->ComponentRoleEnum
= &Exynos_Mpeg4Dec_ComponentRoleEnum
;
2350 pOMXComponent
->ComponentDeInit
= &Exynos_OMX_ComponentDeinit
;
2352 pExynosComponent
->exynos_codec_componentInit
= &Exynos_Mpeg4Dec_Init
;
2353 pExynosComponent
->exynos_codec_componentTerminate
= &Exynos_Mpeg4Dec_Terminate
;
2355 pVideoDec
->exynos_codec_srcInputProcess
= &Exynos_Mpeg4Dec_srcInputBufferProcess
;
2356 pVideoDec
->exynos_codec_srcOutputProcess
= &Exynos_Mpeg4Dec_srcOutputBufferProcess
;
2357 pVideoDec
->exynos_codec_dstInputProcess
= &Exynos_Mpeg4Dec_dstInputBufferProcess
;
2358 pVideoDec
->exynos_codec_dstOutputProcess
= &Exynos_Mpeg4Dec_dstOutputBufferProcess
;
2360 pVideoDec
->exynos_codec_start
= &Mpeg4CodecStart
;
2361 pVideoDec
->exynos_codec_stop
= &Mpeg4CodecStop
;
2362 pVideoDec
->exynos_codec_bufferProcessRun
= &Mpeg4CodecOutputBufferProcessRun
;
2363 pVideoDec
->exynos_codec_enqueueAllBuffer
= &Mpeg4CodecEnQueueAllBuffer
;
2365 if (codecType
== CODEC_TYPE_MPEG4
)
2366 pVideoDec
->exynos_checkInputFrame
= &Check_Mpeg4_Frame
;
2368 pVideoDec
->exynos_checkInputFrame
= &Check_H263_Frame
;
2370 pVideoDec
->exynos_codec_getCodecInputPrivateData
= &GetCodecInputPrivateData
;
2371 pVideoDec
->exynos_codec_getCodecOutputPrivateData
= &GetCodecOutputPrivateData
;
2373 pVideoDec
->hSharedMemory
= Exynos_OSAL_SharedMemory_Open();
2374 if (pVideoDec
->hSharedMemory
== NULL
) {
2375 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2376 Exynos_OSAL_Free(pMpeg4Dec
);
2377 pMpeg4Dec
= ((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
= NULL
;
2378 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2379 ret
= OMX_ErrorInsufficientResources
;
2383 pExynosComponent
->currentState
= OMX_StateLoaded
;
2385 ret
= OMX_ErrorNone
;
2393 OMX_ERRORTYPE
Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent
)
2395 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2396 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2397 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2398 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2399 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2403 if (hComponent
== NULL
) {
2404 ret
= OMX_ErrorBadParameter
;
2407 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2408 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2409 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2411 Exynos_OSAL_SharedMemory_Close(pVideoDec
->hSharedMemory
);
2413 Exynos_OSAL_Free(pExynosComponent
->componentName
);
2414 pExynosComponent
->componentName
= NULL
;
2416 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
2417 if (pMpeg4Dec
!= NULL
) {
2418 Exynos_OSAL_Free(pMpeg4Dec
);
2419 pMpeg4Dec
= pVideoDec
->hCodecHandle
= NULL
;
2422 ret
= Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2423 if (ret
!= OMX_ErrorNone
) {
2427 ret
= OMX_ErrorNone
;