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 */
413 pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
->Init(V4L2_MEMORY_DMABUF
);
414 if (pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
== NULL
) {
415 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to allocate context buffer");
416 ret
= OMX_ErrorInsufficientResources
;
423 if (ret
!= OMX_ErrorNone
) {
424 if (pDecOps
!= NULL
) {
425 Exynos_OSAL_Free(pDecOps
);
426 pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
= NULL
;
428 if (pInbufOps
!= NULL
) {
429 Exynos_OSAL_Free(pInbufOps
);
430 pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
= NULL
;
432 if (pOutbufOps
!= NULL
) {
433 Exynos_OSAL_Free(pOutbufOps
);
434 pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
= NULL
;
443 OMX_ERRORTYPE
Mpeg4CodecClose(EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
)
445 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
446 void *hMFCHandle
= NULL
;
447 ExynosVideoDecOps
*pDecOps
= NULL
;
448 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
449 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
453 if (pMpeg4Dec
== NULL
) {
454 ret
= OMX_ErrorBadParameter
;
458 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
459 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
460 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
461 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
463 if (hMFCHandle
!= NULL
) {
464 pDecOps
->Finalize(hMFCHandle
);
465 pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
= NULL
;
467 if (pOutbufOps
!= NULL
) {
468 Exynos_OSAL_Free(pOutbufOps
);
469 pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
= NULL
;
471 if (pInbufOps
!= NULL
) {
472 Exynos_OSAL_Free(pInbufOps
);
473 pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
= NULL
;
475 if (pDecOps
!= NULL
) {
476 Exynos_OSAL_Free(pDecOps
);
477 pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
= NULL
;
488 OMX_ERRORTYPE
Mpeg4CodecStart(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
490 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
491 void *hMFCHandle
= NULL
;
492 ExynosVideoDecOps
*pDecOps
= NULL
;
493 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
494 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
495 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
496 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
500 if (pOMXComponent
== NULL
) {
501 ret
= OMX_ErrorBadParameter
;
505 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
506 if (pVideoDec
== NULL
) {
507 ret
= OMX_ErrorBadParameter
;
511 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
512 if (pMpeg4Dec
== NULL
) {
513 ret
= OMX_ErrorBadParameter
;
517 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
518 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
519 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
520 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
522 if (nPortIndex
== INPUT_PORT_INDEX
)
523 pInbufOps
->Run(hMFCHandle
);
524 else if (nPortIndex
== OUTPUT_PORT_INDEX
)
525 pOutbufOps
->Run(hMFCHandle
);
535 OMX_ERRORTYPE
Mpeg4CodecStop(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
537 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
538 void *hMFCHandle
= NULL
;
539 ExynosVideoDecOps
*pDecOps
= NULL
;
540 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
541 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
542 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
543 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
547 if (pOMXComponent
== NULL
) {
548 ret
= OMX_ErrorBadParameter
;
552 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
553 if (pVideoDec
== NULL
) {
554 ret
= OMX_ErrorBadParameter
;
557 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
558 if (pMpeg4Dec
== NULL
) {
559 ret
= OMX_ErrorBadParameter
;
563 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
564 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
565 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
566 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
568 if ((nPortIndex
== INPUT_PORT_INDEX
) && (pInbufOps
!= NULL
))
569 pInbufOps
->Stop(hMFCHandle
);
570 else if ((nPortIndex
== OUTPUT_PORT_INDEX
) && (pOutbufOps
!= NULL
))
571 pOutbufOps
->Stop(hMFCHandle
);
581 OMX_ERRORTYPE
Mpeg4CodecOutputBufferProcessRun(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
583 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
584 void *hMFCHandle
= NULL
;
585 ExynosVideoDecOps
*pDecOps
= NULL
;
586 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
587 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
588 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
589 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
593 if (pOMXComponent
== NULL
) {
594 ret
= OMX_ErrorBadParameter
;
598 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
599 if (pVideoDec
== NULL
) {
600 ret
= OMX_ErrorBadParameter
;
603 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
604 if (pMpeg4Dec
== NULL
) {
605 ret
= OMX_ErrorBadParameter
;
609 hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
610 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
611 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
612 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
614 if (nPortIndex
== INPUT_PORT_INDEX
) {
615 if (pMpeg4Dec
->bSourceStart
== OMX_FALSE
) {
616 Exynos_OSAL_SignalSet(pMpeg4Dec
->hSourceStartEvent
);
617 Exynos_OSAL_SleepMillisec(0);
621 if (nPortIndex
== OUTPUT_PORT_INDEX
) {
622 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
623 Exynos_OSAL_SignalSet(pMpeg4Dec
->hDestinationStartEvent
);
624 Exynos_OSAL_SleepMillisec(0);
636 OMX_ERRORTYPE
Mpeg4CodecRegistCodecBuffers(
637 OMX_COMPONENTTYPE
*pOMXComponent
,
641 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
642 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
643 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
644 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
645 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
646 CODEC_DEC_BUFFER
**ppCodecBuffer
= NULL
;
647 ExynosVideoDecBufferOps
*pBufOps
= NULL
;
648 ExynosVideoPlane
*pPlanes
= NULL
;
650 OMX_U32 nPlaneCnt
= 0;
655 if (nPortIndex
== INPUT_PORT_INDEX
) {
656 ppCodecBuffer
= &(pVideoDec
->pMFCDecInputBuffer
[0]);
657 nPlaneCnt
= MFC_INPUT_BUFFER_PLANE
;
658 pBufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
660 ppCodecBuffer
= &(pVideoDec
->pMFCDecOutputBuffer
[0]);
661 nPlaneCnt
= MFC_OUTPUT_BUFFER_PLANE
;
662 pBufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
665 pPlanes
= (ExynosVideoPlane
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane
) * nPlaneCnt
);
666 if (pPlanes
== NULL
) {
667 ret
= OMX_ErrorInsufficientResources
;
671 /* Register buffer */
672 for (i
= 0; i
< nBufferCnt
; i
++) {
673 for (j
= 0; j
< nPlaneCnt
; j
++) {
674 pPlanes
[j
].addr
= ppCodecBuffer
[i
]->pVirAddr
[j
];
675 pPlanes
[j
].fd
= ppCodecBuffer
[i
]->fd
[j
];
676 pPlanes
[j
].allocSize
= ppCodecBuffer
[i
]->bufferSize
[j
];
679 if (pBufOps
->Register(hMFCHandle
, pPlanes
, nPlaneCnt
) != VIDEO_ERROR_NONE
) {
680 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "PORT[%d]: Failed to Register buffer", nPortIndex
);
681 ret
= OMX_ErrorInsufficientResources
;
682 Exynos_OSAL_Free(pPlanes
);
687 Exynos_OSAL_Free(pPlanes
);
697 OMX_ERRORTYPE
Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
699 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
700 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
701 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
702 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
703 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
704 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
705 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
708 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
709 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
710 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
714 if ((nPortIndex
!= INPUT_PORT_INDEX
) && (nPortIndex
!= OUTPUT_PORT_INDEX
)) {
715 ret
= OMX_ErrorBadPortIndex
;
719 if ((nPortIndex
== INPUT_PORT_INDEX
) &&
720 (pMpeg4Dec
->bSourceStart
== OMX_TRUE
)) {
721 Exynos_CodecBufferReset(pExynosComponent
, INPUT_PORT_INDEX
);
723 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
724 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]);
725 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[0]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]);
727 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
730 pInbufOps
->Clear_Queue(hMFCHandle
);
731 } else if ((nPortIndex
== OUTPUT_PORT_INDEX
) &&
732 (pMpeg4Dec
->bDestinationStart
== OMX_TRUE
)) {
733 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
734 ExynosVideoBuffer
*pBuffer
= NULL
;
736 Exynos_CodecBufferReset(pExynosComponent
, OUTPUT_PORT_INDEX
);
738 nOutbufs
= pDecOps
->Get_ActualBufferCount(hMFCHandle
);
739 nOutbufs
+= EXTRA_DPB_NUM
;
740 for (i
= 0; i
< nOutbufs
; i
++) {
741 Exynos_CodecBufferEnQueue(pExynosComponent
, OUTPUT_PORT_INDEX
, pVideoDec
->pMFCDecOutputBuffer
[i
]);
743 pOutbufOps
->Clear_Queue(hMFCHandle
);
745 ret
= OMX_ErrorBadParameter
;
755 OMX_ERRORTYPE
Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
757 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
758 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
759 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
760 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
761 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
762 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
763 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
764 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
766 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
767 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
768 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
769 ExynosVideoGeometry bufferConf
;
770 OMX_U32 inputBufferNumber
= 0;
775 if ((oneFrameSize
<= 0) && (pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
)) {
776 OMX_BUFFERHEADERTYPE
*OMXBuffer
= NULL
;
777 OMXBuffer
= Exynos_OutputBufferGetQueue_Direct(pExynosComponent
);
778 if (OMXBuffer
== NULL
) {
779 ret
= OMX_ErrorUndefined
;
783 OMXBuffer
->nTimeStamp
= pSrcInputData
->timeStamp
;
784 OMXBuffer
->nFlags
= pSrcInputData
->nFlags
;
785 Exynos_OMX_OutputBufferReturn(pOMXComponent
, OMXBuffer
);
791 if (pVideoDec
->bThumbnailMode
== OMX_TRUE
)
792 pDecOps
->Set_IFrameDecoding(hMFCHandle
);
794 /* input buffer info */
795 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
796 if (pMpeg4Dec
->hMFCMpeg4Handle
.codecType
== CODEC_TYPE_MPEG4
)
797 bufferConf
.eCompressionFormat
= VIDEO_CODING_MPEG4
;
799 bufferConf
.eCompressionFormat
= VIDEO_CODING_H263
;
801 pInbufOps
->Set_Shareable(hMFCHandle
);
802 if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
) {
803 bufferConf
.nSizeImage
= pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
804 * pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
* 3 / 2;
805 inputBufferNumber
= MAX_VIDEO_INPUTBUFFER_NUM
;
806 } else if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
807 bufferConf
.nSizeImage
= DEFAULT_MFC_INPUT_BUFFER_SIZE
;
808 inputBufferNumber
= MFC_INPUT_BUFFER_NUM_MAX
;
811 /* should be done before prepare input buffer */
812 if (pInbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
813 ret
= OMX_ErrorInsufficientResources
;
817 /* set input buffer geometry */
818 if (pInbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
819 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for input buffer");
820 ret
= OMX_ErrorInsufficientResources
;
824 /* setup input buffer */
825 if (pInbufOps
->Setup(hMFCHandle
, inputBufferNumber
) != VIDEO_ERROR_NONE
) {
826 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup input buffer");
827 ret
= OMX_ErrorInsufficientResources
;
831 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
832 ret
= Mpeg4CodecRegistCodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
);
833 if (ret
!= OMX_ErrorNone
)
835 } else if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
) {
836 /* Register input buffer */
837 for (i
= 0; i
< pExynosInputPort
->portDefinition
.nBufferCountActual
; i
++) {
838 ExynosVideoPlane plane
;
839 plane
.addr
= pExynosInputPort
->extendBufferHeader
[i
].OMXBufferHeader
->pBuffer
;
840 plane
.allocSize
= pExynosInputPort
->extendBufferHeader
[i
].OMXBufferHeader
->nAllocLen
;
841 plane
.fd
= pExynosInputPort
->extendBufferHeader
[i
].buf_fd
[0];
842 if (pInbufOps
->Register(hMFCHandle
, &plane
, MFC_INPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
843 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register input buffer");
844 ret
= OMX_ErrorInsufficientResources
;
850 /* set output geometry */
851 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
852 pMpeg4Dec
->hMFCMpeg4Handle
.MFCOutputColorType
= bufferConf
.eColorFormat
= VIDEO_COLORFORMAT_NV12_TILED
;
853 if (pOutbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
854 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for output buffer");
855 ret
= OMX_ErrorInsufficientResources
;
859 /* input buffer enqueue for header parsing */
860 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d", oneFrameSize
);
861 if (pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
862 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
) != VIDEO_ERROR_NONE
) {
863 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to enqueue input buffer for header parsing");
864 // ret = OMX_ErrorInsufficientResources;
865 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecInit
;
869 /* start header parsing */
870 if (pInbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
871 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run input buffer for header parsing");
872 ret
= OMX_ErrorCodecInit
;
876 /* get geometry for output */
877 Exynos_OSAL_Memset(&pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
, 0, sizeof(ExynosVideoGeometry
));
878 if (pOutbufOps
->Get_Geometry(hMFCHandle
, &pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
) != VIDEO_ERROR_NONE
) {
879 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to get geometry for parsed header info");
880 ret
= OMX_ErrorInsufficientResources
;
885 pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
= pDecOps
->Get_ActualBufferCount(hMFCHandle
);
886 if (pVideoDec
->bThumbnailMode
== OMX_FALSE
)
887 pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
+= EXTRA_DPB_NUM
;
888 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Mpeg4CodecSetup nOutbufs: %d", pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
);
890 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_TRUE
;
892 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
893 if ((pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
) ||
894 (pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
)) {
895 pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
896 pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
897 pExynosInputPort
->portDefinition
.format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
898 pExynosInputPort
->portDefinition
.format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
900 Exynos_UpdateFrameSize(pOMXComponent
);
901 pExynosOutputPort
->exceptionFlag
= NEED_PORT_DISABLE
;
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 pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
917 pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
918 pExynosInputPort
->portDefinition
.format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
919 pExynosInputPort
->portDefinition
.format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
921 pExynosOutputPort
->portDefinition
.nBufferCountActual
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
922 pExynosOutputPort
->portDefinition
.nBufferCountMin
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
924 Exynos_UpdateFrameSize(pOMXComponent
);
925 pExynosOutputPort
->exceptionFlag
= NEED_PORT_DISABLE
;
927 /** Send Port Settings changed call back **/
928 (*(pExynosComponent
->pCallbacks
->EventHandler
))
930 pExynosComponent
->callbackData
,
931 OMX_EventPortSettingsChanged
, /* The command was completed */
932 OMX_DirOutput
, /* This is the port index */
937 Exynos_OSAL_SleepMillisec(0);
938 ret
= OMX_ErrorInputDataDecodeYet
;
939 Mpeg4CodecStop(pOMXComponent
, INPUT_PORT_INDEX
);
947 OMX_ERRORTYPE
Mpeg4CodecDstSetup(OMX_COMPONENTTYPE
*pOMXComponent
)
949 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
950 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
951 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
952 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
953 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
954 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
955 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
957 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
958 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
959 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
965 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
966 /* BUFFER_COPY case, get dpb count */
967 nOutbufs
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
969 /* should be done before prepare output buffer */
970 if (pOutbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
971 ret
= OMX_ErrorInsufficientResources
;
975 /*BUFFER_SHERE case, get dpb count */
976 nOutbufs
= pExynosOutputPort
->portDefinition
.nBufferCountActual
;
979 if (pOutbufOps
->Enable_DynamicDPB(hMFCHandle
) != VIDEO_ERROR_NONE
) {
980 ret
= OMX_ErrorUndefined
;
984 pOutbufOps
->Set_Shareable(hMFCHandle
);
985 if (pOutbufOps
->Setup(hMFCHandle
, MAX_OUTPUTBUFFER_NUM_DYNAMIC
) != VIDEO_ERROR_NONE
) {
986 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup output buffer");
987 ret
= OMX_ErrorInsufficientResources
;
991 ExynosVideoPlane planes
[MFC_OUTPUT_BUFFER_PLANE
];
992 OMX_U32 nAllocLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
993 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
996 nAllocLen
[0] = calc_plane(pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
,
997 pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
);
998 nAllocLen
[1] = calc_plane(pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
,
999 pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
>> 1);
1001 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1002 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, nOutbufs
, nAllocLen
);
1003 if (ret
!= OMX_ErrorNone
)
1006 for (i
= 0; i
< nOutbufs
; i
++) {
1007 /* Enqueue output buffer */
1008 pOutbufOps
->ExtensionEnqueue(hMFCHandle
,
1009 (unsigned char **)pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
,
1010 (unsigned char **)pVideoDec
->pMFCDecOutputBuffer
[i
]->fd
,
1011 (unsigned int *)pVideoDec
->pMFCDecOutputBuffer
[i
]->bufferSize
,
1012 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
1015 if (pOutbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
1016 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run output buffer");
1017 ret
= OMX_ErrorInsufficientResources
;
1020 } else if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
) {
1025 if ((pExynosOutputPort
->bIsANBEnabled
== OMX_FALSE
) &&
1026 (pExynosOutputPort
->bStoreMetaData
== OMX_FALSE
)) {
1027 ret
= OMX_ErrorNotImplemented
;
1031 ret
= OMX_ErrorNotImplemented
;
1036 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_TRUE
;
1038 ret
= OMX_ErrorNone
;
1046 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetParameter(
1047 OMX_IN OMX_HANDLETYPE hComponent
,
1048 OMX_IN OMX_INDEXTYPE nParamIndex
,
1049 OMX_INOUT OMX_PTR pComponentParameterStructure
)
1051 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1052 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1053 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1057 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1058 ret
= OMX_ErrorBadParameter
;
1061 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1062 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1063 if (ret
!= OMX_ErrorNone
) {
1066 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1067 ret
= OMX_ErrorBadParameter
;
1071 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1072 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1073 ret
= OMX_ErrorInvalidState
;
1077 switch (nParamIndex
) {
1078 case OMX_IndexParamVideoMpeg4
:
1080 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1081 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1082 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1084 ret
= Exynos_OMX_Check_SizeVersion(pDstMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1085 if (ret
!= OMX_ErrorNone
) {
1089 if (pDstMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1090 ret
= OMX_ErrorBadPortIndex
;
1094 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1095 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstMpeg4Param
->nPortIndex
];
1097 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1100 case OMX_IndexParamVideoH263
:
1102 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1103 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1104 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1106 ret
= Exynos_OMX_Check_SizeVersion(pDstH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1107 if (ret
!= OMX_ErrorNone
) {
1111 if (pDstH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1112 ret
= OMX_ErrorBadPortIndex
;
1116 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1117 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstH263Param
->nPortIndex
];
1119 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1122 case OMX_IndexParamStandardComponentRole
:
1125 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1127 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1128 if (ret
!= OMX_ErrorNone
) {
1132 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1133 if (codecType
== CODEC_TYPE_MPEG4
)
1134 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1136 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1139 case OMX_IndexParamVideoProfileLevelQuerySupported
:
1141 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1142 EXYNOS_OMX_VIDEO_PROFILELEVEL
*pProfileLevel
= NULL
;
1143 OMX_U32 maxProfileLevelNum
= 0;
1146 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1147 if (ret
!= OMX_ErrorNone
) {
1151 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1152 ret
= OMX_ErrorBadPortIndex
;
1156 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1157 if (codecType
== CODEC_TYPE_MPEG4
) {
1158 pProfileLevel
= supportedMPEG4ProfileLevels
;
1159 maxProfileLevelNum
= sizeof(supportedMPEG4ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1161 pProfileLevel
= supportedH263ProfileLevels
;
1162 maxProfileLevelNum
= sizeof(supportedH263ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1165 if (pDstProfileLevel
->nProfileIndex
>= maxProfileLevelNum
) {
1166 ret
= OMX_ErrorNoMore
;
1170 pProfileLevel
+= pDstProfileLevel
->nProfileIndex
;
1171 pDstProfileLevel
->eProfile
= pProfileLevel
->profile
;
1172 pDstProfileLevel
->eLevel
= pProfileLevel
->level
;
1175 case OMX_IndexParamVideoProfileLevelCurrent
:
1177 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1178 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1179 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1180 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1183 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1184 if (ret
!= OMX_ErrorNone
) {
1188 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1189 ret
= OMX_ErrorBadPortIndex
;
1193 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1194 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1195 if (codecType
== CODEC_TYPE_MPEG4
) {
1196 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstProfileLevel
->nPortIndex
];
1197 pDstProfileLevel
->eProfile
= pSrcMpeg4Param
->eProfile
;
1198 pDstProfileLevel
->eLevel
= pSrcMpeg4Param
->eLevel
;
1200 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstProfileLevel
->nPortIndex
];
1201 pDstProfileLevel
->eProfile
= pSrcH263Param
->eProfile
;
1202 pDstProfileLevel
->eLevel
= pSrcH263Param
->eLevel
;
1206 case OMX_IndexParamVideoErrorCorrection
:
1208 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1209 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= NULL
;
1210 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1212 ret
= Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1213 if (ret
!= OMX_ErrorNone
) {
1217 if (pDstErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1218 ret
= OMX_ErrorBadPortIndex
;
1222 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1223 pSrcErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1225 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1226 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1227 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1228 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1229 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1233 ret
= Exynos_OMX_VideoDecodeGetParameter(hComponent
, nParamIndex
, pComponentParameterStructure
);
1242 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetParameter(
1243 OMX_IN OMX_HANDLETYPE hComponent
,
1244 OMX_IN OMX_INDEXTYPE nIndex
,
1245 OMX_IN OMX_PTR pComponentParameterStructure
)
1247 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1248 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1249 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1253 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1254 ret
= OMX_ErrorBadParameter
;
1257 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1258 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1259 if (ret
!= OMX_ErrorNone
) {
1262 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1263 ret
= OMX_ErrorBadParameter
;
1267 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1268 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1269 ret
= OMX_ErrorInvalidState
;
1274 case OMX_IndexParamVideoMpeg4
:
1276 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1277 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1278 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1280 ret
= Exynos_OMX_Check_SizeVersion(pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1281 if (ret
!= OMX_ErrorNone
) {
1285 if (pSrcMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1286 ret
= OMX_ErrorBadPortIndex
;
1290 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1291 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcMpeg4Param
->nPortIndex
];
1293 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1296 case OMX_IndexParamVideoH263
:
1298 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1299 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1300 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1302 ret
= Exynos_OMX_Check_SizeVersion(pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1303 if (ret
!= OMX_ErrorNone
) {
1307 if (pSrcH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1308 ret
= OMX_ErrorBadPortIndex
;
1312 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1313 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcH263Param
->nPortIndex
];
1315 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1318 case OMX_IndexParamStandardComponentRole
:
1320 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1322 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1323 if (ret
!= OMX_ErrorNone
) {
1327 if ((pExynosComponent
->currentState
!= OMX_StateLoaded
) && (pExynosComponent
->currentState
!= OMX_StateWaitForResources
)) {
1328 ret
= OMX_ErrorIncorrectStateOperation
;
1332 if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
)) {
1333 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
1334 } else if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
)) {
1335 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
1337 ret
= OMX_ErrorBadParameter
;
1342 case OMX_IndexParamVideoProfileLevelCurrent
:
1344 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pSrcProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1345 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1346 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1347 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1350 ret
= Exynos_OMX_Check_SizeVersion(pSrcProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1351 if (ret
!= OMX_ErrorNone
)
1354 if (pSrcProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1355 ret
= OMX_ErrorBadPortIndex
;
1359 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1360 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1361 if (codecType
== CODEC_TYPE_MPEG4
) {
1363 * To do: Check validity of profile & level parameters
1366 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcProfileLevel
->nPortIndex
];
1367 pDstMpeg4Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1368 pDstMpeg4Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1371 * To do: Check validity of profile & level parameters
1374 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcProfileLevel
->nPortIndex
];
1375 pDstH263Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1376 pDstH263Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1380 case OMX_IndexParamVideoErrorCorrection
:
1382 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1383 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= NULL
;
1384 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1386 ret
= Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1387 if (ret
!= OMX_ErrorNone
) {
1391 if (pSrcErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1392 ret
= OMX_ErrorBadPortIndex
;
1396 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1397 pDstErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1399 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1400 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1401 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1402 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1403 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1407 ret
= Exynos_OMX_VideoDecodeSetParameter(hComponent
, nIndex
, pComponentParameterStructure
);
1416 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetConfig(
1417 OMX_IN OMX_HANDLETYPE hComponent
,
1418 OMX_IN OMX_INDEXTYPE nIndex
,
1419 OMX_IN OMX_PTR pComponentConfigStructure
)
1421 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1422 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1423 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1427 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1428 ret
= OMX_ErrorBadParameter
;
1431 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1432 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1433 if (ret
!= OMX_ErrorNone
) {
1436 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1437 ret
= OMX_ErrorBadParameter
;
1440 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1441 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1442 ret
= OMX_ErrorInvalidState
;
1448 ret
= Exynos_OMX_VideoDecodeGetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1458 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetConfig(
1459 OMX_IN OMX_HANDLETYPE hComponent
,
1460 OMX_IN OMX_INDEXTYPE nIndex
,
1461 OMX_IN OMX_PTR pComponentConfigStructure
)
1463 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1464 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1465 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1469 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1470 ret
= OMX_ErrorBadParameter
;
1473 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1474 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1475 if (ret
!= OMX_ErrorNone
) {
1478 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1479 ret
= OMX_ErrorBadParameter
;
1482 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1483 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1484 ret
= OMX_ErrorInvalidState
;
1490 ret
= Exynos_OMX_VideoDecodeSetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1500 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetExtensionIndex(
1501 OMX_IN OMX_HANDLETYPE hComponent
,
1502 OMX_IN OMX_STRING cParameterName
,
1503 OMX_OUT OMX_INDEXTYPE
*pIndexType
)
1505 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1506 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1507 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1511 if (hComponent
== NULL
) {
1512 ret
= OMX_ErrorBadParameter
;
1515 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1516 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1517 if (ret
!= OMX_ErrorNone
) {
1520 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1521 ret
= OMX_ErrorBadParameter
;
1524 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1525 if ((cParameterName
== NULL
) || (pIndexType
== NULL
)) {
1526 ret
= OMX_ErrorBadParameter
;
1529 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1530 ret
= OMX_ErrorInvalidState
;
1534 ret
= Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent
, cParameterName
, pIndexType
);
1542 OMX_ERRORTYPE
Exynos_Mpeg4Dec_ComponentRoleEnum(
1543 OMX_IN OMX_HANDLETYPE hComponent
,
1544 OMX_OUT OMX_U8
*cRole
,
1545 OMX_IN OMX_U32 nIndex
)
1547 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1548 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1549 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1554 if ((hComponent
== NULL
) || (cRole
== NULL
)) {
1555 ret
= OMX_ErrorBadParameter
;
1558 if (nIndex
!= (MAX_COMPONENT_ROLE_NUM
- 1)) {
1559 ret
= OMX_ErrorNoMore
;
1562 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1563 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1564 if (ret
!= OMX_ErrorNone
) {
1567 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1568 ret
= OMX_ErrorBadParameter
;
1571 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1572 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1573 ret
= OMX_ErrorInvalidState
;
1577 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1578 if (codecType
== CODEC_TYPE_MPEG4
)
1579 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1581 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1590 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Init(OMX_COMPONENTTYPE
*pOMXComponent
)
1592 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1593 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1594 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1595 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1596 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1597 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
1598 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1600 ExynosVideoDecOps
*pDecOps
= NULL
;
1601 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
1602 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
1604 CSC_METHOD csc_method
= CSC_METHOD_SW
;
1609 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_FALSE
;
1610 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_FALSE
;
1611 pExynosComponent
->bUseFlagEOF
= OMX_TRUE
;
1612 pExynosComponent
->bSaveFlagEOS
= OMX_FALSE
;
1613 pExynosComponent
->bBehaviorEOS
= OMX_FALSE
;
1615 /* H.264 Codec Open */
1616 ret
= Mpeg4CodecOpen(pMpeg4Dec
);
1617 if (ret
!= OMX_ErrorNone
) {
1621 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1622 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1623 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1625 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1626 OMX_U32 nPlaneSize
[MFC_INPUT_BUFFER_PLANE
] = {DEFAULT_MFC_INPUT_BUFFER_SIZE
};
1627 Exynos_OSAL_SemaphoreCreate(&pExynosInputPort
->codecSemID
);
1628 Exynos_OSAL_QueueCreate(&pExynosInputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1629 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
, nPlaneSize
);
1630 if (ret
!= OMX_ErrorNone
)
1633 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++)
1634 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
1635 } else if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
) {
1639 /* Does not require any actions. */
1642 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1643 Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort
->codecSemID
);
1644 Exynos_OSAL_QueueCreate(&pExynosOutputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1645 } else if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
) {
1649 /* Does not require any actions. */
1652 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1653 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hSourceStartEvent
);
1654 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1655 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hDestinationStartEvent
);
1657 Exynos_OSAL_Memset(pExynosComponent
->timeStamp
, -19771003, sizeof(OMX_TICKS
) * MAX_TIMESTAMP
);
1658 Exynos_OSAL_Memset(pExynosComponent
->nFlags
, 0, sizeof(OMX_U32
) * MAX_FLAGS
);
1659 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
= 0;
1660 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= 0;
1662 pExynosComponent
->getAllDelayBuffer
= OMX_FALSE
;
1664 #if 0//defined(USE_CSC_GSCALER)
1665 csc_method
= CSC_METHOD_HW
; //in case of Use ION buffer.
1667 pVideoDec
->csc_handle
= csc_init(csc_method
);
1668 if (pVideoDec
->csc_handle
== NULL
) {
1669 ret
= OMX_ErrorInsufficientResources
;
1672 pVideoDec
->csc_set_format
= OMX_FALSE
;
1681 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE
*pOMXComponent
)
1683 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1684 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1685 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1686 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1687 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1688 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1689 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1691 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1692 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1693 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1699 if (pVideoDec
->csc_handle
!= NULL
) {
1700 csc_deinit(pVideoDec
->csc_handle
);
1701 pVideoDec
->csc_handle
= NULL
;
1704 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hDestinationStartEvent
);
1705 pMpeg4Dec
->hDestinationStartEvent
= NULL
;
1706 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1707 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hSourceStartEvent
);
1708 pMpeg4Dec
->hSourceStartEvent
= NULL
;
1709 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1711 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1712 Exynos_Free_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
);
1713 Exynos_OSAL_QueueTerminate(&pExynosOutputPort
->codecBufferQ
);
1714 Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort
->codecSemID
);
1715 } else if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
) {
1719 /* Does not require any actions. */
1722 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1723 Exynos_Free_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
);
1724 Exynos_OSAL_QueueTerminate(&pExynosInputPort
->codecBufferQ
);
1725 Exynos_OSAL_SemaphoreTerminate(pExynosInputPort
->codecSemID
);
1726 } else if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
) {
1730 /* Does not require any actions. */
1732 Mpeg4CodecClose(pMpeg4Dec
);
1734 Exynos_ResetAllPortConfig(pOMXComponent
);
1742 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
1744 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1745 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1746 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1747 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1748 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1749 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1750 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1751 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
1752 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1753 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1754 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1755 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1760 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
== OMX_FALSE
) {
1761 ret
= Mpeg4CodecSrcSetup(pOMXComponent
, pSrcInputData
);
1764 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_FALSE
) {
1765 ret
= Mpeg4CodecDstSetup(pOMXComponent
);
1768 if ((Check_Stream_StartCode(pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
, oneFrameSize
, pMpeg4Dec
->hMFCMpeg4Handle
.codecType
) == OMX_TRUE
) ||
1769 ((pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
1770 pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->timeStamp
;
1771 pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->nFlags
;
1772 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
);
1773 pDecOps
->Set_FrameTag(hMFCHandle
, pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
);
1774 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
++;
1775 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
%= MAX_TIMESTAMP
;
1777 /* queue work for input buffer */
1778 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize
, pSrcInputData
->bufferHeader
, pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
);
1779 codecReturn
= pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
1780 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
);
1781 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1782 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1783 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1786 Mpeg4CodecStart(pOMXComponent
, INPUT_PORT_INDEX
);
1787 if (pMpeg4Dec
->bSourceStart
== OMX_FALSE
) {
1788 pMpeg4Dec
->bSourceStart
= OMX_TRUE
;
1789 Exynos_OSAL_SignalSet(pMpeg4Dec
->hSourceStartEvent
);
1790 Exynos_OSAL_SleepMillisec(0);
1792 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1793 pMpeg4Dec
->bDestinationStart
= OMX_TRUE
;
1794 Exynos_OSAL_SignalSet(pMpeg4Dec
->hDestinationStartEvent
);
1795 Exynos_OSAL_SleepMillisec(0);
1799 ret
= OMX_ErrorNone
;
1807 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
1809 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1810 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1811 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1812 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1813 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1814 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1815 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1816 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1817 ExynosVideoBuffer
*pVideoBuffer
;
1821 pVideoBuffer
= pInbufOps
->Dequeue(hMFCHandle
);
1823 pSrcOutputData
->dataLen
= 0;
1824 pSrcOutputData
->usedDataLen
= 0;
1825 pSrcOutputData
->remainDataLen
= 0;
1826 pSrcOutputData
->nFlags
= 0;
1827 pSrcOutputData
->timeStamp
= 0;
1829 if (pVideoBuffer
== NULL
) {
1830 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= NULL
;
1831 pSrcOutputData
->allocSize
= 0;
1832 pSrcOutputData
->pPrivate
= NULL
;
1833 pSrcOutputData
->bufferHeader
= NULL
;
1835 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= pVideoBuffer
->planes
[0].addr
;
1836 pSrcOutputData
->buffer
.singlePlaneBuffer
.fd
= pVideoBuffer
->planes
[0].fd
;
1837 pSrcOutputData
->allocSize
= pVideoBuffer
->planes
[0].allocSize
;
1839 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
1841 while (pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
!= pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]) {
1842 if (i
>= MFC_INPUT_BUFFER_NUM_MAX
) {
1843 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
1844 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1849 pVideoDec
->pMFCDecInputBuffer
[i
]->dataSize
= 0;
1850 pSrcOutputData
->pPrivate
= pVideoDec
->pMFCDecInputBuffer
[i
];
1853 /* For Share Buffer */
1854 pSrcOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
1857 ret
= OMX_ErrorNone
;
1865 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
1867 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1868 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1869 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1870 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1871 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1872 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1873 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1874 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1875 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0,};
1876 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1880 if (pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] == NULL
) {
1881 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to find input buffer");
1882 ret
= OMX_ErrorBadParameter
;
1886 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x, FD[0]:%d, FD[1]:%d", __FUNCTION__
, __LINE__
,
1887 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0],
1888 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[1],
1889 pDstInputData
->buffer
.multiPlaneBuffer
.fd
[0],
1890 pDstInputData
->buffer
.multiPlaneBuffer
.fd
[1]);
1892 OMX_U32 nAllocLen
[VIDEO_BUFFER_MAX_PLANES
] = {0, 0, 0};
1893 nAllocLen
[0] = pExynosOutputPort
->portDefinition
.format
.video
.nFrameWidth
* pExynosOutputPort
->portDefinition
.format
.video
.nFrameHeight
;
1894 nAllocLen
[1] = pExynosOutputPort
->portDefinition
.format
.video
.nFrameWidth
* pExynosOutputPort
->portDefinition
.format
.video
.nFrameHeight
/ 2;
1896 codecReturn
= pOutbufOps
->ExtensionEnqueue(hMFCHandle
,
1897 (unsigned char **)pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
,
1898 (unsigned int **)pDstInputData
->buffer
.multiPlaneBuffer
.fd
,
1899 (unsigned int *)nAllocLen
, (unsigned int *)dataLen
,
1900 MFC_OUTPUT_BUFFER_PLANE
, pDstInputData
->bufferHeader
);
1901 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1902 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1903 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1906 Mpeg4CodecStart(pOMXComponent
, OUTPUT_PORT_INDEX
);
1908 ret
= OMX_ErrorNone
;
1916 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
1918 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1919 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1920 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1921 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1922 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1923 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1924 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1925 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1926 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1927 ExynosVideoBuffer
*pVideoBuffer
;
1928 ExynosVideoBuffer videoBuffer
;
1929 ExynosVideoFrameStatusType displayStatus
= VIDEO_FRAME_STATUS_UNKNOWN
;
1930 ExynosVideoGeometry
*bufferGeometry
;
1931 DECODE_CODEC_EXTRA_BUFFERINFO
*pBufferInfo
= NULL
;
1932 OMX_S32 indexTimestamp
= 0;
1937 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1938 ret
= OMX_ErrorNone
;
1943 Exynos_OSAL_Memset(&videoBuffer
, 0, sizeof(ExynosVideoBuffer
));
1944 if (pOutbufOps
->ExtensionDequeue(hMFCHandle
, &videoBuffer
) == VIDEO_ERROR_NONE
) {
1945 pVideoBuffer
= &videoBuffer
;
1947 pVideoBuffer
= NULL
;
1948 ret
= OMX_ErrorNone
;
1951 displayStatus
= pVideoBuffer
->displayStatus
;
1952 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus: 0x%x", displayStatus
);
1954 if ((displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_DECODING
) ||
1955 (displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_ONLY
) ||
1956 (displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
1957 (displayStatus
== VIDEO_FRAME_STATUS_DECODING_FINISHED
) ||
1958 (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
1959 if (pVideoBuffer
!= NULL
) {
1960 ret
= OMX_ErrorNone
;
1963 ret
= OMX_ErrorUndefined
;
1969 if (ret
!= OMX_ErrorNone
)
1972 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
++;
1973 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
%= MAX_TIMESTAMP
;
1975 pDstOutputData
->allocSize
= pDstOutputData
->dataLen
= 0;
1976 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
1977 pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[plane
] = pVideoBuffer
->planes
[plane
].addr
;
1978 pDstOutputData
->buffer
.multiPlaneBuffer
.fd
[plane
] = pVideoBuffer
->planes
[plane
].fd
;
1979 pDstOutputData
->allocSize
+= pVideoBuffer
->planes
[plane
].allocSize
;
1980 pDstOutputData
->dataLen
+= pVideoBuffer
->planes
[plane
].dataSize
;
1982 pDstOutputData
->usedDataLen
= 0;
1983 pDstOutputData
->pPrivate
= pVideoBuffer
;
1984 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1986 pDstOutputData
->pPrivate
= NULL
;
1987 for (i
= 0; i
< MFC_OUTPUT_BUFFER_NUM_MAX
; i
++) {
1988 if (pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] ==
1989 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[0]) {
1990 pDstOutputData
->pPrivate
= pVideoDec
->pMFCDecOutputBuffer
[i
];
1991 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x, FD[0]:%d, FD[1]:%d", __FUNCTION__
, __LINE__
,
1992 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[0],
1993 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[1],
1994 pVideoDec
->pMFCDecOutputBuffer
[i
]->fd
[0],
1995 pVideoDec
->pMFCDecOutputBuffer
[i
]->fd
[1]);
2000 if (pDstOutputData
->pPrivate
== NULL
) {
2001 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
2002 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 Exynos_OSAL_Memcpy(&pBufferInfo
->PDSB
, &pVideoBuffer
->PDSB
, sizeof(PrivateDataShareBuffer
));
2014 switch (bufferGeometry
->eColorFormat
) {
2015 case VIDEO_COLORFORMAT_NV12
:
2016 pBufferInfo
->ColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
2018 case VIDEO_COLORFORMAT_NV12_TILED
:
2020 pBufferInfo
->ColorFormat
= OMX_SEC_COLOR_FormatNV12Tiled
;
2024 indexTimestamp
= pDecOps
->Get_FrameTag(hMFCHandle
);
2025 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "out indexTimestamp: %d", indexTimestamp
);
2026 if ((indexTimestamp
< 0) || (indexTimestamp
>= MAX_TIMESTAMP
)) {
2027 if ((pExynosComponent
->checkTimeStamp
.needSetStartTimeStamp
!= OMX_TRUE
) &&
2028 (pExynosComponent
->checkTimeStamp
.needCheckStartTimeStamp
!= OMX_TRUE
)) {
2029 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2030 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2031 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "missing out indexTimestamp: %d", indexTimestamp
);
2033 pDstOutputData
->timeStamp
= 0x00;
2034 pDstOutputData
->nFlags
= 0x00;
2037 /* For timestamp correction. if mfc support frametype detect */
2038 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "disp_pic_frame_type: %d", pVideoBuffer
->frameType
);
2039 #ifdef NEED_TIMESTAMP_REORDER
2040 if ((pVideoBuffer
->frameType
== VIDEO_FRAME_I
)) {
2041 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2042 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2043 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= indexTimestamp
;
2045 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2046 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2049 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2050 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2052 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData
->timeStamp
, pDstOutputData
->timeStamp
/ 1E6
, indexTimestamp
, pDstOutputData
->nFlags
);
2055 if ((displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
2056 (displayStatus
== VIDEO_FRAME_STATUS_DECODING_FINISHED
) ||
2057 ((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
2058 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus:%d, nFlags0x%x", displayStatus
, pDstOutputData
->nFlags
);
2059 pDstOutputData
->remainDataLen
= 0;
2060 if (((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
) &&
2061 (pExynosComponent
->bBehaviorEOS
== OMX_TRUE
)) {
2062 pDstOutputData
->remainDataLen
= bufferGeometry
->nFrameWidth
* bufferGeometry
->nFrameHeight
* 3 / 2;
2063 pExynosComponent
->bBehaviorEOS
= OMX_FALSE
;
2066 pDstOutputData
->remainDataLen
= bufferGeometry
->nFrameWidth
* bufferGeometry
->nFrameHeight
* 3 / 2;
2069 ret
= OMX_ErrorNone
;
2077 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
2079 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2080 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2081 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2082 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2086 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2087 ret
= OMX_ErrorNone
;
2090 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2091 ret
= OMX_ErrorNone
;
2095 ret
= Exynos_Mpeg4Dec_SrcIn(pOMXComponent
, pSrcInputData
);
2096 if ((ret
!= OMX_ErrorNone
) && (ret
!= OMX_ErrorInputDataDecodeYet
)) {
2097 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2098 pExynosComponent
->callbackData
,
2099 OMX_EventError
, ret
, 0, NULL
);
2108 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
2110 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2111 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2112 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2113 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2117 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2118 ret
= OMX_ErrorNone
;
2122 if ((pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
2123 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2124 ret
= OMX_ErrorNone
;
2128 if ((pMpeg4Dec
->bSourceStart
== OMX_FALSE
) &&
2129 (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort
))) {
2130 Exynos_OSAL_SignalWait(pMpeg4Dec
->hSourceStartEvent
, DEF_MAX_WAIT_TIME
);
2131 Exynos_OSAL_SignalReset(pMpeg4Dec
->hSourceStartEvent
);
2134 ret
= Exynos_Mpeg4Dec_SrcOut(pOMXComponent
, pSrcOutputData
);
2135 if ((ret
!= OMX_ErrorNone
) &&
2136 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2137 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2138 pExynosComponent
->callbackData
,
2139 OMX_EventError
, ret
, 0, NULL
);
2148 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
2150 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2151 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2152 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2153 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2157 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2158 ret
= OMX_ErrorNone
;
2161 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2162 ret
= OMX_ErrorNone
;
2165 if (pExynosOutputPort
->bufferProcessType
== BUFFER_SHARE
) {
2166 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2167 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2168 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2169 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2172 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_TRUE
) {
2173 ret
= Exynos_Mpeg4Dec_DstIn(pOMXComponent
, pDstInputData
);
2174 if (ret
!= OMX_ErrorNone
) {
2175 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2176 pExynosComponent
->callbackData
,
2177 OMX_EventError
, ret
, 0, NULL
);
2187 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
2189 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2190 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2191 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2192 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2196 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2197 ret
= OMX_ErrorNone
;
2200 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2201 ret
= OMX_ErrorNone
;
2205 if ((pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) == BUFFER_COPY
) {
2206 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2207 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2208 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2209 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2212 ret
= Exynos_Mpeg4Dec_DstOut(pOMXComponent
, pDstOutputData
);
2213 if ((ret
!= OMX_ErrorNone
) &&
2214 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2215 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2216 pExynosComponent
->callbackData
,
2217 OMX_EventError
, ret
, 0, NULL
);
2226 OSCL_EXPORT_REF OMX_ERRORTYPE
Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent
, OMX_STRING componentName
)
2228 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2229 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2230 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2231 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
2232 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2233 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2235 OMX_S32 codecType
= -1;
2239 if ((hComponent
== NULL
) || (componentName
== NULL
)) {
2240 ret
= OMX_ErrorBadParameter
;
2241 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
2244 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_MPEG4_DEC
, componentName
) == 0) {
2245 codecType
= CODEC_TYPE_MPEG4
;
2246 } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H263_DEC
, componentName
) == 0) {
2247 codecType
= CODEC_TYPE_H263
;
2249 ret
= OMX_ErrorBadParameter
;
2250 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName
, __LINE__
);
2254 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2255 ret
= Exynos_OMX_VideoDecodeComponentInit(pOMXComponent
);
2256 if (ret
!= OMX_ErrorNone
) {
2257 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_Error, Line:%d", __LINE__
);
2260 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2261 pExynosComponent
->codecType
= HW_VIDEO_DEC_CODEC
;
2263 pExynosComponent
->componentName
= (OMX_STRING
)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE
);
2264 if (pExynosComponent
->componentName
== NULL
) {
2265 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2266 ret
= OMX_ErrorInsufficientResources
;
2267 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2270 Exynos_OSAL_Memset(pExynosComponent
->componentName
, 0, MAX_OMX_COMPONENT_NAME_SIZE
);
2272 pMpeg4Dec
= Exynos_OSAL_Malloc(sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2273 if (pMpeg4Dec
== NULL
) {
2274 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2275 ret
= OMX_ErrorInsufficientResources
;
2276 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2279 Exynos_OSAL_Memset(pMpeg4Dec
, 0, sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2280 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2281 pVideoDec
->hCodecHandle
= (OMX_HANDLETYPE
)pMpeg4Dec
;
2282 pMpeg4Dec
->hMFCMpeg4Handle
.codecType
= codecType
;
2284 if (codecType
== CODEC_TYPE_MPEG4
)
2285 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_MPEG4_DEC
);
2287 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_H263_DEC
);
2289 /* Set componentVersion */
2290 pExynosComponent
->componentVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2291 pExynosComponent
->componentVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2292 pExynosComponent
->componentVersion
.s
.nRevision
= REVISION_NUMBER
;
2293 pExynosComponent
->componentVersion
.s
.nStep
= STEP_NUMBER
;
2294 /* Set specVersion */
2295 pExynosComponent
->specVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2296 pExynosComponent
->specVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2297 pExynosComponent
->specVersion
.s
.nRevision
= REVISION_NUMBER
;
2298 pExynosComponent
->specVersion
.s
.nStep
= STEP_NUMBER
;
2301 pExynosPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2302 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2303 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2304 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2305 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2306 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_INPUT_BUFFER_SIZE
;
2307 if (codecType
== CODEC_TYPE_MPEG4
) {
2308 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
2309 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2310 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/mpeg4");
2312 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
2313 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2314 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/h263");
2316 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2317 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2318 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatUnused
;
2319 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2320 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
2321 pExynosPort
->portWayType
= WAY2_PORT
;
2324 pExynosPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2325 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2326 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2327 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2328 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2329 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE
;
2330 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingUnused
;
2331 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2332 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "raw/video");
2333 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2334 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2335 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420Planar
;
2336 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2337 pExynosPort
->bufferProcessType
= BUFFER_COPY
| BUFFER_ANBSHARE
;
2338 pExynosPort
->portWayType
= WAY2_PORT
;
2340 if (codecType
== CODEC_TYPE_MPEG4
) {
2341 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2342 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->mpeg4Component
[i
], OMX_VIDEO_PARAM_MPEG4TYPE
);
2343 pMpeg4Dec
->mpeg4Component
[i
].nPortIndex
= i
;
2344 pMpeg4Dec
->mpeg4Component
[i
].eProfile
= OMX_VIDEO_MPEG4ProfileSimple
;
2345 pMpeg4Dec
->mpeg4Component
[i
].eLevel
= OMX_VIDEO_MPEG4Level3
;
2348 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2349 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->h263Component
[i
], OMX_VIDEO_PARAM_H263TYPE
);
2350 pMpeg4Dec
->h263Component
[i
].nPortIndex
= i
;
2351 pMpeg4Dec
->h263Component
[i
].eProfile
= OMX_VIDEO_H263ProfileBaseline
| OMX_VIDEO_H263ProfileISWV2
;
2352 pMpeg4Dec
->h263Component
[i
].eLevel
= OMX_VIDEO_H263Level45
;
2356 pOMXComponent
->GetParameter
= &Exynos_Mpeg4Dec_GetParameter
;
2357 pOMXComponent
->SetParameter
= &Exynos_Mpeg4Dec_SetParameter
;
2358 pOMXComponent
->GetConfig
= &Exynos_Mpeg4Dec_GetConfig
;
2359 pOMXComponent
->SetConfig
= &Exynos_Mpeg4Dec_SetConfig
;
2360 pOMXComponent
->GetExtensionIndex
= &Exynos_Mpeg4Dec_GetExtensionIndex
;
2361 pOMXComponent
->ComponentRoleEnum
= &Exynos_Mpeg4Dec_ComponentRoleEnum
;
2362 pOMXComponent
->ComponentDeInit
= &Exynos_OMX_ComponentDeinit
;
2364 pExynosComponent
->exynos_codec_componentInit
= &Exynos_Mpeg4Dec_Init
;
2365 pExynosComponent
->exynos_codec_componentTerminate
= &Exynos_Mpeg4Dec_Terminate
;
2367 pVideoDec
->exynos_codec_srcInputProcess
= &Exynos_Mpeg4Dec_srcInputBufferProcess
;
2368 pVideoDec
->exynos_codec_srcOutputProcess
= &Exynos_Mpeg4Dec_srcOutputBufferProcess
;
2369 pVideoDec
->exynos_codec_dstInputProcess
= &Exynos_Mpeg4Dec_dstInputBufferProcess
;
2370 pVideoDec
->exynos_codec_dstOutputProcess
= &Exynos_Mpeg4Dec_dstOutputBufferProcess
;
2372 pVideoDec
->exynos_codec_start
= &Mpeg4CodecStart
;
2373 pVideoDec
->exynos_codec_stop
= &Mpeg4CodecStop
;
2374 pVideoDec
->exynos_codec_bufferProcessRun
= &Mpeg4CodecOutputBufferProcessRun
;
2375 pVideoDec
->exynos_codec_enqueueAllBuffer
= &Mpeg4CodecEnQueueAllBuffer
;
2377 if (codecType
== CODEC_TYPE_MPEG4
)
2378 pVideoDec
->exynos_checkInputFrame
= &Check_Mpeg4_Frame
;
2380 pVideoDec
->exynos_checkInputFrame
= &Check_H263_Frame
;
2382 pVideoDec
->exynos_codec_getCodecInputPrivateData
= &GetCodecInputPrivateData
;
2383 pVideoDec
->exynos_codec_getCodecOutputPrivateData
= &GetCodecOutputPrivateData
;
2385 pVideoDec
->hSharedMemory
= Exynos_OSAL_SharedMemory_Open();
2386 if (pVideoDec
->hSharedMemory
== NULL
) {
2387 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2388 Exynos_OSAL_Free(pMpeg4Dec
);
2389 pMpeg4Dec
= ((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
= NULL
;
2390 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2391 ret
= OMX_ErrorInsufficientResources
;
2395 pExynosComponent
->currentState
= OMX_StateLoaded
;
2397 ret
= OMX_ErrorNone
;
2405 OMX_ERRORTYPE
Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent
)
2407 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2408 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2409 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2410 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2411 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2415 if (hComponent
== NULL
) {
2416 ret
= OMX_ErrorBadParameter
;
2419 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2420 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2421 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2423 Exynos_OSAL_SharedMemory_Close(pVideoDec
->hSharedMemory
);
2425 Exynos_OSAL_Free(pExynosComponent
->componentName
);
2426 pExynosComponent
->componentName
= NULL
;
2428 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
2429 if (pMpeg4Dec
!= NULL
) {
2430 Exynos_OSAL_Free(pMpeg4Dec
);
2431 pMpeg4Dec
= pVideoDec
->hCodecHandle
= NULL
;
2434 ret
= Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2435 if (ret
!= OMX_ErrorNone
) {
2439 ret
= OMX_ErrorNone
;