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
;
964 OMX_U32 nAllocLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
965 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
969 nAllocLen
[0] = pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nAlignPlaneSize
[0];
970 nAllocLen
[1] = pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nAlignPlaneSize
[1];
972 pOutbufOps
->Set_Shareable(hMFCHandle
);
974 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
975 /* should be done before prepare output buffer */
976 if (pOutbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
977 ret
= OMX_ErrorInsufficientResources
;
982 nOutbufs
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
983 if (pOutbufOps
->Setup(hMFCHandle
, nOutbufs
) != VIDEO_ERROR_NONE
) {
984 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup output buffer");
985 ret
= OMX_ErrorInsufficientResources
;
989 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, nOutbufs
, nAllocLen
);
990 if (ret
!= OMX_ErrorNone
)
993 ret
= Mpeg4CodecRegistCodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, nOutbufs
);
994 if (ret
!= OMX_ErrorNone
)
997 /* Enqueue output buffer */
998 for (i
= 0; i
< nOutbufs
; i
++) {
999 pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
,
1000 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
1002 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1003 ExynosVideoPlane planes
[MFC_OUTPUT_BUFFER_PLANE
];
1007 nOutbufs
= pExynosOutputPort
->portDefinition
.nBufferCountActual
;
1008 if (pOutbufOps
->Setup(hMFCHandle
, nOutbufs
) != VIDEO_ERROR_NONE
) {
1009 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup output buffer");
1010 ret
= OMX_ErrorInsufficientResources
;
1014 /* Register output buffer */
1019 if (pExynosOutputPort
->bIsANBEnabled
== OMX_TRUE
) {
1020 for (i
= 0; i
< pExynosOutputPort
->assignedBufferNum
; i
++) {
1021 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
1022 planes
[plane
].fd
= pExynosOutputPort
->extendBufferHeader
[i
].buf_fd
[plane
];
1023 planes
[plane
].addr
= pExynosOutputPort
->extendBufferHeader
[i
].pYUVBuf
[plane
];
1024 planes
[plane
].allocSize
= nAllocLen
[plane
];
1027 if (pOutbufOps
->Register(hMFCHandle
, planes
, MFC_OUTPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
1028 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register output buffer");
1029 ret
= OMX_ErrorInsufficientResources
;
1032 pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pExynosOutputPort
->extendBufferHeader
[i
].pYUVBuf
,
1033 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
1036 ret
= OMX_ErrorNotImplemented
;
1040 ret
= OMX_ErrorNotImplemented
;
1045 if (pOutbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
1046 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run output buffer");
1047 ret
= OMX_ErrorInsufficientResources
;
1051 if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1052 Mpeg4CodecStop(pOMXComponent
, OUTPUT_PORT_INDEX
);
1054 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_TRUE
;
1056 ret
= OMX_ErrorNone
;
1064 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetParameter(
1065 OMX_IN OMX_HANDLETYPE hComponent
,
1066 OMX_IN OMX_INDEXTYPE nParamIndex
,
1067 OMX_INOUT OMX_PTR pComponentParameterStructure
)
1069 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1070 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1071 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1075 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1076 ret
= OMX_ErrorBadParameter
;
1079 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1080 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1081 if (ret
!= OMX_ErrorNone
) {
1084 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1085 ret
= OMX_ErrorBadParameter
;
1089 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1090 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1091 ret
= OMX_ErrorInvalidState
;
1095 switch (nParamIndex
) {
1096 case OMX_IndexParamVideoMpeg4
:
1098 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1099 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1100 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1102 ret
= Exynos_OMX_Check_SizeVersion(pDstMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1103 if (ret
!= OMX_ErrorNone
) {
1107 if (pDstMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1108 ret
= OMX_ErrorBadPortIndex
;
1112 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1113 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstMpeg4Param
->nPortIndex
];
1115 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1118 case OMX_IndexParamVideoH263
:
1120 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1121 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1122 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1124 ret
= Exynos_OMX_Check_SizeVersion(pDstH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1125 if (ret
!= OMX_ErrorNone
) {
1129 if (pDstH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1130 ret
= OMX_ErrorBadPortIndex
;
1134 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1135 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstH263Param
->nPortIndex
];
1137 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1140 case OMX_IndexParamStandardComponentRole
:
1143 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1145 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1146 if (ret
!= OMX_ErrorNone
) {
1150 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1151 if (codecType
== CODEC_TYPE_MPEG4
)
1152 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1154 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1157 case OMX_IndexParamVideoProfileLevelQuerySupported
:
1159 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1160 EXYNOS_OMX_VIDEO_PROFILELEVEL
*pProfileLevel
= NULL
;
1161 OMX_U32 maxProfileLevelNum
= 0;
1164 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1165 if (ret
!= OMX_ErrorNone
) {
1169 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1170 ret
= OMX_ErrorBadPortIndex
;
1174 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1175 if (codecType
== CODEC_TYPE_MPEG4
) {
1176 pProfileLevel
= supportedMPEG4ProfileLevels
;
1177 maxProfileLevelNum
= sizeof(supportedMPEG4ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1179 pProfileLevel
= supportedH263ProfileLevels
;
1180 maxProfileLevelNum
= sizeof(supportedH263ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1183 if (pDstProfileLevel
->nProfileIndex
>= maxProfileLevelNum
) {
1184 ret
= OMX_ErrorNoMore
;
1188 pProfileLevel
+= pDstProfileLevel
->nProfileIndex
;
1189 pDstProfileLevel
->eProfile
= pProfileLevel
->profile
;
1190 pDstProfileLevel
->eLevel
= pProfileLevel
->level
;
1193 case OMX_IndexParamVideoProfileLevelCurrent
:
1195 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1196 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1197 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1198 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1201 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1202 if (ret
!= OMX_ErrorNone
) {
1206 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1207 ret
= OMX_ErrorBadPortIndex
;
1211 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1212 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1213 if (codecType
== CODEC_TYPE_MPEG4
) {
1214 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstProfileLevel
->nPortIndex
];
1215 pDstProfileLevel
->eProfile
= pSrcMpeg4Param
->eProfile
;
1216 pDstProfileLevel
->eLevel
= pSrcMpeg4Param
->eLevel
;
1218 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstProfileLevel
->nPortIndex
];
1219 pDstProfileLevel
->eProfile
= pSrcH263Param
->eProfile
;
1220 pDstProfileLevel
->eLevel
= pSrcH263Param
->eLevel
;
1224 case OMX_IndexParamVideoErrorCorrection
:
1226 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1227 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= NULL
;
1228 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1230 ret
= Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1231 if (ret
!= OMX_ErrorNone
) {
1235 if (pDstErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1236 ret
= OMX_ErrorBadPortIndex
;
1240 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1241 pSrcErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1243 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1244 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1245 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1246 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1247 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1251 ret
= Exynos_OMX_VideoDecodeGetParameter(hComponent
, nParamIndex
, pComponentParameterStructure
);
1260 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetParameter(
1261 OMX_IN OMX_HANDLETYPE hComponent
,
1262 OMX_IN OMX_INDEXTYPE nIndex
,
1263 OMX_IN OMX_PTR pComponentParameterStructure
)
1265 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1266 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1267 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1271 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1272 ret
= OMX_ErrorBadParameter
;
1275 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1276 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1277 if (ret
!= OMX_ErrorNone
) {
1280 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1281 ret
= OMX_ErrorBadParameter
;
1285 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1286 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1287 ret
= OMX_ErrorInvalidState
;
1292 case OMX_IndexParamVideoMpeg4
:
1294 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1295 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1296 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1298 ret
= Exynos_OMX_Check_SizeVersion(pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1299 if (ret
!= OMX_ErrorNone
) {
1303 if (pSrcMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1304 ret
= OMX_ErrorBadPortIndex
;
1308 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1309 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcMpeg4Param
->nPortIndex
];
1311 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1314 case OMX_IndexParamVideoH263
:
1316 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1317 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1318 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1320 ret
= Exynos_OMX_Check_SizeVersion(pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1321 if (ret
!= OMX_ErrorNone
) {
1325 if (pSrcH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1326 ret
= OMX_ErrorBadPortIndex
;
1330 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1331 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcH263Param
->nPortIndex
];
1333 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1336 case OMX_IndexParamStandardComponentRole
:
1338 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1340 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1341 if (ret
!= OMX_ErrorNone
) {
1345 if ((pExynosComponent
->currentState
!= OMX_StateLoaded
) && (pExynosComponent
->currentState
!= OMX_StateWaitForResources
)) {
1346 ret
= OMX_ErrorIncorrectStateOperation
;
1350 if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
)) {
1351 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
1352 } else if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
)) {
1353 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
1355 ret
= OMX_ErrorBadParameter
;
1360 case OMX_IndexParamVideoProfileLevelCurrent
:
1362 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pSrcProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1363 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1364 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1365 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1368 ret
= Exynos_OMX_Check_SizeVersion(pSrcProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1369 if (ret
!= OMX_ErrorNone
)
1372 if (pSrcProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1373 ret
= OMX_ErrorBadPortIndex
;
1377 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1378 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1379 if (codecType
== CODEC_TYPE_MPEG4
) {
1381 * To do: Check validity of profile & level parameters
1384 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcProfileLevel
->nPortIndex
];
1385 pDstMpeg4Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1386 pDstMpeg4Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1389 * To do: Check validity of profile & level parameters
1392 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcProfileLevel
->nPortIndex
];
1393 pDstH263Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1394 pDstH263Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1398 case OMX_IndexParamVideoErrorCorrection
:
1400 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1401 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= NULL
;
1402 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1404 ret
= Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1405 if (ret
!= OMX_ErrorNone
) {
1409 if (pSrcErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1410 ret
= OMX_ErrorBadPortIndex
;
1414 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1415 pDstErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1417 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1418 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1419 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1420 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1421 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1425 ret
= Exynos_OMX_VideoDecodeSetParameter(hComponent
, nIndex
, pComponentParameterStructure
);
1434 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetConfig(
1435 OMX_IN OMX_HANDLETYPE hComponent
,
1436 OMX_IN OMX_INDEXTYPE nIndex
,
1437 OMX_IN OMX_PTR pComponentConfigStructure
)
1439 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1440 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1441 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1445 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1446 ret
= OMX_ErrorBadParameter
;
1449 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1450 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1451 if (ret
!= OMX_ErrorNone
) {
1454 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1455 ret
= OMX_ErrorBadParameter
;
1458 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1459 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1460 ret
= OMX_ErrorInvalidState
;
1466 ret
= Exynos_OMX_VideoDecodeGetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1476 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetConfig(
1477 OMX_IN OMX_HANDLETYPE hComponent
,
1478 OMX_IN OMX_INDEXTYPE nIndex
,
1479 OMX_IN OMX_PTR pComponentConfigStructure
)
1481 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1482 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1483 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1487 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1488 ret
= OMX_ErrorBadParameter
;
1491 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1492 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1493 if (ret
!= OMX_ErrorNone
) {
1496 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1497 ret
= OMX_ErrorBadParameter
;
1500 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1501 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1502 ret
= OMX_ErrorInvalidState
;
1508 ret
= Exynos_OMX_VideoDecodeSetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1518 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetExtensionIndex(
1519 OMX_IN OMX_HANDLETYPE hComponent
,
1520 OMX_IN OMX_STRING cParameterName
,
1521 OMX_OUT OMX_INDEXTYPE
*pIndexType
)
1523 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1524 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1525 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1529 if (hComponent
== NULL
) {
1530 ret
= OMX_ErrorBadParameter
;
1533 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1534 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1535 if (ret
!= OMX_ErrorNone
) {
1538 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1539 ret
= OMX_ErrorBadParameter
;
1542 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1543 if ((cParameterName
== NULL
) || (pIndexType
== NULL
)) {
1544 ret
= OMX_ErrorBadParameter
;
1547 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1548 ret
= OMX_ErrorInvalidState
;
1552 if (Exynos_OSAL_Strcmp(cParameterName
, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL
) == 0) {
1553 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1554 *pIndexType
= OMX_IndexVendorThumbnailMode
;
1555 ret
= OMX_ErrorNone
;
1557 ret
= Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent
, cParameterName
, pIndexType
);
1566 OMX_ERRORTYPE
Exynos_Mpeg4Dec_ComponentRoleEnum(
1567 OMX_IN OMX_HANDLETYPE hComponent
,
1568 OMX_OUT OMX_U8
*cRole
,
1569 OMX_IN OMX_U32 nIndex
)
1571 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1572 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1573 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1578 if ((hComponent
== NULL
) || (cRole
== NULL
)) {
1579 ret
= OMX_ErrorBadParameter
;
1582 if (nIndex
!= (MAX_COMPONENT_ROLE_NUM
- 1)) {
1583 ret
= OMX_ErrorNoMore
;
1586 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1587 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1588 if (ret
!= OMX_ErrorNone
) {
1591 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1592 ret
= OMX_ErrorBadParameter
;
1595 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1596 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1597 ret
= OMX_ErrorInvalidState
;
1601 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1602 if (codecType
== CODEC_TYPE_MPEG4
)
1603 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1605 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1614 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Init(OMX_COMPONENTTYPE
*pOMXComponent
)
1616 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1617 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1618 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1619 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1620 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1621 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
1622 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1624 ExynosVideoDecOps
*pDecOps
= NULL
;
1625 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
1626 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
1628 CSC_METHOD csc_method
= CSC_METHOD_SW
;
1633 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_FALSE
;
1634 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_FALSE
;
1635 pExynosComponent
->bUseFlagEOF
= OMX_TRUE
;
1636 pExynosComponent
->bSaveFlagEOS
= OMX_FALSE
;
1638 /* Mpeg4 Codec Open */
1639 ret
= Mpeg4CodecOpen(pMpeg4Dec
);
1640 if (ret
!= OMX_ErrorNone
) {
1644 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1645 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1646 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1648 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1649 OMX_U32 nPlaneSize
[MFC_INPUT_BUFFER_PLANE
] = {DEFAULT_MFC_INPUT_BUFFER_SIZE
};
1650 Exynos_OSAL_SemaphoreCreate(&pExynosInputPort
->codecSemID
);
1651 Exynos_OSAL_QueueCreate(&pExynosInputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1652 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
, nPlaneSize
);
1653 if (ret
!= OMX_ErrorNone
)
1656 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++)
1657 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
1658 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
1662 /* Does not require any actions. */
1665 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1666 Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort
->codecSemID
);
1667 Exynos_OSAL_QueueCreate(&pExynosOutputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1668 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1672 /* Does not require any actions. */
1675 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1676 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hSourceStartEvent
);
1677 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1678 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hDestinationStartEvent
);
1680 Exynos_OSAL_Memset(pExynosComponent
->timeStamp
, -19771003, sizeof(OMX_TICKS
) * MAX_TIMESTAMP
);
1681 Exynos_OSAL_Memset(pExynosComponent
->nFlags
, 0, sizeof(OMX_U32
) * MAX_FLAGS
);
1682 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
= 0;
1683 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= 0;
1685 pExynosComponent
->getAllDelayBuffer
= OMX_FALSE
;
1688 csc_method
= CSC_METHOD_HW
;
1690 pVideoDec
->csc_handle
= csc_init(csc_method
);
1691 if (pVideoDec
->csc_handle
== NULL
) {
1692 ret
= OMX_ErrorInsufficientResources
;
1695 pVideoDec
->csc_set_format
= OMX_FALSE
;
1704 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE
*pOMXComponent
)
1706 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1707 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1708 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1709 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1710 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1711 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1712 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1714 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1715 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1716 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1722 if (pVideoDec
->csc_handle
!= NULL
) {
1723 csc_deinit(pVideoDec
->csc_handle
);
1724 pVideoDec
->csc_handle
= NULL
;
1727 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hDestinationStartEvent
);
1728 pMpeg4Dec
->hDestinationStartEvent
= NULL
;
1729 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1730 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hSourceStartEvent
);
1731 pMpeg4Dec
->hSourceStartEvent
= NULL
;
1732 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1734 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1735 Exynos_Free_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
);
1736 Exynos_OSAL_QueueTerminate(&pExynosOutputPort
->codecBufferQ
);
1737 Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort
->codecSemID
);
1738 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1742 /* Does not require any actions. */
1745 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1746 Exynos_Free_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
);
1747 Exynos_OSAL_QueueTerminate(&pExynosInputPort
->codecBufferQ
);
1748 Exynos_OSAL_SemaphoreTerminate(pExynosInputPort
->codecSemID
);
1749 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
1753 /* Does not require any actions. */
1755 Mpeg4CodecClose(pMpeg4Dec
);
1763 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
1765 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1766 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1767 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1768 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1769 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1770 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1771 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1772 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
1773 OMX_BOOL bInStartCode
= OMX_FALSE
;
1774 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1775 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1776 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1777 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1782 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
== OMX_FALSE
) {
1783 ret
= Mpeg4CodecSrcSetup(pOMXComponent
, pSrcInputData
);
1786 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_FALSE
) {
1787 ret
= Mpeg4CodecDstSetup(pOMXComponent
);
1790 if (((bInStartCode
= Check_Stream_StartCode(pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
, oneFrameSize
, pMpeg4Dec
->hMFCMpeg4Handle
.codecType
)) == OMX_TRUE
) ||
1791 ((pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
1792 pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->timeStamp
;
1793 pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->nFlags
;
1794 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
);
1795 pDecOps
->Set_FrameTag(hMFCHandle
, pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
);
1796 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
++;
1797 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
%= MAX_TIMESTAMP
;
1799 /* queue work for input buffer */
1800 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize
, pSrcInputData
->bufferHeader
, pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
);
1801 codecReturn
= pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
1802 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
);
1803 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1804 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1805 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1808 Mpeg4CodecStart(pOMXComponent
, INPUT_PORT_INDEX
);
1809 if (pMpeg4Dec
->bSourceStart
== OMX_FALSE
) {
1810 pMpeg4Dec
->bSourceStart
= OMX_TRUE
;
1811 Exynos_OSAL_SignalSet(pMpeg4Dec
->hSourceStartEvent
);
1812 Exynos_OSAL_SleepMillisec(0);
1814 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1815 pMpeg4Dec
->bDestinationStart
= OMX_TRUE
;
1816 Exynos_OSAL_SignalSet(pMpeg4Dec
->hDestinationStartEvent
);
1817 Exynos_OSAL_SleepMillisec(0);
1819 } else if (bInStartCode
== OMX_FALSE
) {
1820 ret
= OMX_ErrorCorruptedFrame
;
1824 ret
= OMX_ErrorNone
;
1832 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
1834 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1835 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1836 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1837 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1838 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1839 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1840 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1841 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1842 ExynosVideoBuffer
*pVideoBuffer
;
1846 pVideoBuffer
= pInbufOps
->Dequeue(hMFCHandle
);
1848 pSrcOutputData
->dataLen
= 0;
1849 pSrcOutputData
->usedDataLen
= 0;
1850 pSrcOutputData
->remainDataLen
= 0;
1851 pSrcOutputData
->nFlags
= 0;
1852 pSrcOutputData
->timeStamp
= 0;
1854 if (pVideoBuffer
== NULL
) {
1855 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= NULL
;
1856 pSrcOutputData
->allocSize
= 0;
1857 pSrcOutputData
->pPrivate
= NULL
;
1858 pSrcOutputData
->bufferHeader
= NULL
;
1860 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= pVideoBuffer
->planes
[0].addr
;
1861 pSrcOutputData
->buffer
.singlePlaneBuffer
.fd
= pVideoBuffer
->planes
[0].fd
;
1862 pSrcOutputData
->allocSize
= pVideoBuffer
->planes
[0].allocSize
;
1864 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1866 while (pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
!= pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]) {
1867 if (i
>= MFC_INPUT_BUFFER_NUM_MAX
) {
1868 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
1869 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1874 pVideoDec
->pMFCDecInputBuffer
[i
]->dataSize
= 0;
1875 pSrcOutputData
->pPrivate
= pVideoDec
->pMFCDecInputBuffer
[i
];
1878 /* For Share Buffer */
1879 pSrcOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
1882 ret
= OMX_ErrorNone
;
1890 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
1892 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1893 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1894 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1895 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1896 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1897 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1898 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1899 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1900 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0,};
1901 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1905 if (pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] == NULL
) {
1906 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to find input buffer");
1907 ret
= OMX_ErrorBadParameter
;
1911 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x", __FUNCTION__
, __LINE__
,
1912 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0],
1913 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[1]);
1915 codecReturn
= pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
,
1916 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, pDstInputData
->bufferHeader
);
1918 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1919 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1920 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1923 Mpeg4CodecStart(pOMXComponent
, OUTPUT_PORT_INDEX
);
1925 ret
= OMX_ErrorNone
;
1933 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
1935 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1936 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1937 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1938 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1939 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1940 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1941 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1942 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1943 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1944 ExynosVideoBuffer
*pVideoBuffer
= NULL
;
1945 ExynosVideoFrameStatusType displayStatus
= VIDEO_FRAME_STATUS_UNKNOWN
;
1946 ExynosVideoGeometry
*bufferGeometry
;
1947 DECODE_CODEC_EXTRA_BUFFERINFO
*pBufferInfo
= NULL
;
1948 OMX_S32 indexTimestamp
= 0;
1953 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1954 ret
= OMX_ErrorNone
;
1959 if ((pVideoBuffer
= pOutbufOps
->Dequeue(hMFCHandle
)) == NULL
) {
1960 ret
= OMX_ErrorNone
;
1963 displayStatus
= pVideoBuffer
->displayStatus
;
1964 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus: 0x%x", displayStatus
);
1966 if ((displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_DECODING
) ||
1967 (displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_ONLY
) ||
1968 (displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
1969 (displayStatus
== VIDEO_FRAME_STATUS_DECODING_FINISHED
) ||
1970 (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
1971 ret
= OMX_ErrorNone
;
1976 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
++;
1977 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
%= MAX_TIMESTAMP
;
1979 pDstOutputData
->allocSize
= pDstOutputData
->dataLen
= 0;
1980 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
1981 pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[plane
] = pVideoBuffer
->planes
[plane
].addr
;
1982 pDstOutputData
->buffer
.multiPlaneBuffer
.fd
[plane
] = pVideoBuffer
->planes
[plane
].fd
;
1983 pDstOutputData
->allocSize
+= pVideoBuffer
->planes
[plane
].allocSize
;
1984 pDstOutputData
->dataLen
+= pVideoBuffer
->planes
[plane
].dataSize
;
1986 pDstOutputData
->usedDataLen
= 0;
1987 pDstOutputData
->pPrivate
= pVideoBuffer
;
1988 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1990 pDstOutputData
->pPrivate
= NULL
;
1991 for (i
= 0; i
< MFC_OUTPUT_BUFFER_NUM_MAX
; i
++) {
1992 if (pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] ==
1993 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[0]) {
1994 pDstOutputData
->pPrivate
= pVideoDec
->pMFCDecOutputBuffer
[i
];
1999 if (pDstOutputData
->pPrivate
== NULL
) {
2000 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
2001 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
2006 /* For Share Buffer */
2007 pDstOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
2009 pBufferInfo
= (DECODE_CODEC_EXTRA_BUFFERINFO
*)pDstOutputData
->extInfo
;
2010 bufferGeometry
= &pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
;
2011 pBufferInfo
->imageWidth
= bufferGeometry
->nFrameWidth
;
2012 pBufferInfo
->imageHeight
= bufferGeometry
->nFrameHeight
;
2013 switch (bufferGeometry
->eColorFormat
) {
2014 case VIDEO_COLORFORMAT_NV12
:
2015 pBufferInfo
->ColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
2017 case VIDEO_COLORFORMAT_NV12_TILED
:
2019 pBufferInfo
->ColorFormat
= OMX_SEC_COLOR_FormatNV12Tiled
;
2023 indexTimestamp
= pDecOps
->Get_FrameTag(hMFCHandle
);
2024 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "out indexTimestamp: %d", indexTimestamp
);
2025 if ((indexTimestamp
< 0) || (indexTimestamp
>= MAX_TIMESTAMP
)) {
2026 if ((pExynosComponent
->checkTimeStamp
.needSetStartTimeStamp
!= OMX_TRUE
) &&
2027 (pExynosComponent
->checkTimeStamp
.needCheckStartTimeStamp
!= OMX_TRUE
)) {
2028 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2029 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2030 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "missing out indexTimestamp: %d", indexTimestamp
);
2032 pDstOutputData
->timeStamp
= 0x00;
2033 pDstOutputData
->nFlags
= 0x00;
2036 /* For timestamp correction. if mfc support frametype detect */
2037 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "disp_pic_frame_type: %d", pVideoBuffer
->frameType
);
2038 #ifdef NEED_TIMESTAMP_REORDER
2039 if ((pVideoBuffer
->frameType
== VIDEO_FRAME_I
)) {
2040 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2041 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2042 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= indexTimestamp
;
2044 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2045 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2048 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2049 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2051 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData
->timeStamp
, pDstOutputData
->timeStamp
/ 1E6
, indexTimestamp
, pDstOutputData
->nFlags
);
2054 if ((displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
2055 (displayStatus
== VIDEO_FRAME_STATUS_DECODING_FINISHED
) ||
2056 ((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
2057 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus:%d, nFlags0x%x", displayStatus
, pDstOutputData
->nFlags
);
2058 pDstOutputData
->remainDataLen
= 0;
2060 pDstOutputData
->remainDataLen
= bufferGeometry
->nFrameWidth
* bufferGeometry
->nFrameHeight
* 3 / 2;
2063 ret
= OMX_ErrorNone
;
2071 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
2073 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2074 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2075 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2076 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2080 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2081 ret
= OMX_ErrorNone
;
2084 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2085 ret
= OMX_ErrorNone
;
2089 ret
= Exynos_Mpeg4Dec_SrcIn(pOMXComponent
, pSrcInputData
);
2090 if ((ret
!= OMX_ErrorNone
) &&
2091 (ret
!= OMX_ErrorInputDataDecodeYet
) &&
2092 (ret
!= OMX_ErrorCorruptedFrame
)) {
2093 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2094 pExynosComponent
->callbackData
,
2095 OMX_EventError
, ret
, 0, NULL
);
2104 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
2106 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2107 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2108 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2109 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2113 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2114 ret
= OMX_ErrorNone
;
2118 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
2119 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2120 ret
= OMX_ErrorNone
;
2124 if ((pMpeg4Dec
->bSourceStart
== OMX_FALSE
) &&
2125 (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort
))) {
2126 Exynos_OSAL_SignalWait(pMpeg4Dec
->hSourceStartEvent
, DEF_MAX_WAIT_TIME
);
2127 Exynos_OSAL_SignalReset(pMpeg4Dec
->hSourceStartEvent
);
2130 ret
= Exynos_Mpeg4Dec_SrcOut(pOMXComponent
, pSrcOutputData
);
2131 if ((ret
!= OMX_ErrorNone
) &&
2132 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2133 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2134 pExynosComponent
->callbackData
,
2135 OMX_EventError
, ret
, 0, NULL
);
2144 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
2146 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2147 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2148 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2149 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2153 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2154 ret
= OMX_ErrorNone
;
2157 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2158 ret
= OMX_ErrorNone
;
2161 if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
2162 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2163 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2164 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2165 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2168 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_TRUE
) {
2169 ret
= Exynos_Mpeg4Dec_DstIn(pOMXComponent
, pDstInputData
);
2170 if (ret
!= OMX_ErrorNone
) {
2171 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2172 pExynosComponent
->callbackData
,
2173 OMX_EventError
, ret
, 0, NULL
);
2183 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
2185 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2186 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2187 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2188 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2192 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2193 ret
= OMX_ErrorNone
;
2196 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2197 ret
= OMX_ErrorNone
;
2201 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
2202 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2203 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2204 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2205 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2208 ret
= Exynos_Mpeg4Dec_DstOut(pOMXComponent
, pDstOutputData
);
2209 if ((ret
!= OMX_ErrorNone
) &&
2210 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2211 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2212 pExynosComponent
->callbackData
,
2213 OMX_EventError
, ret
, 0, NULL
);
2222 OSCL_EXPORT_REF OMX_ERRORTYPE
Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent
, OMX_STRING componentName
)
2224 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2225 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2226 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2227 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
2228 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2229 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2231 OMX_S32 codecType
= -1;
2235 if ((hComponent
== NULL
) || (componentName
== NULL
)) {
2236 ret
= OMX_ErrorBadParameter
;
2237 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
2240 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_MPEG4_DEC
, componentName
) == 0) {
2241 codecType
= CODEC_TYPE_MPEG4
;
2242 } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H263_DEC
, componentName
) == 0) {
2243 codecType
= CODEC_TYPE_H263
;
2245 ret
= OMX_ErrorBadParameter
;
2246 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName
, __LINE__
);
2250 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2251 ret
= Exynos_OMX_VideoDecodeComponentInit(pOMXComponent
);
2252 if (ret
!= OMX_ErrorNone
) {
2253 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_Error, Line:%d", __LINE__
);
2256 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2257 pExynosComponent
->codecType
= HW_VIDEO_DEC_CODEC
;
2259 pExynosComponent
->componentName
= (OMX_STRING
)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE
);
2260 if (pExynosComponent
->componentName
== NULL
) {
2261 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2262 ret
= OMX_ErrorInsufficientResources
;
2263 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2266 Exynos_OSAL_Memset(pExynosComponent
->componentName
, 0, MAX_OMX_COMPONENT_NAME_SIZE
);
2268 pMpeg4Dec
= Exynos_OSAL_Malloc(sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2269 if (pMpeg4Dec
== NULL
) {
2270 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2271 ret
= OMX_ErrorInsufficientResources
;
2272 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2275 Exynos_OSAL_Memset(pMpeg4Dec
, 0, sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2276 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2277 pVideoDec
->hCodecHandle
= (OMX_HANDLETYPE
)pMpeg4Dec
;
2278 pMpeg4Dec
->hMFCMpeg4Handle
.codecType
= codecType
;
2280 if (codecType
== CODEC_TYPE_MPEG4
)
2281 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_MPEG4_DEC
);
2283 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_H263_DEC
);
2285 /* Set componentVersion */
2286 pExynosComponent
->componentVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2287 pExynosComponent
->componentVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2288 pExynosComponent
->componentVersion
.s
.nRevision
= REVISION_NUMBER
;
2289 pExynosComponent
->componentVersion
.s
.nStep
= STEP_NUMBER
;
2290 /* Set specVersion */
2291 pExynosComponent
->specVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2292 pExynosComponent
->specVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2293 pExynosComponent
->specVersion
.s
.nRevision
= REVISION_NUMBER
;
2294 pExynosComponent
->specVersion
.s
.nStep
= STEP_NUMBER
;
2297 pExynosPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2298 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2299 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2300 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2301 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2302 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_INPUT_BUFFER_SIZE
;
2303 if (codecType
== CODEC_TYPE_MPEG4
) {
2304 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
2305 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2306 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/mpeg4");
2308 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
2309 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2310 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/h263");
2312 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2313 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2314 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatUnused
;
2315 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2316 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
2317 pExynosPort
->portWayType
= WAY2_PORT
;
2320 pExynosPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2321 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2322 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2323 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2324 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2325 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE
;
2326 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingUnused
;
2327 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2328 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "raw/video");
2329 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2330 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2331 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420Planar
;
2332 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2333 pExynosPort
->bufferProcessType
= BUFFER_COPY
| BUFFER_ANBSHARE
;
2334 pExynosPort
->portWayType
= WAY2_PORT
;
2336 if (codecType
== CODEC_TYPE_MPEG4
) {
2337 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2338 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->mpeg4Component
[i
], OMX_VIDEO_PARAM_MPEG4TYPE
);
2339 pMpeg4Dec
->mpeg4Component
[i
].nPortIndex
= i
;
2340 pMpeg4Dec
->mpeg4Component
[i
].eProfile
= OMX_VIDEO_MPEG4ProfileSimple
;
2341 pMpeg4Dec
->mpeg4Component
[i
].eLevel
= OMX_VIDEO_MPEG4Level3
;
2344 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2345 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->h263Component
[i
], OMX_VIDEO_PARAM_H263TYPE
);
2346 pMpeg4Dec
->h263Component
[i
].nPortIndex
= i
;
2347 pMpeg4Dec
->h263Component
[i
].eProfile
= OMX_VIDEO_H263ProfileBaseline
| OMX_VIDEO_H263ProfileISWV2
;
2348 pMpeg4Dec
->h263Component
[i
].eLevel
= OMX_VIDEO_H263Level45
;
2352 pOMXComponent
->GetParameter
= &Exynos_Mpeg4Dec_GetParameter
;
2353 pOMXComponent
->SetParameter
= &Exynos_Mpeg4Dec_SetParameter
;
2354 pOMXComponent
->GetConfig
= &Exynos_Mpeg4Dec_GetConfig
;
2355 pOMXComponent
->SetConfig
= &Exynos_Mpeg4Dec_SetConfig
;
2356 pOMXComponent
->GetExtensionIndex
= &Exynos_Mpeg4Dec_GetExtensionIndex
;
2357 pOMXComponent
->ComponentRoleEnum
= &Exynos_Mpeg4Dec_ComponentRoleEnum
;
2358 pOMXComponent
->ComponentDeInit
= &Exynos_OMX_ComponentDeinit
;
2360 pExynosComponent
->exynos_codec_componentInit
= &Exynos_Mpeg4Dec_Init
;
2361 pExynosComponent
->exynos_codec_componentTerminate
= &Exynos_Mpeg4Dec_Terminate
;
2363 pVideoDec
->exynos_codec_srcInputProcess
= &Exynos_Mpeg4Dec_srcInputBufferProcess
;
2364 pVideoDec
->exynos_codec_srcOutputProcess
= &Exynos_Mpeg4Dec_srcOutputBufferProcess
;
2365 pVideoDec
->exynos_codec_dstInputProcess
= &Exynos_Mpeg4Dec_dstInputBufferProcess
;
2366 pVideoDec
->exynos_codec_dstOutputProcess
= &Exynos_Mpeg4Dec_dstOutputBufferProcess
;
2368 pVideoDec
->exynos_codec_start
= &Mpeg4CodecStart
;
2369 pVideoDec
->exynos_codec_stop
= &Mpeg4CodecStop
;
2370 pVideoDec
->exynos_codec_bufferProcessRun
= &Mpeg4CodecOutputBufferProcessRun
;
2371 pVideoDec
->exynos_codec_enqueueAllBuffer
= &Mpeg4CodecEnQueueAllBuffer
;
2373 if (codecType
== CODEC_TYPE_MPEG4
)
2374 pVideoDec
->exynos_checkInputFrame
= &Check_Mpeg4_Frame
;
2376 pVideoDec
->exynos_checkInputFrame
= &Check_H263_Frame
;
2378 pVideoDec
->exynos_codec_getCodecInputPrivateData
= &GetCodecInputPrivateData
;
2379 pVideoDec
->exynos_codec_getCodecOutputPrivateData
= &GetCodecOutputPrivateData
;
2381 pVideoDec
->hSharedMemory
= Exynos_OSAL_SharedMemory_Open();
2382 if (pVideoDec
->hSharedMemory
== NULL
) {
2383 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2384 Exynos_OSAL_Free(pMpeg4Dec
);
2385 pMpeg4Dec
= ((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
= NULL
;
2386 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2387 ret
= OMX_ErrorInsufficientResources
;
2391 pExynosComponent
->currentState
= OMX_StateLoaded
;
2393 ret
= OMX_ErrorNone
;
2401 OMX_ERRORTYPE
Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent
)
2403 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2404 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2405 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2406 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2407 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2411 if (hComponent
== NULL
) {
2412 ret
= OMX_ErrorBadParameter
;
2415 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2416 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2417 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2419 Exynos_OSAL_SharedMemory_Close(pVideoDec
->hSharedMemory
);
2421 Exynos_OSAL_Free(pExynosComponent
->componentName
);
2422 pExynosComponent
->componentName
= NULL
;
2424 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
2425 if (pMpeg4Dec
!= NULL
) {
2426 Exynos_OSAL_Free(pMpeg4Dec
);
2427 pMpeg4Dec
= pVideoDec
->hCodecHandle
= NULL
;
2430 ret
= Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2431 if (ret
!= OMX_ErrorNone
) {
2435 ret
= OMX_ErrorNone
;