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
Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
638 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
639 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
640 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
641 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
642 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
643 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
644 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
647 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
648 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
649 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
653 if ((nPortIndex
== INPUT_PORT_INDEX
) &&
654 (pMpeg4Dec
->bSourceStart
== OMX_TRUE
)) {
655 Exynos_CodecBufferReset(pExynosComponent
, INPUT_PORT_INDEX
);
657 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
658 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]);
659 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[0]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]);
661 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
664 pInbufOps
->Clear_Queue(hMFCHandle
);
665 } else if ((nPortIndex
== OUTPUT_PORT_INDEX
) &&
666 (pMpeg4Dec
->bDestinationStart
== OMX_TRUE
)) {
667 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
668 ExynosVideoBuffer
*pBuffer
= NULL
;
670 Exynos_CodecBufferReset(pExynosComponent
, OUTPUT_PORT_INDEX
);
672 nOutbufs
= pDecOps
->Get_ActualBufferCount(hMFCHandle
);
673 nOutbufs
+= EXTRA_DPB_NUM
;
674 for (i
= 0; i
< nOutbufs
; i
++) {
675 pOutbufOps
->Get_Buffer(hMFCHandle
, i
, &pBuffer
);
676 Exynos_CodecBufferEnQueue(pExynosComponent
, OUTPUT_PORT_INDEX
, (OMX_PTR
)pBuffer
);
678 pOutbufOps
->Clear_Queue(hMFCHandle
);
680 ret
= OMX_ErrorBadParameter
;
690 OMX_ERRORTYPE
Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
692 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
693 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
694 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
695 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
696 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
697 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
698 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
699 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
701 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
702 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
703 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
704 ExynosVideoGeometry bufferConf
;
705 OMX_U32 inputBufferNumber
= 0;
710 if ((oneFrameSize
<= 0) && (pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
)) {
711 OMX_BUFFERHEADERTYPE
*OMXBuffer
= NULL
;
712 OMXBuffer
= Exynos_OutputBufferGetQueue_Direct(pExynosComponent
);
713 if (OMXBuffer
== NULL
) {
714 ret
= OMX_ErrorUndefined
;
718 OMXBuffer
->nTimeStamp
= pSrcInputData
->timeStamp
;
719 OMXBuffer
->nFlags
= pSrcInputData
->nFlags
;
720 Exynos_OMX_OutputBufferReturn(pOMXComponent
, OMXBuffer
);
726 if (pVideoDec
->bThumbnailMode
== OMX_TRUE
)
727 pDecOps
->Set_DisplayDelay(hMFCHandle
, 0);
729 /* input buffer info */
730 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
731 if (pMpeg4Dec
->hMFCMpeg4Handle
.codecType
== CODEC_TYPE_MPEG4
)
732 bufferConf
.eCompressionFormat
= VIDEO_CODING_MPEG4
;
734 bufferConf
.eCompressionFormat
= VIDEO_CODING_H263
;
736 pInbufOps
->Set_Shareable(hMFCHandle
);
737 if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
738 bufferConf
.nSizeImage
= pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
739 * pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
* 3 / 2;
740 inputBufferNumber
= MAX_VIDEO_INPUTBUFFER_NUM
;
741 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
742 bufferConf
.nSizeImage
= DEFAULT_MFC_INPUT_BUFFER_SIZE
;
743 inputBufferNumber
= MFC_INPUT_BUFFER_NUM_MAX
;
746 /* should be done before prepare input buffer */
747 if (pInbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
748 ret
= OMX_ErrorInsufficientResources
;
752 /* set input buffer geometry */
753 if (pInbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
754 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for input buffer");
755 ret
= OMX_ErrorInsufficientResources
;
759 /* setup input buffer */
760 if (pInbufOps
->Setup(hMFCHandle
, inputBufferNumber
) != VIDEO_ERROR_NONE
) {
761 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup input buffer");
762 ret
= OMX_ErrorInsufficientResources
;
766 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
767 /* Register input buffer */
768 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
769 ExynosVideoPlane plane
;
770 plane
.addr
= pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0];
771 plane
.allocSize
= pVideoDec
->pMFCDecInputBuffer
[i
]->bufferSize
[0];
772 plane
.fd
= pVideoDec
->pMFCDecInputBuffer
[i
]->fd
[0];
773 if (pInbufOps
->Register(hMFCHandle
, &plane
, MFC_INPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
774 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register input buffer");
775 ret
= OMX_ErrorInsufficientResources
;
779 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
780 /* Register input buffer */
781 for (i
= 0; i
< pExynosInputPort
->portDefinition
.nBufferCountActual
; i
++) {
782 ExynosVideoPlane plane
;
783 plane
.addr
= pExynosInputPort
->extendBufferHeader
[i
].OMXBufferHeader
->pBuffer
;
784 plane
.allocSize
= pExynosInputPort
->extendBufferHeader
[i
].OMXBufferHeader
->nAllocLen
;
785 plane
.fd
= pExynosInputPort
->extendBufferHeader
[i
].buf_fd
[0];
786 if (pInbufOps
->Register(hMFCHandle
, &plane
, MFC_INPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
787 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register input buffer");
788 ret
= OMX_ErrorInsufficientResources
;
794 /* set output geometry */
795 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
796 pMpeg4Dec
->hMFCMpeg4Handle
.MFCOutputColorType
= bufferConf
.eColorFormat
= VIDEO_COLORFORMAT_NV12_TILED
;
797 if (pOutbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
798 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for output buffer");
799 ret
= OMX_ErrorInsufficientResources
;
803 /* input buffer enqueue for header parsing */
804 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d", oneFrameSize
);
805 if (pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
806 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
) != VIDEO_ERROR_NONE
) {
807 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to enqueue input buffer for header parsing");
808 // ret = OMX_ErrorInsufficientResources;
809 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecInit
;
813 /* start header parsing */
814 if (pInbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
815 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run input buffer for header parsing");
816 ret
= OMX_ErrorCodecInit
;
820 /* get geometry for output */
821 Exynos_OSAL_Memset(&pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
, 0, sizeof(ExynosVideoGeometry
));
822 if (pOutbufOps
->Get_Geometry(hMFCHandle
, &pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
) != VIDEO_ERROR_NONE
) {
823 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to get geometry for parsed header info");
824 ret
= OMX_ErrorInsufficientResources
;
829 pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
= pDecOps
->Get_ActualBufferCount(hMFCHandle
);
830 if (pVideoDec
->bThumbnailMode
== OMX_FALSE
)
831 pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
+= EXTRA_DPB_NUM
;
832 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Mpeg4CodecSetup nOutbufs: %d", pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
);
834 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_TRUE
;
836 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
837 if ((pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
) ||
838 (pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
)) {
839 pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
840 pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
841 pExynosInputPort
->portDefinition
.format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
842 pExynosInputPort
->portDefinition
.format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
844 Exynos_UpdateFrameSize(pOMXComponent
);
845 pExynosOutputPort
->exceptionFlag
= NEED_PORT_DISABLE
;
847 /** Send Port Settings changed call back **/
848 (*(pExynosComponent
->pCallbacks
->EventHandler
))
850 pExynosComponent
->callbackData
,
851 OMX_EventPortSettingsChanged
, /* The command was completed */
852 OMX_DirOutput
, /* This is the port index */
856 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
857 if ((pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
) ||
858 (pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
!= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
) ||
859 (pExynosOutputPort
->portDefinition
.nBufferCountActual
!= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
)) {
860 pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
;
861 pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
= pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
;
862 pExynosInputPort
->portDefinition
.format
.video
.nStride
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
+ 15) & (~15));
863 pExynosInputPort
->portDefinition
.format
.video
.nSliceHeight
= ((pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
+ 15) & (~15));
865 pExynosOutputPort
->portDefinition
.nBufferCountActual
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
- 2;
866 pExynosOutputPort
->portDefinition
.nBufferCountMin
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
- 2;
868 Exynos_UpdateFrameSize(pOMXComponent
);
869 pExynosOutputPort
->exceptionFlag
= NEED_PORT_DISABLE
;
871 /** Send Port Settings changed call back **/
872 (*(pExynosComponent
->pCallbacks
->EventHandler
))
874 pExynosComponent
->callbackData
,
875 OMX_EventPortSettingsChanged
, /* The command was completed */
876 OMX_DirOutput
, /* This is the port index */
881 Exynos_OSAL_SleepMillisec(0);
882 ret
= OMX_ErrorInputDataDecodeYet
;
883 Mpeg4CodecStop(pOMXComponent
, INPUT_PORT_INDEX
);
891 OMX_ERRORTYPE
Mpeg4CodecDstSetup(OMX_COMPONENTTYPE
*pOMXComponent
)
893 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
894 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
895 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
896 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
897 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
898 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
899 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
901 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
902 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
903 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
910 nOutbufs
= pMpeg4Dec
->hMFCMpeg4Handle
.maxDPBNum
;
912 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
913 /* should be done before prepare output buffer */
914 if (pOutbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
915 ret
= OMX_ErrorInsufficientResources
;
919 pOutbufOps
->Set_Shareable(hMFCHandle
);
920 if (pOutbufOps
->Setup(hMFCHandle
, nOutbufs
) != VIDEO_ERROR_NONE
) {
921 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup output buffer");
922 ret
= OMX_ErrorInsufficientResources
;
926 ExynosVideoPlane planes
[MFC_OUTPUT_BUFFER_PLANE
];
927 OMX_U32 nAllocLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
928 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0, 0};
931 nAllocLen
[0] = calc_plane(pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
,
932 pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
);
933 nAllocLen
[1] = calc_plane(pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameWidth
,
934 pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
.nFrameHeight
>> 1);
936 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
937 /* Register output buffer */
938 for (i
= 0; i
< nOutbufs
; i
++) {
939 pVideoDec
->pMFCDecOutputBuffer
[i
] = (CODEC_DEC_BUFFER
*)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER
));
940 Exynos_OSAL_Memset(pVideoDec
->pMFCDecOutputBuffer
[i
], 0, sizeof(CODEC_DEC_BUFFER
));
942 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
943 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[plane
] =
944 (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec
->hSharedMemory
, nAllocLen
[plane
], NORMAL_MEMORY
);
945 if (pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[plane
] == NULL
) {
946 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Alloc output buffer");
947 ret
= OMX_ErrorInsufficientResources
;
950 pVideoDec
->pMFCDecOutputBuffer
[i
]->fd
[plane
] =
951 Exynos_OSAL_SharedMemory_VirtToION(pVideoDec
->hSharedMemory
,
952 pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[plane
]);
953 pVideoDec
->pMFCDecOutputBuffer
[i
]->bufferSize
[plane
] = nAllocLen
[plane
];
955 planes
[plane
].addr
= pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[plane
];
956 planes
[plane
].fd
= pVideoDec
->pMFCDecOutputBuffer
[i
]->fd
[plane
];
957 planes
[plane
].allocSize
= pVideoDec
->pMFCDecOutputBuffer
[i
]->bufferSize
[plane
];
960 if (pOutbufOps
->Register(hMFCHandle
, planes
, MFC_OUTPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
961 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register output buffer");
962 ret
= OMX_ErrorInsufficientResources
;
965 pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
,
966 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
968 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
969 /* Register output buffer */
974 if (pExynosOutputPort
->bIsANBEnabled
== OMX_TRUE
) {
975 for (i
= 0; i
< pExynosOutputPort
->assignedBufferNum
; i
++) {
976 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
977 planes
[plane
].fd
= pExynosOutputPort
->extendBufferHeader
[i
].buf_fd
[plane
];
978 planes
[plane
].addr
= pExynosOutputPort
->extendBufferHeader
[i
].pYUVBuf
[plane
];
979 planes
[plane
].allocSize
= nAllocLen
[plane
];
982 if (pOutbufOps
->Register(hMFCHandle
, planes
, MFC_OUTPUT_BUFFER_PLANE
) != VIDEO_ERROR_NONE
) {
983 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to Register output buffer");
984 ret
= OMX_ErrorInsufficientResources
;
987 pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pExynosOutputPort
->extendBufferHeader
[i
].pYUVBuf
,
988 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, NULL
);
991 ret
= OMX_ErrorNotImplemented
;
995 ret
= OMX_ErrorNotImplemented
;
1000 if (pOutbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
1001 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run output buffer");
1002 ret
= OMX_ErrorInsufficientResources
;
1006 if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1007 Mpeg4CodecStop(pOMXComponent
, OUTPUT_PORT_INDEX
);
1009 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_TRUE
;
1011 ret
= OMX_ErrorNone
;
1019 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetParameter(
1020 OMX_IN OMX_HANDLETYPE hComponent
,
1021 OMX_IN OMX_INDEXTYPE nParamIndex
,
1022 OMX_INOUT OMX_PTR pComponentParameterStructure
)
1024 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1025 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1026 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1030 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1031 ret
= OMX_ErrorBadParameter
;
1034 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1035 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1036 if (ret
!= OMX_ErrorNone
) {
1039 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1040 ret
= OMX_ErrorBadParameter
;
1044 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1045 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1046 ret
= OMX_ErrorInvalidState
;
1050 switch (nParamIndex
) {
1051 case OMX_IndexParamVideoMpeg4
:
1053 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1054 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1055 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1057 ret
= Exynos_OMX_Check_SizeVersion(pDstMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1058 if (ret
!= OMX_ErrorNone
) {
1062 if (pDstMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1063 ret
= OMX_ErrorBadPortIndex
;
1067 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1068 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstMpeg4Param
->nPortIndex
];
1070 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1073 case OMX_IndexParamVideoH263
:
1075 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1076 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1077 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1079 ret
= Exynos_OMX_Check_SizeVersion(pDstH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1080 if (ret
!= OMX_ErrorNone
) {
1084 if (pDstH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1085 ret
= OMX_ErrorBadPortIndex
;
1089 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1090 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstH263Param
->nPortIndex
];
1092 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1095 case OMX_IndexParamStandardComponentRole
:
1098 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1100 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1101 if (ret
!= OMX_ErrorNone
) {
1105 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1106 if (codecType
== CODEC_TYPE_MPEG4
)
1107 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1109 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1112 case OMX_IndexParamVideoProfileLevelQuerySupported
:
1114 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1115 EXYNOS_OMX_VIDEO_PROFILELEVEL
*pProfileLevel
= NULL
;
1116 OMX_U32 maxProfileLevelNum
= 0;
1119 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1120 if (ret
!= OMX_ErrorNone
) {
1124 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1125 ret
= OMX_ErrorBadPortIndex
;
1129 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1130 if (codecType
== CODEC_TYPE_MPEG4
) {
1131 pProfileLevel
= supportedMPEG4ProfileLevels
;
1132 maxProfileLevelNum
= sizeof(supportedMPEG4ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1134 pProfileLevel
= supportedH263ProfileLevels
;
1135 maxProfileLevelNum
= sizeof(supportedH263ProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1138 if (pDstProfileLevel
->nProfileIndex
>= maxProfileLevelNum
) {
1139 ret
= OMX_ErrorNoMore
;
1143 pProfileLevel
+= pDstProfileLevel
->nProfileIndex
;
1144 pDstProfileLevel
->eProfile
= pProfileLevel
->profile
;
1145 pDstProfileLevel
->eLevel
= pProfileLevel
->level
;
1148 case OMX_IndexParamVideoProfileLevelCurrent
:
1150 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1151 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= NULL
;
1152 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= NULL
;
1153 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1156 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1157 if (ret
!= OMX_ErrorNone
) {
1161 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1162 ret
= OMX_ErrorBadPortIndex
;
1166 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1167 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1168 if (codecType
== CODEC_TYPE_MPEG4
) {
1169 pSrcMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pDstProfileLevel
->nPortIndex
];
1170 pDstProfileLevel
->eProfile
= pSrcMpeg4Param
->eProfile
;
1171 pDstProfileLevel
->eLevel
= pSrcMpeg4Param
->eLevel
;
1173 pSrcH263Param
= &pMpeg4Dec
->h263Component
[pDstProfileLevel
->nPortIndex
];
1174 pDstProfileLevel
->eProfile
= pSrcH263Param
->eProfile
;
1175 pDstProfileLevel
->eLevel
= pSrcH263Param
->eLevel
;
1179 case OMX_IndexParamVideoErrorCorrection
:
1181 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1182 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= NULL
;
1183 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1185 ret
= Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1186 if (ret
!= OMX_ErrorNone
) {
1190 if (pDstErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1191 ret
= OMX_ErrorBadPortIndex
;
1195 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1196 pSrcErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1198 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1199 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1200 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1201 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1202 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1206 ret
= Exynos_OMX_VideoDecodeGetParameter(hComponent
, nParamIndex
, pComponentParameterStructure
);
1215 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetParameter(
1216 OMX_IN OMX_HANDLETYPE hComponent
,
1217 OMX_IN OMX_INDEXTYPE nIndex
,
1218 OMX_IN OMX_PTR pComponentParameterStructure
)
1220 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1221 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1222 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1226 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1227 ret
= OMX_ErrorBadParameter
;
1230 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1231 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1232 if (ret
!= OMX_ErrorNone
) {
1235 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1236 ret
= OMX_ErrorBadParameter
;
1240 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1241 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1242 ret
= OMX_ErrorInvalidState
;
1247 case OMX_IndexParamVideoMpeg4
:
1249 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1250 OMX_VIDEO_PARAM_MPEG4TYPE
*pSrcMpeg4Param
= (OMX_VIDEO_PARAM_MPEG4TYPE
*)pComponentParameterStructure
;
1251 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1253 ret
= Exynos_OMX_Check_SizeVersion(pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1254 if (ret
!= OMX_ErrorNone
) {
1258 if (pSrcMpeg4Param
->nPortIndex
>= ALL_PORT_NUM
) {
1259 ret
= OMX_ErrorBadPortIndex
;
1263 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1264 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcMpeg4Param
->nPortIndex
];
1266 Exynos_OSAL_Memcpy(pDstMpeg4Param
, pSrcMpeg4Param
, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE
));
1269 case OMX_IndexParamVideoH263
:
1271 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1272 OMX_VIDEO_PARAM_H263TYPE
*pSrcH263Param
= (OMX_VIDEO_PARAM_H263TYPE
*)pComponentParameterStructure
;
1273 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1275 ret
= Exynos_OMX_Check_SizeVersion(pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1276 if (ret
!= OMX_ErrorNone
) {
1280 if (pSrcH263Param
->nPortIndex
>= ALL_PORT_NUM
) {
1281 ret
= OMX_ErrorBadPortIndex
;
1285 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1286 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcH263Param
->nPortIndex
];
1288 Exynos_OSAL_Memcpy(pDstH263Param
, pSrcH263Param
, sizeof(OMX_VIDEO_PARAM_H263TYPE
));
1291 case OMX_IndexParamStandardComponentRole
:
1293 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1295 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1296 if (ret
!= OMX_ErrorNone
) {
1300 if ((pExynosComponent
->currentState
!= OMX_StateLoaded
) && (pExynosComponent
->currentState
!= OMX_StateWaitForResources
)) {
1301 ret
= OMX_ErrorIncorrectStateOperation
;
1305 if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
)) {
1306 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
1307 } else if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
)) {
1308 pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
1310 ret
= OMX_ErrorBadParameter
;
1315 case OMX_IndexParamVideoProfileLevelCurrent
:
1317 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pSrcProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1318 OMX_VIDEO_PARAM_MPEG4TYPE
*pDstMpeg4Param
= NULL
;
1319 OMX_VIDEO_PARAM_H263TYPE
*pDstH263Param
= NULL
;
1320 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1323 ret
= Exynos_OMX_Check_SizeVersion(pSrcProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1324 if (ret
!= OMX_ErrorNone
)
1327 if (pSrcProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1328 ret
= OMX_ErrorBadPortIndex
;
1332 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1333 codecType
= pMpeg4Dec
->hMFCMpeg4Handle
.codecType
;
1334 if (codecType
== CODEC_TYPE_MPEG4
) {
1336 * To do: Check validity of profile & level parameters
1339 pDstMpeg4Param
= &pMpeg4Dec
->mpeg4Component
[pSrcProfileLevel
->nPortIndex
];
1340 pDstMpeg4Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1341 pDstMpeg4Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1344 * To do: Check validity of profile & level parameters
1347 pDstH263Param
= &pMpeg4Dec
->h263Component
[pSrcProfileLevel
->nPortIndex
];
1348 pDstH263Param
->eProfile
= pSrcProfileLevel
->eProfile
;
1349 pDstH263Param
->eLevel
= pSrcProfileLevel
->eLevel
;
1353 case OMX_IndexParamVideoErrorCorrection
:
1355 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1356 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= NULL
;
1357 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
1359 ret
= Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1360 if (ret
!= OMX_ErrorNone
) {
1364 if (pSrcErrorCorrectionType
->nPortIndex
!= INPUT_PORT_INDEX
) {
1365 ret
= OMX_ErrorBadPortIndex
;
1369 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1370 pDstErrorCorrectionType
= &pMpeg4Dec
->errorCorrectionType
[INPUT_PORT_INDEX
];
1372 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1373 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1374 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1375 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1376 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1380 ret
= Exynos_OMX_VideoDecodeSetParameter(hComponent
, nIndex
, pComponentParameterStructure
);
1389 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetConfig(
1390 OMX_IN OMX_HANDLETYPE hComponent
,
1391 OMX_IN OMX_INDEXTYPE nIndex
,
1392 OMX_IN OMX_PTR pComponentConfigStructure
)
1394 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1395 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1396 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1400 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1401 ret
= OMX_ErrorBadParameter
;
1404 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1405 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1406 if (ret
!= OMX_ErrorNone
) {
1409 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1410 ret
= OMX_ErrorBadParameter
;
1413 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1414 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1415 ret
= OMX_ErrorInvalidState
;
1421 ret
= Exynos_OMX_VideoDecodeGetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1431 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SetConfig(
1432 OMX_IN OMX_HANDLETYPE hComponent
,
1433 OMX_IN OMX_INDEXTYPE nIndex
,
1434 OMX_IN OMX_PTR pComponentConfigStructure
)
1436 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1437 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1438 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1442 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1443 ret
= OMX_ErrorBadParameter
;
1446 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1447 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1448 if (ret
!= OMX_ErrorNone
) {
1451 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1452 ret
= OMX_ErrorBadParameter
;
1455 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1456 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1457 ret
= OMX_ErrorInvalidState
;
1463 ret
= Exynos_OMX_VideoDecodeSetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1473 OMX_ERRORTYPE
Exynos_Mpeg4Dec_GetExtensionIndex(
1474 OMX_IN OMX_HANDLETYPE hComponent
,
1475 OMX_IN OMX_STRING cParameterName
,
1476 OMX_OUT OMX_INDEXTYPE
*pIndexType
)
1478 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1479 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1480 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1484 if (hComponent
== NULL
) {
1485 ret
= OMX_ErrorBadParameter
;
1488 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1489 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1490 if (ret
!= OMX_ErrorNone
) {
1493 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1494 ret
= OMX_ErrorBadParameter
;
1497 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1498 if ((cParameterName
== NULL
) || (pIndexType
== NULL
)) {
1499 ret
= OMX_ErrorBadParameter
;
1502 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1503 ret
= OMX_ErrorInvalidState
;
1507 if (Exynos_OSAL_Strcmp(cParameterName
, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL
) == 0) {
1508 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1509 *pIndexType
= OMX_IndexVendorThumbnailMode
;
1510 ret
= OMX_ErrorNone
;
1512 ret
= Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent
, cParameterName
, pIndexType
);
1521 OMX_ERRORTYPE
Exynos_Mpeg4Dec_ComponentRoleEnum(
1522 OMX_IN OMX_HANDLETYPE hComponent
,
1523 OMX_OUT OMX_U8
*cRole
,
1524 OMX_IN OMX_U32 nIndex
)
1526 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1527 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1528 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1533 if ((hComponent
== NULL
) || (cRole
== NULL
)) {
1534 ret
= OMX_ErrorBadParameter
;
1537 if (nIndex
!= (MAX_COMPONENT_ROLE_NUM
- 1)) {
1538 ret
= OMX_ErrorNoMore
;
1541 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1542 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1543 if (ret
!= OMX_ErrorNone
) {
1546 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1547 ret
= OMX_ErrorBadParameter
;
1550 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1551 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1552 ret
= OMX_ErrorInvalidState
;
1556 codecType
= ((EXYNOS_MPEG4DEC_HANDLE
*)(((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
))->hMFCMpeg4Handle
.codecType
;
1557 if (codecType
== CODEC_TYPE_MPEG4
)
1558 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_MPEG4_DEC_ROLE
);
1560 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_H263_DEC_ROLE
);
1569 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Init(OMX_COMPONENTTYPE
*pOMXComponent
)
1571 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1572 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1573 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1574 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1575 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1576 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
1577 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1579 ExynosVideoDecOps
*pDecOps
= NULL
;
1580 ExynosVideoDecBufferOps
*pInbufOps
= NULL
;
1581 ExynosVideoDecBufferOps
*pOutbufOps
= NULL
;
1583 CSC_METHOD csc_method
= CSC_METHOD_SW
;
1588 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
= OMX_FALSE
;
1589 pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
= OMX_FALSE
;
1590 pExynosComponent
->bUseFlagEOF
= OMX_TRUE
;
1591 pExynosComponent
->bSaveFlagEOS
= OMX_FALSE
;
1593 /* Mpeg4 Codec Open */
1594 ret
= Mpeg4CodecOpen(pMpeg4Dec
);
1595 if (ret
!= OMX_ErrorNone
) {
1599 pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1600 pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1601 pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1603 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1604 Exynos_OSAL_SemaphoreCreate(&pExynosInputPort
->codecSemID
);
1605 Exynos_OSAL_QueueCreate(&pExynosInputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1607 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
1608 pVideoDec
->pMFCDecInputBuffer
[i
] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER
));
1609 Exynos_OSAL_Memset(pVideoDec
->pMFCDecInputBuffer
[i
], 0, sizeof(CODEC_DEC_BUFFER
));
1610 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i
, pVideoDec
->pMFCDecInputBuffer
[i
]);
1612 for (plane
= 0; plane
< MFC_INPUT_BUFFER_PLANE
; plane
++) {
1613 /* Use ION Allocator */
1614 pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[plane
] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec
->hSharedMemory
, DEFAULT_MFC_INPUT_BUFFER_SIZE
, NORMAL_MEMORY
);
1615 pVideoDec
->pMFCDecInputBuffer
[i
]->fd
[plane
] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec
->hSharedMemory
, pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[plane
]);
1616 pVideoDec
->pMFCDecInputBuffer
[i
]->bufferSize
[plane
] = DEFAULT_MFC_INPUT_BUFFER_SIZE
;
1617 pVideoDec
->pMFCDecInputBuffer
[i
]->dataSize
= 0;
1618 if (pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[plane
] == NULL
) {
1619 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Fail input buffer");
1620 ret
= OMX_ErrorInsufficientResources
;
1623 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i
, plane
, pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[plane
]);
1626 Exynos_CodecBufferEnQueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoDec
->pMFCDecInputBuffer
[i
]);
1628 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
1632 /* Does not require any actions. */
1635 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1636 Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort
->codecSemID
);
1637 Exynos_OSAL_QueueCreate(&pExynosOutputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1638 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1642 /* Does not require any actions. */
1645 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1646 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hSourceStartEvent
);
1647 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1648 Exynos_OSAL_SignalCreate(&pMpeg4Dec
->hDestinationStartEvent
);
1650 Exynos_OSAL_Memset(pExynosComponent
->timeStamp
, -19771003, sizeof(OMX_TICKS
) * MAX_TIMESTAMP
);
1651 Exynos_OSAL_Memset(pExynosComponent
->nFlags
, 0, sizeof(OMX_U32
) * MAX_FLAGS
);
1652 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
= 0;
1653 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= 0;
1655 pExynosComponent
->getAllDelayBuffer
= OMX_FALSE
;
1657 #if 0//defined(USE_CSC_GSCALER)
1658 csc_method
= CSC_METHOD_HW
; //in case of Use ION buffer.
1660 pVideoDec
->csc_handle
= csc_init(csc_method
);
1661 if (pVideoDec
->csc_handle
== NULL
) {
1662 ret
= OMX_ErrorInsufficientResources
;
1665 pVideoDec
->csc_set_format
= OMX_FALSE
;
1674 OMX_ERRORTYPE
Exynos_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE
*pOMXComponent
)
1676 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1677 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1678 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1679 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1680 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1681 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1682 OMX_PTR hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1684 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1685 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1686 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1692 if (pVideoDec
->csc_handle
!= NULL
) {
1693 csc_deinit(pVideoDec
->csc_handle
);
1694 pVideoDec
->csc_handle
= NULL
;
1697 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hDestinationStartEvent
);
1698 pMpeg4Dec
->hDestinationStartEvent
= NULL
;
1699 pMpeg4Dec
->bDestinationStart
= OMX_FALSE
;
1700 Exynos_OSAL_SignalTerminate(pMpeg4Dec
->hSourceStartEvent
);
1701 pMpeg4Dec
->hSourceStartEvent
= NULL
;
1702 pMpeg4Dec
->bSourceStart
= OMX_FALSE
;
1704 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1705 for (i
= 0; i
< MFC_OUTPUT_BUFFER_NUM_MAX
; i
++) {
1706 if (pVideoDec
->pMFCDecOutputBuffer
[i
] != NULL
) {
1707 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
1708 if (pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[plane
] != NULL
)
1709 Exynos_OSAL_SharedMemory_Free(pVideoDec
->hSharedMemory
, pVideoDec
->pMFCDecOutputBuffer
[i
]->pVirAddr
[plane
]);
1712 Exynos_OSAL_Free(pVideoDec
->pMFCDecOutputBuffer
[i
]);
1713 pVideoDec
->pMFCDecOutputBuffer
[i
] = NULL
;
1717 Exynos_OSAL_QueueTerminate(&pExynosOutputPort
->codecBufferQ
);
1718 Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort
->codecSemID
);
1719 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1723 /* Does not require any actions. */
1726 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1727 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
1728 if (pVideoDec
->pMFCDecInputBuffer
[i
] != NULL
) {
1729 for (plane
= 0; plane
< MFC_INPUT_BUFFER_PLANE
; plane
++) {
1730 if (pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[plane
] != NULL
)
1731 Exynos_OSAL_SharedMemory_Free(pVideoDec
->hSharedMemory
, pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[plane
]);
1734 Exynos_OSAL_Free(pVideoDec
->pMFCDecInputBuffer
[i
]);
1735 pVideoDec
->pMFCDecInputBuffer
[i
] = NULL
;
1739 Exynos_OSAL_QueueTerminate(&pExynosInputPort
->codecBufferQ
);
1740 Exynos_OSAL_SemaphoreTerminate(pExynosInputPort
->codecSemID
);
1741 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
1745 /* Does not require any actions. */
1747 Mpeg4CodecClose(pMpeg4Dec
);
1755 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
1757 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1758 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1759 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1760 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1761 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1762 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1763 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1764 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
1765 OMX_BOOL bInStartCode
= OMX_FALSE
;
1766 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1767 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1768 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1769 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1774 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCSrc
== OMX_FALSE
) {
1775 ret
= Mpeg4CodecSrcSetup(pOMXComponent
, pSrcInputData
);
1778 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_FALSE
) {
1779 ret
= Mpeg4CodecDstSetup(pOMXComponent
);
1782 if (((bInStartCode
= Check_Stream_StartCode(pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
, oneFrameSize
, pMpeg4Dec
->hMFCMpeg4Handle
.codecType
)) == OMX_TRUE
) ||
1783 ((pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
1784 pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->timeStamp
;
1785 pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
] = pSrcInputData
->nFlags
;
1786 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "input timestamp %lld us (%.2f secs), Tag: %d, nFlags: 0x%x", pSrcInputData
->timeStamp
, pSrcInputData
->timeStamp
/ 1E6
, pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
, pSrcInputData
->nFlags
);
1787 pDecOps
->Set_FrameTag(hMFCHandle
, pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
);
1788 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
++;
1789 pMpeg4Dec
->hMFCMpeg4Handle
.indexTimestamp
%= MAX_TIMESTAMP
;
1791 /* queue work for input buffer */
1792 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize
, pSrcInputData
->bufferHeader
, pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
);
1793 codecReturn
= pInbufOps
->Enqueue(hMFCHandle
, (unsigned char **)&pSrcInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
1794 (unsigned int *)&oneFrameSize
, MFC_INPUT_BUFFER_PLANE
, pSrcInputData
->bufferHeader
);
1795 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1796 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1797 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1800 Mpeg4CodecStart(pOMXComponent
, INPUT_PORT_INDEX
);
1801 if (pMpeg4Dec
->bSourceStart
== OMX_FALSE
) {
1802 pMpeg4Dec
->bSourceStart
= OMX_TRUE
;
1803 Exynos_OSAL_SignalSet(pMpeg4Dec
->hSourceStartEvent
);
1804 Exynos_OSAL_SleepMillisec(0);
1806 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1807 pMpeg4Dec
->bDestinationStart
= OMX_TRUE
;
1808 Exynos_OSAL_SignalSet(pMpeg4Dec
->hDestinationStartEvent
);
1809 Exynos_OSAL_SleepMillisec(0);
1811 } else if (bInStartCode
== OMX_FALSE
) {
1812 ret
= OMX_ErrorCorruptedFrame
;
1816 ret
= OMX_ErrorNone
;
1824 OMX_ERRORTYPE
Exynos_Mpeg4Dec_SrcOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
1826 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1827 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1828 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1829 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1830 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1831 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1832 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1833 ExynosVideoDecBufferOps
*pInbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pInbufOps
;
1834 ExynosVideoBuffer
*pVideoBuffer
;
1838 pVideoBuffer
= pInbufOps
->Dequeue(hMFCHandle
);
1840 pSrcOutputData
->dataLen
= 0;
1841 pSrcOutputData
->usedDataLen
= 0;
1842 pSrcOutputData
->remainDataLen
= 0;
1843 pSrcOutputData
->nFlags
= 0;
1844 pSrcOutputData
->timeStamp
= 0;
1846 if (pVideoBuffer
== NULL
) {
1847 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= NULL
;
1848 pSrcOutputData
->allocSize
= 0;
1849 pSrcOutputData
->pPrivate
= NULL
;
1850 pSrcOutputData
->bufferHeader
= NULL
;
1852 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= pVideoBuffer
->planes
[0].addr
;
1853 pSrcOutputData
->buffer
.singlePlaneBuffer
.fd
= pVideoBuffer
->planes
[0].fd
;
1854 pSrcOutputData
->allocSize
= pVideoBuffer
->planes
[0].allocSize
;
1856 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1858 while (pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
!= pVideoDec
->pMFCDecInputBuffer
[i
]->pVirAddr
[0]) {
1859 if (i
>= MFC_INPUT_BUFFER_NUM_MAX
) {
1860 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
1861 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1866 pVideoDec
->pMFCDecInputBuffer
[i
]->dataSize
= 0;
1867 pSrcOutputData
->pPrivate
= pVideoDec
->pMFCDecInputBuffer
[i
];
1870 /* For Share Buffer */
1871 pSrcOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
1874 ret
= OMX_ErrorNone
;
1882 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
1884 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1885 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1886 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1887 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1888 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1889 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1890 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1891 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1892 OMX_U32 dataLen
[MFC_OUTPUT_BUFFER_PLANE
] = {0,};
1893 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1897 if (pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] == NULL
) {
1898 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to find input buffer");
1899 ret
= OMX_ErrorBadParameter
;
1903 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x", __FUNCTION__
, __LINE__
,
1904 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0],
1905 pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
[1]);
1907 codecReturn
= pOutbufOps
->Enqueue(hMFCHandle
, (unsigned char **)pDstInputData
->buffer
.multiPlaneBuffer
.dataBuffer
,
1908 (unsigned int *)dataLen
, MFC_OUTPUT_BUFFER_PLANE
, pDstInputData
->bufferHeader
);
1910 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1911 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s : %d", __FUNCTION__
, __LINE__
);
1912 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecDecode
;
1915 Mpeg4CodecStart(pOMXComponent
, OUTPUT_PORT_INDEX
);
1917 ret
= OMX_ErrorNone
;
1925 OMX_ERRORTYPE
Exynos_Mpeg4Dec_DstOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
1927 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1928 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1929 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1930 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1931 void *hMFCHandle
= pMpeg4Dec
->hMFCMpeg4Handle
.hMFCHandle
;
1932 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1933 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1934 ExynosVideoDecOps
*pDecOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pDecOps
;
1935 ExynosVideoDecBufferOps
*pOutbufOps
= pMpeg4Dec
->hMFCMpeg4Handle
.pOutbufOps
;
1936 ExynosVideoBuffer
*pVideoBuffer
= NULL
;
1937 ExynosVideoFrameStatusType displayStatus
= VIDEO_FRAME_STATUS_UNKNOWN
;
1938 ExynosVideoGeometry
*bufferGeometry
;
1939 DECODE_CODEC_EXTRA_BUFFERINFO
*pBufferInfo
= NULL
;
1940 OMX_S32 indexTimestamp
= 0;
1945 if (pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) {
1946 ret
= OMX_ErrorNone
;
1951 if ((pVideoBuffer
= pOutbufOps
->Dequeue(hMFCHandle
)) == NULL
) {
1952 ret
= OMX_ErrorNone
;
1955 displayStatus
= pVideoBuffer
->displayStatus
;
1956 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus: 0x%x", displayStatus
);
1958 if ((displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_DECODING
) ||
1959 (displayStatus
== VIDEO_FRAME_STATUS_DISPLAY_ONLY
) ||
1960 (displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
1961 (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
1962 ret
= OMX_ErrorNone
;
1967 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
++;
1968 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
%= MAX_TIMESTAMP
;
1970 pDstOutputData
->allocSize
= pDstOutputData
->dataLen
= 0;
1971 for (plane
= 0; plane
< MFC_OUTPUT_BUFFER_PLANE
; plane
++) {
1972 pDstOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[plane
] = pVideoBuffer
->planes
[plane
].addr
;
1973 pDstOutputData
->buffer
.multiPlaneBuffer
.fd
[plane
] = pVideoBuffer
->planes
[plane
].fd
;
1974 pDstOutputData
->allocSize
+= pVideoBuffer
->planes
[plane
].allocSize
;
1975 pDstOutputData
->dataLen
+= pVideoBuffer
->planes
[plane
].dataSize
;
1977 pDstOutputData
->usedDataLen
= 0;
1978 pDstOutputData
->pPrivate
= pVideoBuffer
;
1979 /* For Share Buffer */
1980 pDstOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
1982 pBufferInfo
= (DECODE_CODEC_EXTRA_BUFFERINFO
*)pDstOutputData
->extInfo
;
1983 bufferGeometry
= &pMpeg4Dec
->hMFCMpeg4Handle
.codecOutbufConf
;
1984 pBufferInfo
->imageWidth
= bufferGeometry
->nFrameWidth
;
1985 pBufferInfo
->imageHeight
= bufferGeometry
->nFrameHeight
;
1986 switch (bufferGeometry
->eColorFormat
) {
1987 case VIDEO_COLORFORMAT_NV12
:
1988 pBufferInfo
->ColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
1990 case VIDEO_COLORFORMAT_NV12_TILED
:
1992 pBufferInfo
->ColorFormat
= OMX_SEC_COLOR_FormatNV12Tiled
;
1996 indexTimestamp
= pDecOps
->Get_FrameTag(hMFCHandle
);
1997 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "out indexTimestamp: %d", indexTimestamp
);
1998 if ((indexTimestamp
< 0) || (indexTimestamp
>= MAX_TIMESTAMP
)) {
1999 if ((pExynosComponent
->checkTimeStamp
.needSetStartTimeStamp
!= OMX_TRUE
) &&
2000 (pExynosComponent
->checkTimeStamp
.needCheckStartTimeStamp
!= OMX_TRUE
)) {
2001 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2002 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2003 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "missing out indexTimestamp: %d", indexTimestamp
);
2005 pDstOutputData
->timeStamp
= 0x00;
2006 pDstOutputData
->nFlags
= 0x00;
2009 /* For timestamp correction. if mfc support frametype detect */
2010 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "disp_pic_frame_type: %d", pVideoBuffer
->frameType
);
2011 #ifdef NEED_TIMESTAMP_REORDER
2012 if ((pVideoBuffer
->frameType
== VIDEO_FRAME_I
)) {
2013 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2014 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2015 pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
= indexTimestamp
;
2017 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2018 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pMpeg4Dec
->hMFCMpeg4Handle
.outputIndexTimestamp
];
2021 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2022 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2024 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData
->timeStamp
, pDstOutputData
->timeStamp
/ 1E6
, indexTimestamp
, pDstOutputData
->nFlags
);
2027 if ((displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
2028 ((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
2029 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "displayStatus:%d, nFlags0x%x", displayStatus
, pDstOutputData
->nFlags
);
2030 pDstOutputData
->remainDataLen
= 0;
2032 pDstOutputData
->remainDataLen
= bufferGeometry
->nFrameWidth
* bufferGeometry
->nFrameHeight
* 3 / 2;
2035 ret
= OMX_ErrorNone
;
2043 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
2045 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2046 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2047 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2048 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2052 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2053 ret
= OMX_ErrorNone
;
2056 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2057 ret
= OMX_ErrorNone
;
2061 ret
= Exynos_Mpeg4Dec_SrcIn(pOMXComponent
, pSrcInputData
);
2062 if ((ret
!= OMX_ErrorNone
) &&
2063 (ret
!= OMX_ErrorInputDataDecodeYet
) &&
2064 (ret
!= OMX_ErrorCorruptedFrame
)) {
2065 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2066 pExynosComponent
->callbackData
,
2067 OMX_EventError
, ret
, 0, NULL
);
2076 OMX_ERRORTYPE
Exynos_Mpeg4Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
2078 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2079 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2080 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2081 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2085 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2086 ret
= OMX_ErrorNone
;
2090 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
2091 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2092 ret
= OMX_ErrorNone
;
2096 if ((pMpeg4Dec
->bSourceStart
== OMX_FALSE
) &&
2097 (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort
))) {
2098 Exynos_OSAL_SignalWait(pMpeg4Dec
->hSourceStartEvent
, DEF_MAX_WAIT_TIME
);
2099 Exynos_OSAL_SignalReset(pMpeg4Dec
->hSourceStartEvent
);
2102 ret
= Exynos_Mpeg4Dec_SrcOut(pOMXComponent
, pSrcOutputData
);
2103 if ((ret
!= OMX_ErrorNone
) &&
2104 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2105 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2106 pExynosComponent
->callbackData
,
2107 OMX_EventError
, ret
, 0, NULL
);
2116 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
2118 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2119 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2120 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2121 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2125 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2126 ret
= OMX_ErrorNone
;
2129 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2130 ret
= OMX_ErrorNone
;
2133 if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
2134 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2135 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2136 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2137 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2140 if (pMpeg4Dec
->hMFCMpeg4Handle
.bConfiguredMFCDst
== OMX_TRUE
) {
2141 ret
= Exynos_Mpeg4Dec_DstIn(pOMXComponent
, pDstInputData
);
2142 if (ret
!= OMX_ErrorNone
) {
2143 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2144 pExynosComponent
->callbackData
,
2145 OMX_EventError
, ret
, 0, NULL
);
2155 OMX_ERRORTYPE
Exynos_Mpeg4Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
2157 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2158 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2159 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2160 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2164 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2165 ret
= OMX_ErrorNone
;
2168 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2169 ret
= OMX_ErrorNone
;
2173 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
2174 if ((pMpeg4Dec
->bDestinationStart
== OMX_FALSE
) &&
2175 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2176 Exynos_OSAL_SignalWait(pMpeg4Dec
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2177 Exynos_OSAL_SignalReset(pMpeg4Dec
->hDestinationStartEvent
);
2180 ret
= Exynos_Mpeg4Dec_DstOut(pOMXComponent
, pDstOutputData
);
2181 if ((ret
!= OMX_ErrorNone
) &&
2182 (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2183 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2184 pExynosComponent
->callbackData
,
2185 OMX_EventError
, ret
, 0, NULL
);
2194 OSCL_EXPORT_REF OMX_ERRORTYPE
Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent
, OMX_STRING componentName
)
2196 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2197 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2198 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2199 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
2200 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2201 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2203 OMX_S32 codecType
= -1;
2207 if ((hComponent
== NULL
) || (componentName
== NULL
)) {
2208 ret
= OMX_ErrorBadParameter
;
2209 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
2212 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_MPEG4_DEC
, componentName
) == 0) {
2213 codecType
= CODEC_TYPE_MPEG4
;
2214 } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H263_DEC
, componentName
) == 0) {
2215 codecType
= CODEC_TYPE_H263
;
2217 ret
= OMX_ErrorBadParameter
;
2218 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName
, __LINE__
);
2222 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2223 ret
= Exynos_OMX_VideoDecodeComponentInit(pOMXComponent
);
2224 if (ret
!= OMX_ErrorNone
) {
2225 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_Error, Line:%d", __LINE__
);
2228 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2229 pExynosComponent
->codecType
= HW_VIDEO_DEC_CODEC
;
2231 pExynosComponent
->componentName
= (OMX_STRING
)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE
);
2232 if (pExynosComponent
->componentName
== NULL
) {
2233 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2234 ret
= OMX_ErrorInsufficientResources
;
2235 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2238 Exynos_OSAL_Memset(pExynosComponent
->componentName
, 0, MAX_OMX_COMPONENT_NAME_SIZE
);
2240 pMpeg4Dec
= Exynos_OSAL_Malloc(sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2241 if (pMpeg4Dec
== NULL
) {
2242 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2243 ret
= OMX_ErrorInsufficientResources
;
2244 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2247 Exynos_OSAL_Memset(pMpeg4Dec
, 0, sizeof(EXYNOS_MPEG4DEC_HANDLE
));
2248 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2249 pVideoDec
->hCodecHandle
= (OMX_HANDLETYPE
)pMpeg4Dec
;
2250 pMpeg4Dec
->hMFCMpeg4Handle
.codecType
= codecType
;
2252 if (codecType
== CODEC_TYPE_MPEG4
)
2253 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_MPEG4_DEC
);
2255 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_H263_DEC
);
2257 /* Set componentVersion */
2258 pExynosComponent
->componentVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2259 pExynosComponent
->componentVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2260 pExynosComponent
->componentVersion
.s
.nRevision
= REVISION_NUMBER
;
2261 pExynosComponent
->componentVersion
.s
.nStep
= STEP_NUMBER
;
2262 /* Set specVersion */
2263 pExynosComponent
->specVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2264 pExynosComponent
->specVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2265 pExynosComponent
->specVersion
.s
.nRevision
= REVISION_NUMBER
;
2266 pExynosComponent
->specVersion
.s
.nStep
= STEP_NUMBER
;
2269 pExynosPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2270 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2271 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2272 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2273 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2274 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_INPUT_BUFFER_SIZE
;
2275 if (codecType
== CODEC_TYPE_MPEG4
) {
2276 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingMPEG4
;
2277 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2278 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/mpeg4");
2280 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingH263
;
2281 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2282 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/h263");
2284 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2285 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2286 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatUnused
;
2287 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2288 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
2289 pExynosPort
->portWayType
= WAY2_PORT
;
2292 pExynosPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2293 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2294 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2295 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2296 pExynosPort
->portDefinition
.format
.video
.nSliceHeight
= 0;
2297 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE
;
2298 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingUnused
;
2299 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2300 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "raw/video");
2301 pExynosPort
->portDefinition
.format
.video
.pNativeRender
= 0;
2302 pExynosPort
->portDefinition
.format
.video
.bFlagErrorConcealment
= OMX_FALSE
;
2303 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420Planar
;
2304 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2305 pExynosPort
->bufferProcessType
= BUFFER_COPY
| BUFFER_ANBSHARE
;
2306 pExynosPort
->portWayType
= WAY2_PORT
;
2308 if (codecType
== CODEC_TYPE_MPEG4
) {
2309 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2310 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->mpeg4Component
[i
], OMX_VIDEO_PARAM_MPEG4TYPE
);
2311 pMpeg4Dec
->mpeg4Component
[i
].nPortIndex
= i
;
2312 pMpeg4Dec
->mpeg4Component
[i
].eProfile
= OMX_VIDEO_MPEG4ProfileSimple
;
2313 pMpeg4Dec
->mpeg4Component
[i
].eLevel
= OMX_VIDEO_MPEG4Level3
;
2316 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2317 INIT_SET_SIZE_VERSION(&pMpeg4Dec
->h263Component
[i
], OMX_VIDEO_PARAM_H263TYPE
);
2318 pMpeg4Dec
->h263Component
[i
].nPortIndex
= i
;
2319 pMpeg4Dec
->h263Component
[i
].eProfile
= OMX_VIDEO_H263ProfileBaseline
| OMX_VIDEO_H263ProfileISWV2
;
2320 pMpeg4Dec
->h263Component
[i
].eLevel
= OMX_VIDEO_H263Level45
;
2324 pOMXComponent
->GetParameter
= &Exynos_Mpeg4Dec_GetParameter
;
2325 pOMXComponent
->SetParameter
= &Exynos_Mpeg4Dec_SetParameter
;
2326 pOMXComponent
->GetConfig
= &Exynos_Mpeg4Dec_GetConfig
;
2327 pOMXComponent
->SetConfig
= &Exynos_Mpeg4Dec_SetConfig
;
2328 pOMXComponent
->GetExtensionIndex
= &Exynos_Mpeg4Dec_GetExtensionIndex
;
2329 pOMXComponent
->ComponentRoleEnum
= &Exynos_Mpeg4Dec_ComponentRoleEnum
;
2330 pOMXComponent
->ComponentDeInit
= &Exynos_OMX_ComponentDeinit
;
2332 pExynosComponent
->exynos_codec_componentInit
= &Exynos_Mpeg4Dec_Init
;
2333 pExynosComponent
->exynos_codec_componentTerminate
= &Exynos_Mpeg4Dec_Terminate
;
2335 pVideoDec
->exynos_codec_srcInputProcess
= &Exynos_Mpeg4Dec_srcInputBufferProcess
;
2336 pVideoDec
->exynos_codec_srcOutputProcess
= &Exynos_Mpeg4Dec_srcOutputBufferProcess
;
2337 pVideoDec
->exynos_codec_dstInputProcess
= &Exynos_Mpeg4Dec_dstInputBufferProcess
;
2338 pVideoDec
->exynos_codec_dstOutputProcess
= &Exynos_Mpeg4Dec_dstOutputBufferProcess
;
2340 pVideoDec
->exynos_codec_start
= &Mpeg4CodecStart
;
2341 pVideoDec
->exynos_codec_stop
= &Mpeg4CodecStop
;
2342 pVideoDec
->exynos_codec_bufferProcessRun
= &Mpeg4CodecOutputBufferProcessRun
;
2343 pVideoDec
->exynos_codec_enqueueAllBuffer
= &Mpeg4CodecEnQueueAllBuffer
;
2345 if (codecType
== CODEC_TYPE_MPEG4
)
2346 pVideoDec
->exynos_checkInputFrame
= &Check_Mpeg4_Frame
;
2348 pVideoDec
->exynos_checkInputFrame
= &Check_H263_Frame
;
2350 pVideoDec
->exynos_codec_getCodecInputPrivateData
= &GetCodecInputPrivateData
;
2351 pVideoDec
->exynos_codec_getCodecOutputPrivateData
= &GetCodecOutputPrivateData
;
2353 pVideoDec
->hSharedMemory
= Exynos_OSAL_SharedMemory_Open();
2354 if (pVideoDec
->hSharedMemory
== NULL
) {
2355 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2356 Exynos_OSAL_Free(pMpeg4Dec
);
2357 pMpeg4Dec
= ((EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
= NULL
;
2358 Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2359 ret
= OMX_ErrorInsufficientResources
;
2363 pExynosComponent
->currentState
= OMX_StateLoaded
;
2365 ret
= OMX_ErrorNone
;
2373 OMX_ERRORTYPE
Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent
)
2375 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2376 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2377 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2378 EXYNOS_OMX_VIDEODEC_COMPONENT
*pVideoDec
= NULL
;
2379 EXYNOS_MPEG4DEC_HANDLE
*pMpeg4Dec
= NULL
;
2383 if (hComponent
== NULL
) {
2384 ret
= OMX_ErrorBadParameter
;
2387 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2388 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2389 pVideoDec
= (EXYNOS_OMX_VIDEODEC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2391 Exynos_OSAL_SharedMemory_Close(pVideoDec
->hSharedMemory
);
2393 Exynos_OSAL_Free(pExynosComponent
->componentName
);
2394 pExynosComponent
->componentName
= NULL
;
2396 pMpeg4Dec
= (EXYNOS_MPEG4DEC_HANDLE
*)pVideoDec
->hCodecHandle
;
2397 if (pMpeg4Dec
!= NULL
) {
2398 Exynos_OSAL_Free(pMpeg4Dec
);
2399 pMpeg4Dec
= pVideoDec
->hCodecHandle
= NULL
;
2402 ret
= Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent
);
2403 if (ret
!= OMX_ErrorNone
) {
2407 ret
= OMX_ErrorNone
;